Monitoring your unit tests without lifting a finger

I love unit testing. First of all, I think it is a good idea to test separate units of the code, but after doing so for some time, I’ve come to realize that unit tests are great for managing the software development cycle too. It all boils down to the idea that you should write tests before you write your code.

Now, this is something that I and others apparently struggle a lot with. How do you write a test for some code that doesn’t even exist yet? Even worse, how do you write a test for a piece of software that you’re not yet sure how will be used?

In computational physics, this problem arises often because we are writing code at the same time as we are trying to understand the physics, mathematics and algorithms at hand. And this is a good thing. You might want to think that one should structure all code before it is written, but this is generally a bad approach in computational physics. Especially if you’re working on something new. The reason is that you will often understand the problem and algorithms better while developing, rather than just reading about them and trying to analyze them blindly.

Keeping the tests and code healthy

But enough with the talk, let’s just assume that you are convinced that you should (or have to) implement some unit tests. At one point you are likely to be in a position where you find it tiresome to have to go into that folder where the tests are defined and run them manually. This is where Jenkins comes in to play.

Continue reading Monitoring your unit tests without lifting a finger

Limiting the width of Wikipedia-articles when reading on widescreens

I’m using a widescreen display most of the day, which makes it quite useful to have two browser windows openĀ or one browser window and a text-editor side-by-side. But sometimes I keep the browser window maximized, which is a bad thing for sites like Wikipedia. The articles get dragged out in full width, making the lines a bit too long to read comfortably:

Way too long lines to read comfortably.
Way too long lines to read comfortably.

Thankfully, it is quite easy to fix this. I came over one solution with a bookmarklet, but this requires you to click a button for each article. If you have logged in to Wikipedia, however, you may add your own custom CSS that will appear on all articles by clicking Preferences > Appearance > Custom CSS.

In the editor that shows up, add the following:

body {
    max-width: 65em;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    float: none;

After this change, Wikipedia pages are limited to the width of 65em (approximately 1000 px):

Wikipedia with a much better width.
Wikipedia with a much better width.

If you want to add this to all pages on the web, you should consider a bookmarklet like the one mentioned here.