Browsed by
Category: computer

Developing .NET applications without installing .NET SDK

Developing .NET applications without installing .NET SDK

I recently developed a small .NET application. I considered installing the .NET SDK on my laptop (on which I were to develop the .NET application), but was unsure of which version I would need, and how I would potentially downgrade the SDK version if needed.  Instead of installing the SDK on my laptop, I decided to run the SDK inside a Docker container. This way I could easily switch between SDK versions if needed, as all I’d have to do…

Read More Read More

Docker build fails with “no matching manifest for unknown in the manifest list entries”

Docker build fails with “no matching manifest for unknown in the manifest list entries”

I recently got this error when trying to build a Windows container (specifically microsoft/dotnet-framework:4.7.2-sdk) on my Windows 10 laptop: no matching manifest for unknown in the manifest list entries I was surprised that I couldn’t build Windows containers on my Windows laptop, but then I recalled that Docker for Windows let you choose between running Linux containers or Windows containers. As I until now had exclusively ran Linux containers, my Docker was set up to run Linux containers, but configuring Docker to…

Read More Read More

Patching Python instance methods

Patching Python instance methods

I’m working on a project in which one of our services need to publish messages to a RabbitMQ exchange. Consider this code excerpt from the message queue client:

In my unit tests I wanted to verify that an unsuccessful attempt to publish the message, would cause trigger an exception to be thrown. To test this, I needed basic_publish  to return False. At first I found it tricky to patch instance methods such as basic_publish , but after coming across this excellent…

Read More Read More

Testing a Flask REST API using Factory Boy and an in-memory sqlite database

Testing a Flask REST API using Factory Boy and an in-memory sqlite database

I’m developing a REST API using Python’s Flask microframework. As I wanted to do test driven development to ensure good test coverage, I needed a working testing framework. After checking out a few different options, I found one that works well for my use case. I thought I’d share my setup in case it may be of help to others. First, this is how I create the server:

Passing custom HTTP headers using Flask’s test_client

Passing custom HTTP headers using Flask’s test_client

Passing custon HTTP headers using Flask’s test_client object should have been as easy as doing this:

For some reason this didn’t work in my Flask project. In case others have the same issue as I did, maybe the solution I found to work may work for others too:

 

Mocking SQLAlchemy models in Python

Mocking SQLAlchemy models in Python

I’m developing an API using Python’s Flask framework. The API uses SQLAlchemy, which means that database rows are made available as regular Python classes (referred to as database models) in my Python code. One of my models looks something like this:

My Data Access Object (DAO) for communicating with the database models looks like this:

While writing tests for the API, I wanted to mock out the database models, so that my tests wouldn’t depend on an actual…

Read More Read More

Alarm clock for kids

Alarm clock for kids

I’ve created a very simple Raspberry Pi project that I use to let my kid know if its daytime or nighttime. When I say goodnight and leave my kids bedroom, I trigger a simple script on my Raspberry Pi with a 7″ touchscreen attached. The screen will display a daytime image for a few minutes, before switching to a nighttime image. The nighttime image is an indication for my kid to put down her toys and go to bed. Over…

Read More Read More

Using the “Oboe” Javascript library to speed up data processing

Using the “Oboe” Javascript library to speed up data processing

One of our node.js applications at work was designed to call an internal rest service, cache the whole response, and iterate over the data to separate relevant data from non-relevant data, and write the relevant data to file. To speed things up a bit, we wanted to process, filter and write the data to file as it arrived. For this task, the excellent Javascript library “Oboe” came in handy:

Keywords: HTTP response streaming

“Løp til bussen” – Android-app’en som forteller deg om bussen din er forsinket

“Løp til bussen” – Android-app’en som forteller deg om bussen din er forsinket

For å lære meg litt om Android-programmering jeg har laget en enkel app. App’en er svært enkel, og har som eneste formål å vise sanntidsinfo for din neste reise med buss, bane, tog, trikk eller båt. Utgangspunktet mitt var at jeg enkelt ønsket å finne ut om jeg måtte løpe til bussen eller ikke, for jeg har altfor mange ganger løpt til bussen tidlig om morgenn, for så å bli stående å vente på den fordi den er forsinket.

Setting up Sublime Text as a node.js development environment

Setting up Sublime Text as a node.js development environment

Sublime Text makes a great IDE for node.js development. First, install the node.js software and get your initial project up and running. Various tutorials on the web should get you going. When it’s time to run your app, configure the Sublime Text build system to build it and run it. To avoid having to start and stop your Node server manually, make use of the tool Nodemon – this tool will build and run your app automatically when you edit…

Read More Read More