Steady as a rock

…or so they say

 

Freenode staff, please die in a big chemical fire

[Warning: very opinionated content]

(more…)

Filed under : Uncategorized
By Dennis Kaarsemaker
On May 31, 2008
At 19:51
Comments : 15
 
 

Smoky weddingdress

I’m so glad that my girlfriend bought her weddingdress a few weeks ago. Right now a building next to the weddingdress shop is burning down and the smoke is blowing over it, probably ruining all of the dresses. It was already hard to find an affordable, beautiful dress, this surely would have made it harder.

Filed under : Personal
By Dennis Kaarsemaker
On May 30, 2008
At 19:54
Comments : 0
 
 

Ubuntu membership councils

Yesterday was the first meeting of the Ubuntu EMEA membership board and I think it was a great success. We managed to process 13 membership applications,10 people were accepted as Ubuntu members. This is a huge improvement for prospective members who now do not have to wait for the Community Council to meet, but can turn to local membership boards. So there are now 3 ways to become Ubuntu member:

  • Contribute to the development of Ubuntu and become member through the “Ubuntu Developers” or “Ubuntu Universe Contributors” team.
  • Contribute to Kubuntu or Edubuntu and become Ubuntu member via their respective membership process
  • Contribute to a LoCoteam and come to your regional membership board for membership.

There are now 378 Ubuntu members, that is 378 people who made significant contributions to Ubuntu and the Ubuntu community. There are many more of you out there who make such significant contributions, so this delegation will make sure all those contributions will be recognized!

Filed under : Ubuntu
By Dennis Kaarsemaker
On May 28, 2008
At 20:53
Comments :1
 
 

Ubuntu security notices and updates feeds changed location

Filed under : Ubuntu
By Dennis Kaarsemaker
On April 25, 2008
At 20:05
Comments : 2
 
 

Rickrolled!

Argh, as part of a top 25 of “Bad but Gold” songs (think YMCA and co), TMF just aired Rick as well. RICKROLLED!

Filed under : Uncategorized
By Dennis Kaarsemaker
On March 23, 2008
At 18:32
Comments : 0
 
 

User management tricks

Inspired by the latest launchpad news, here is a better version of launchpadduser.py. It does more sanity checking, can be used as a module and allows you to use a different name locally than on launchpad (eg sudo ./launchpadduser.py –launchpad-name kiko christian) Enjoy!

In related news: It’s now happened too often that I had to walk a user through the boot with live cd/find partition/chroot/passwd hoops after they forget the password for their account. So I whipped up a shellscript that one can wget and run from a live cd. It searches for partitions with linux installs on them and allows you to the password for any account on them that has a usable password. So now these hoops are reduced to:

Filed under : Ubuntu
By Dennis Kaarsemaker
On March 22, 2008
At 16:45
Comments : 9
 
 

Chocolate!

Fact one: Women who have their monthly problems need chocolate and preferably lots of it
Fact two: My girlfriend like to bake pies
Fact three: She has her monthly problems now (why else would I be blogging instead of spending time with her)

Result:

Now this is bad for you but tastes soooooo good!

Filed under : Personal
By Dennis Kaarsemaker
On February 3, 2008
At 15:23
Comments : 4
 
 

Ventriloquists

When I was fixing the Ubuntu setup on the pc of a now happy Ubuntu user, he pointed me to a video on youtube called “Achmed the terrorist”. Achmet is one of Jeff Dunhams puppets and he is a dead suicide bomber who threatens to kill in an increasingly squeeky voice. He also has a christmas song now ;)

Anyway, apparently someone uploaded both his shows to youtube and sure enough I watched them. Jeff’s quite rude at times but overall pretty funny, at least much funnier than many so-called comedians out there. Motivated by this, I searched for ‘ventriloquist’ on youtube and sadly the result was less than stellar.

Until I saw Terry Fator that is. Last year Terry apparently was a candidate in “America’s got talent”, a show I didn’t even know existed. He is absolutely brilliant! Funny, good impersonator, excellent singer and amazing entertainer. If you’ve never seen him, you absolutely should go to youtube and search for his impersonation of Roy Orbison. While you’re at it, watch it all. BRILLIANT!

Filed under : Uncategorized
By Dennis Kaarsemaker
On January 13, 2008
At 19:53
Comments : 2
 
 

Traincoding: network-manager annoyance

xs4all, the best ISP in the Netherlands, now offers free wifi at KPN hotspots to its members. This is excellent, since 3 stations I pass when traincoding now have wifi I can use, so I can use documentation when hacking and not look like an arse because I don’t read docs.

