Nothing surprises me in VB.NET

Posted on Tue 27 March 2012 in Coding • Tagged with nothing, null, vb.net

I currently work in a VB.NET project with a customer, and what amazes me is that I over and over again get the feeling that the language is designed to be easy to work with, but at the same time there are so many aspects of it that behave …


Continue reading

NSubstitute vs Moq - a quick comparison

Posted on Mon 27 February 2012 in Coding • Tagged with mock, moq, nsubstitute, test

When you write unit tests, you occasionally need to mock away dependencies of the subject under test (SUT). By far the easiest way to do this is to use a mocking library, which has the added benefit that it allows you to verify the behavior of the SUT by inspecting …


Continue reading

Using Git locally within a Subversion branch

Posted on Thu 19 January 2012 in Tools • Tagged with git, subversion

I'm not a big fan of Subversion but I'm madly in love with Git! So much that when I have to use Subversion, I create a Git repository within my locally checked out Subversion branch. This is really easy to do, and only takes four simple steps:

  1. Navigate to the …

Continue reading

LVM recipe: determine which physical volume(s) a logical volume is located on

Posted on Thu 19 January 2012 in Sysadmin • Tagged with lvm, recipe

Run the lvs command as follows:

# lvs --segments -o +pe_ranges

The output should be something similar to this:

LV      VG   Attr   #Str Type   SSize   PE Ranges
data    data -wi-ao    1 linear   1.82t /dev/md4:0-476930
data    data -wi-ao    1 linear   1.36t /dev/md2:0-357701
homes   data -wi-a-    1 …

Continue reading

Node.js experimentation - a GitHub clone script

Posted on Thu 19 January 2012 in Coding • Tagged with async, git, node.js

Recently I wrote my first Node.js program! Yeah, yeah, I know! Late to the game and all that! But I thought it was time to catch up with the rest of the world. Better late than never, right? (Also, the program needed to parse JSON data, so JavaScript felt …


Continue reading

Strongly typed properties in Java vs C#

Posted on Thu 19 January 2012 in Coding • Tagged with delegate, generics, method group, csharp, java

The background for this post was that I needed to implement strongly typed properties in a C# project. With strongly typed property, I specifically mean a strongly typed version of public object GetProperty(string propertyName), where the property name is a constant (or name) of some sort, and the return …


Continue reading

Generic extension method with multiple constraints

Posted on Wed 18 January 2012 in Coding • Tagged with constraints, extension methods, generics

In a .NET project, I was coding an extension method for forms, and for various reasons I needed to call a form method which came from an interface. Instead of coding an ugly type check and subsequent type cast, I was happy to discover that I could simply create a …


Continue reading

Playing with Java annotation processing

Posted on Fri 06 January 2012 in Coding • Tagged with annotations, apt, Java, spi

I found Project Lombok via a Tweet, and was intrigued when I saw that a single annotation could trigger automatic code generation transparently during compilation of a source file. How do they do that?

Some digging lead me to discover Java's annotation processing API, and how one can use SPI …


Continue reading

Adventures in updating hard drive firmware

Posted on Fri 06 January 2012 in Sysadmin • Tagged with boot, firmware, iso, linux

I decided to update the firmware of two of my hard drives. The drives in question are both Seagate Barracuda 7200.11, model ST3500320AS, and smartctl gave me the following warning:

==> WARNING: There are known problems with these drives,
see the following Seagate web pages:

http://seagate.custkb.com/seagate …

Continue reading

Generator combined with with/using statement - Python vs C#

Posted on Fri 30 December 2011 in Coding • Tagged with c#, generator, Python

The other day, I tried to return a generator expression from within a with statement in Python, like so:

#!/usr/bin/python

def readlines(fn):
    with open(fn) as fd: # <-- the with statement
        return (line for line in fd) # <-- the generator expression

if __name__ == "__main__":
    for line in readlines("/proc …

Continue reading