How I tackled a hard problem in a new language

I’ve just started a lot of new things in my life; programming Scala (and Python), data engineering and a new client.

Luckily the things we have built until now is algorithmically pretty simple and … what was that? Calculate the what-now temperature?! The wet-bulb temperature? Wash your mouth with soap, young man! What on earth is that?!

And you want me to write this in Scala?! This is horrible.

In this blog post I’ll walk you through my thinking and application of experience to write one of the most complicated calculations I’ve ever put into a program, in a programming language that I’ve never seen 2 months ago.

It actually took me all of 1 hour to get this to work - and still be confident that it works.

Read More

Learning about Python list comprehensions

I’m learning a brand new programming language. That should probably say, new for me.Because it’s Python. I haven’t touched it before. Yes yes - I’m slow, old and everything. But I am still learning new things… so I’m not all in all bad.

Ok - Python is for the most part very nice to work with and reading and writing code has been easy so far. Until I saw a backwards for-loop. It just looked… weird.

Turns out it was not a for-loop at all, but rather a list comprehension.

Read More

Next.JS - testing async React components

I had the great joy of teaching a course on Next JS 13 this last week. Next has for a long time been a favorite of mine and with version 13 they have really stepped it up a notch. Or three.

But what they still are lacking, and for the life of me I cannot understand why, is a good out-of-the-box testing story.

This caused me and the group I was teaching considerable head-ache - especially when we tried to test the server-side async components that Next.JS is plugging hard.

Therefor I have two goals with this post:

  1. Help me (and you?) to easily get started with testing
  2. Show a way to test async server components

Let’s do this.

Read More

Deploying. NET 6 WebAPI using ARM Template

I’m putting together a course where I want students to easily deploy their code. Since the course is on .NET 6 WebAPIs (and Entity Framework (core)) I thought that Azure would make a great choice to deploy to.

And nowadays ARM templates seems to be the way to go (maybe BICEPs but I’m doing ARM for now).

But I ran into problems, and I wanted to share with you those problems and how I overcame it. Just your normal post on this blog in other words.

Creating the API

The course is pretty fast moving and I needed them to be up and running fast, so my idea is to create a very simple, walking skeleton, version of the application; by adding value in a simple Developers table. Turns out that is quite a lot of steps involved, that I don’t want to take...

Read More

Plans are theoretical

I just had an aha-experience that shook me; first I found it interesting, and then I was ashamed that I haven’t realized this before.

Here it is:

Plans are theoretical

Let me tell you how I realized this and how I think it is important.

At </salt> we’re planning to run yet another Graduation Day, after 35 new developers has been created. That is amazing in itself to be part of, but not the topic of this post.

Someone (Sara - excellent co-worker), called me and asked me the following:

Do we have an agenda for the day?

We sure did, but she was asking me a follow-up question:

Will the after-graduation mingle start at 17?

Now, that is a good question but also where theory meets reality. Not Sara’s fault I want to stress but when I realized it.

Because...

Read More

Testing WebAPI with AspNetCore.Mvc.Testing and xUnit Collections

I’m writing a boot camp for .NET core and have started to learn a lot of things that have changed since I last coded C#. One of them was shown to me by my good friend John Magnusson. (I’m downplaying his knowledge and skills a lot here since I was close to tears and he sent me a link that saved by bacon, but hey - I’m telling the story :))

Anyhow - John showed me Microsoft.AspNetCore.Mvc.Testing that really tells a nice story when it comes to testing an API. In this post I wanted to show you how I used it.

Also - I ran into problems, since I had a database seeding that didn’t work when I used the suggested solution. I will show you how I solved that too, and in the process, tell you a little thing I picked up about xUnit. And...

Read More

xUnit - closing Selenium driver after ALL test in suite

I’m enjoying myself at work right now, writing a course in C# and for the .NET core platform. Man - this was some time ago.

Naturally I learn a lot. That’s why I became a teacher. I wanted to share a little nugget (NuGet?) of gold that I found.

In one of the early labs in the course I used Selenium to write some end-to-end tests. And in doing so I need to create Driver object, that is both pretty heavy to start and, if left after the test run, quickly will eat your memory.

Now, I was using xUnit as my testing framework and xUnit doesn’t have a notion of test suites. This was bad since I wanted to create the Driver object on the first e2e test and not tear it down until the last.

My intial attempt looked like this:

Read More

A data-driven prognosis report

I have a big project ahead here at Salt - I’m going to write an entire boot camp from scratch. This is done as a single-person project and all my other colleagues are working on as normal around me.

I wanted to report my progress to them so that they know what’s happening and also that I can get some leeway of keeping my focus.

In this post, I wanted to share a very simple prognosis tool that I created based on the data that my work create. As always, it’s not perfect but it will give an accurate enough feel for where I am and when it will be done

A few words about the project

Unlike most software development projects I’ve been in the scope of this project is very clear;

  • I’m going to write slides, labs, and instructions for 13 weeks,...
Read More

Writing a Selenium test using .NET core and Visual Studio Code

I’m rediscovering my first programming love; .NET. I’m having a blast and .NET core keeps giving.

This post is one of those - I can’t believe that I couldn’t find this post on the net somewhere. Or I didn’t look hard enough.

But I wanted to setup Selnium testing, but only use .NET Core and Visual Studio Code on my Mac. Every example I saw was using older versions of .NET core (I’m writing this on .NET core 5) and/or Visual Studio, which I don’t have.

Installations

First, to make .NET and C# developement pretty good in a code editor, we need a few addons to Visual Studio:

  • C# extension

  • I also installed Prettier and added support for C# code formatting using the following snippet in my setttings.json-file

    "[csharp]": {...
          
    Read More

Making boring fun - bash and Node to the rescue

I rarely get paid to write code these days… or that is people rarely ask me to write code. But since I’m a programmer at heart it is one of the tools in my toolbelt, regardless of what kind of tasks I’m given.

Today I got asked:

Could you please list all Open Source Licenses we are using, and all the dependencies all our code is using.

Considering we have 130+ repositories I was what the scientist refer to as a boring task.

Let’s make it more fun with code.

I’m gonna wield my bash- and Node-swords to solve this sucker. And I was looking to do some functional programming exercises too - let’s see if we can squeeze all of that in there.

Getting the licenses out of the repos

Each repository has a package.json file that contains a Read More