The latest quick hack didn’t work properly at the 2nd station, so I looked up documentation, found my error and now I present: nm_unset - a very simple tool with which you can remove wifi networks for network manager from gconf. I simply got tired of having to use gconftool-2 –recursive-unset /system/networking/wireless/networks/$ssid all the time (and of having to explain how to do this to new users on #ubuntu). I’m really hoping that they soon provide something in n-m for this so I can toss this out again.

Filed under : Ubuntu, Traincoding
By Dennis Kaarsemaker
On January 11, 2008
At 17:52
Comments : 2
 
 

So here it is, merry christmas

…oh wait new year

…oh crap, it’s the 11th already

Been quite busy the past weeks, so not much writing has happened. After christmas I finally picked up work on falcon again. Version 2.0.0 was finally finished and Brandon Holtsclaw was kind enough to upload it to Ubuntu, Yeah! Of course a few bugs were found (and fixed) after that, so version 2.0.4 will be uploaded shortly, which is the recommended one.

At work (where we need more linux sysadmins, prod if interested!) I have been working on a project I called imagine, it’s an OS ‘installer’ that can make an image of your harddrive and install it on another machine. That’s nowhere near unique of course, but this thing runs entirely from initramfs so you can simply use network booting and don’t need other media than a server to store the compressed images. Best thing about it is that the COO allowed me to distribute the code as free sofware, so when that finally clears with legal, you’ll see more of it!.

Filed under : Uncategorized
By Dennis Kaarsemaker
On
At 16:16
Comments : 2
 
 

Career defining moments

The past few weeks I’ve had to make some non-trivial choices regarding my future career and sadly this took up pretty much all my time. Since some people have wondered where I have been lately, I’m posting it here. Then again, most people probably won’t care so I’ll use a ‘click here to read more link’. So read more if you want to know what I’ve been up to or if you’re looking for a windows admin, linux admin or perl developer job in Amsterdam (there are many non-tech vacancies as well).

(more…)

Filed under : Uncategorized
By Dennis Kaarsemaker
On December 1, 2007
At 13:22
Comments : 4
 
 

Ubuntu on toshiba satellite s2670

X does ‘weird’ things on this machine (trident chip), looks like a moire effect so I assume sync issues. Being an X noob, I can’t figure out how to fix this,  following hints found on the web (mostly involving modelines) didn’t work either. Is there anyone out there who reads this and can give me a hint? Please?

Filed under : Uncategorized
By Dennis Kaarsemaker
On November 28, 2007
At 01:31
Comments : 6
 
 

Traincoding: Permutations in python

To my shock, I didn’t find a way to enumerate all permutations of a set of items in any reasonably standard python module. (aka installed when I found out on the train). Of course this has been implemented many times before but I’m sharing it anyway :)
A set of n items has n! permutations. Simple factorial implementation (seems also nowhere to be found in the standard python libs or numpy):

def factorial(x):
    if x < 0:
        raise ValueError("Factorial is only defined for x >= 0")
    y = 1
    while x >= 2:
        y *= x
        x -= 1
    return y

Permutations can easily be defined recursively, but that limits you to sets of 1000 items (maximum recursion depth). So better to make an iterative function. Even better: instead of returning a list, use a generator so you don’t have to copy an array many times. This is also a perfect example of writing obfuscated code in a clean language like python.

def permute(items, i):
    items = items[:]
    n = len(items)
    m = factorial(n)
    while n:
        c = (i%m) * n / m
        yield items[c]
        items.pop(c)
        m /= n
        n -= 1

Example:

>>> import permute
>>> items = [1,2,3]
>>> for i in range(permute.factorial(len(items))):
...     print list(permute.permute(items, i))
...
[1, 2, 3]
[1, 3, 2]
[2, 1, 3]
[2, 3, 1]
[3, 1, 2]
[3, 2, 1]
Filed under : Traincoding
By Dennis Kaarsemaker
On November 10, 2007
At 22:48
Comments : 5
 
 

Traincoding part one: per-thread global variables

Update: keybuk points out that this is pretty useless and that you should read documentation instead.

Every day, I travel about 80 minutes to work and 80 minutes back, by public transport. This is rather boring but fortunately I usually have my laptop with me, so I can do some work or experiments. Last week I started a little project I call traincoding: trying to accompish some small tasks while on the train. This is the first episode of the traincoding log.

Per-thread global variables

A simple way to make your library cumbersome to use in a threaded environment, is the use of global variables. They often have to be locked and unlocked, which costs quite a bit of time. If the global variables aren’t neccessarily global in the process but shared between functions (a good example is the infamous errno variable, which is thread-local by the way), the posix specification gives you something useful: pthread_setspecific. With this and some other functions from libpthread you can make an errno-like thread-local global variable.

In a modern glibc, errno is no longer an extern int errno; but a macro:

