A common problem with configuration files is that they only allow simple values like strings, integers, doubles. It’s not uncommon to want to include more complex values such as a list or dictionary in your config.
The most elegant approach I’ve seen for doing this in python is to make use of the json library to parse the values. First I’ll load an example config file using python’s SafeConfigParser. Typically your config would be in a separate file, however for the purposes of this blog post I’ll use a multi-line string.
Today’s linked article gives a very in depth introduction to doing full text search in Postgres. The author demonstrates everything with numerous code examples. Their assertion is that for smaller projects, postgres provides all the features you need and you won’t require a more specialized search system.
February 2022 updated: I replaced the original link with the Wayback Machine due to the original website no longer existing.
What is NUnit and why use it? NUnit is a .NET port of the popular JUnit test library for Java. It has several advantages that Microsoft’s test framework doesn’t.
If you run MS Tests or NUnit tests in visual studio then all your tests appear as a flat list in the test explorer. You only get the method names. If you use the NUnit runner you get the full namespace/class/method hierarchy as seen in the screenshot below.
I highly recommend having a read through this talk: Move Fast and Break Nothing. There are some great ideas in it on continuous development, testing, communication and learning/teaching on the job. Well worth the time to read through and think about whether you can apply some of the points in it to your work.
A note about this blog: I’m going to try and get into a more regular cadence of posts.
less is already an incredibly useful command in linux (GNU/linux for the purists). It’s a better version of more, for paging through files. One not so well known switch for less is the following:
less +F [file]
The +F option tails the end of the log. Updating when the log changes is buffered, so depending on how noisy your log file is there may be some delay in seeing updates.
DateTimes in .NET are always in one of two timezones - UTC or local time. This advice will make your life easier:
Always store DateTimes in UTC.
Unfortunately sometimes we need to deal with timezones stored in a timezone other than UTC. Maybe we’ve inherited a system or we’re integrating with another system which doesn’t save as UTC. If your web server and database server are both in the same timezone and the DateTime is stored in the server’s local timezone then everything is still OK.
When handling errors you want to do one of the following:
Crash the program. Ignore the error. Try to fix the error and continue. The correct approach depends on a number of factors. What is your application? Do you have enough information available to try and recover or infer what the user wanted to do? Is the error going to impact other operations later on? No matter which approach you choose for handling the error, you ought to use logging!