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 …


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

Certificate error when upgrading to Oneric

Posted on Fri 30 December 2011 in Sysadmin • Tagged with oneric, ubuntu

Just updated one of my Ubuntu servers to Oneric, and I noticed some error messages during the installation:

error adding /etc/ssl/certs/brasil.gov.br.pem
error adding /etc/ssl/certs/cacert.org.pem
error adding /etc/ssl/certs/ca.pem
...

I found a solution in this forum post …


Continue reading

Getting network interfaces in Python

Posted on Fri 30 December 2011 in Sysadmin • Tagged with linux, network interfaces, Python

Here’s a small Python script/module I put together to list all network interfaces on the current server (tested on Linux only!) in a format that easily lets me convert between name, index and address of an interface.

The code is based on getifaddrs.py from pydlnadms, but I …


Continue reading

New features in diskgraph

Posted on Thu 29 December 2011 in Tools • Tagged with diskgraph, linux

I added some new features to diskgraph, and bumped the version to 1.1. New things:

  • Graph nodes now have colors depending on their type.
  • Nodes that represent free space are included in the graph. Only free space >= 5 MB is shown, though.
  • Mounted file systems are shown in the …

Continue reading

Presenting diskgraph

Posted on Wed 28 December 2011 in Tools • Tagged with diskgraph, linux

My server case is full of disks, and many of them are pretty small, like 250 GB. I would like to upgrade the boot disk from a USB stick to a proper SSD disk, but that requires me to replace a number of the smaller disks with something bigger. To …


Continue reading