#define errno (*__errno_location ())

the __errno_location function finds out the thread-local address where errno is stored. This does not need pthread_getspecific since the C runtime allocates memory for errno explicitely. For our purposes we need to do our own allocation. Of course this is not limited to integers. The only thing we store is a pointer, the C runtime does not care what the pointer points to.

So, let’s define our macro first:

#define my_var (*(__get_my_var_location()))

The __get_my_var_location function now creates the key when it’s first called. It also allocates memory when it is first called in a specific thread:

pthread_key_t __my_var_location;
pthread_once_t __my_var_init;

void __init_my_var(void) {
    pthread_key_create(&__my_var_location, NULL);
}

int *__get_my_var_location(void) {
    void *ptr;
    (void) pthread_once(&__my_var_init, __init_my_var);
    ptr = pthread_getspecific(__my_var_location);
    if(!ptr) {
        ptr = malloc(sizeof(my_var_t));
        pthread_setspecific(__my_var_location, ptr);
    }
    return (int*)ptr;
}

That’s easy to use already, but having to type out 2 functions for every variable-like macro which you want to use this way is still a bit cumbersome, so why not let the C preprocessor do it for you? Here’s where it gets evil! You can download the code at the bottom as perthread.h and simply use the following in your code (here’s a full test):

#include
#include "perthread.h"

PER_THREAD(unsigned int, foo) /* NOTE: no semicolon! */
#define foo (*(__get_foo_location()))

static pthread_barrier_t barrier;
void *thread(void *arg) {
    foo = (unsigned int)pthread_self();
    printf("thread: %u foo: %un", (unsigned int)pthread_self(), foo);
    pthread_barrier_wait(&barrier);
    printf("thread: %u foo: %un", (unsigned int)pthread_self(), foo);
    return NULL;
}

int main(int argc, char **argv) {
    pthread_t t1, t2, t3;
    void *res;

    pthread_barrier_init(&barrier, NULL, 3);
    pthread_create(&t1, NULL, thread, NULL);
    pthread_create(&t2, NULL, thread, NULL);
    pthread_create(&t3, NULL, thread, NULL);
    pthread_join(t1, &res);
    pthread_join(t2, &res);
    pthread_join(t3, &res);

    return 0;
}

perthread.h contains the following PER_THREAD macro (you have to imagine a backslash at the endo of each line, wordpress messes it up):

#define PER_THREAD(type, name)
static pthread_once_t __ ## name ## _init = PTHREAD_ONCE_INIT;
static pthread_key_t __ ## name ## _location;
void __init_ ## name (void) {
    pthread_key_create(&__ ## name ## _location, free);
}
int *__get_ ## name ## _location(void) {
    void *ptr;
    (void) pthread_once(&__ ## name ## _init, __init_ ## name);
    ptr = pthread_getspecific(__ ## name ## _location);
    if(!ptr) {
        ptr = malloc(sizeof(type));
        pthread_setspecific(__ ## name ## _location, ptr);
    }
    return (type*)ptr;
}

This macro takes care of creating your initialization function and get_location function, all with the correct type and name. To see that it’s correct, run it through the C preprocessor.

That’s part one of traincoding. See you next time!

Filed under : Traincoding
By Dennis Kaarsemaker
On November 4, 2007
At 15:04
Comments : 3
 
 

End of an era, beginning of another

Back in 2005, when Ubuntu was still young and #ubuntu small (less than 300 users), I became Ubuntu member and IRC operator. At the latest Ubuntu release the channel peaked at over 1600 and usually has more than 1200 users. It’s been fantastic to see this growth in #ubuntu and related channels.

In the past 3 years it’s been a fun ride from Ubuntu user/channel visitor in 2004, through IRC op, and then representative of Ubuntu on freenode. Earlier this year we have worked on a more formal IRC governance, resulting in an IRC council of which I have been a proud member.

But today that has all come to an end, I have resigned from the council and have placed the responsibility for Ubuntu’s presence on freenode in the caring hands of the other council members. The IRC community is a vital part of the community and is in good shape, it is time for me to do the same for my other big love inside the Ubuntu community: the dutch locoteam.

Founded in 2004, the dutch locoteam it is one of the oldest locoteams around and has seen a steady growth over the past years. We have many forum contributors and a good crew of active people, it is time to turn this enthousiastic group of people into a professional team of Ubuntu supporters.

We’re halfway there already, the active members all have great ideas on how to move forward and lots of progress has been made already. The best part so far of this is the AWESOME release party we had last saturday, we estimate the number of visitors at over 400!

On to 2008, the year of Ubuntu-NL!

Filed under : Ubuntu, Personal
By Dennis Kaarsemaker
On October 31, 2007
At 18:26
Comments : 5