27
Jan 12

Veel thee drinken, diep ademhalen en doorgaan


Het is inmiddels alweer een aantal dagen geleden dat hij me vertelde verliefd te zijn op iemand anders. Je hart breekt, je maag draait en je hoofd zegt: “Nee, dit is niet waar!” Tegelijkertijd vallen er een aantal puzzelstukjes op hun plek, zie je opeens het complete plaatje en besef je dat het wel degelijk [...]
23
Jan 12

Javascript parent constructor being run when defining inheritance and a solution


When using the traditional Javascript methods to do some sort of inheritance, the constructor of the parent will always be run when trying to inherit it. This seems to be a unfortunate side effect of using new a().

The problem

Consider this code. Here b inherits from a

function a() {
    console.log("a");
}
 
function b() {
    a.call(this);
    console.log("b");
}
b.prototype = new a(); // a's constructor will be run here!
b.prototype.constructor = b;
 
new b(); // run once
new b(); // run twice

Here a’s constructor will be run 3 times.

a
a
b
a
b

The solution

There is a simple fix for this, but its only in Ecmascript 5.
Change this:

b.prototype = new a();

Into this:

b.prototype = Object.create(a.prototype);

And the constructor will only be run when actually being called:

a
b
a
b
22
Jan 12

Using hgtools with mercurial tags to automatically version packages


I liked to automate my python package versioning a bit more and did this with hgtools. With hgtools it is quite easy to store the version numbers only in your repository as tags, and not having it again in setup.py.

A minimal setup.py can look like this:

from setuptools import setup, find_packages
setup(
    name="HelloWorld",
    use_hg_version=True,
    packages=find_packages(),
    setup_requires=["hgtools"],
)

Just give a revision a tag and make an sdist, or bdist and setuptools will use the version from your tag.
Tags have to conform to strict version formatting from distutils to be used by hgtools.

Later I also made it a step in a Jenkins setup, to always build a sdist and copy it to a HTTP accessible directory so it could be installed with pip. This gave me a nice history of available release packages and also, dev versions.

22
Jan 12

Wekelijks bezoekje aan de weegschaal


Vanmorgen mocht ik weer op de weegschaal staan, iets wat tegenwoordig best een leuke bezigheid is. Met de nadruk op tegenwoordig want vorig jaar, eind juli, dacht ik op een ochtend ook weer eens op de weegschaal te gaan staan. Oh wat ben ik toen geschrokken! Ik woog 71 kilo! Hoe kon dat? Met het [...]
12
Jan 12

Lekker hangen ;-)


06
Jan 12

Hormoonmonsters


Vandaag niet ter afwisseling een leuke foto, tekening of wat dan ook, maar een rant. Want zoals veel mannen aan hun vrouwen merken, hebben zij af en toe zo’n periode waarin ze extra snel op hun teentjes getrapt zijn, iets meer zeuren of sneller huilen. Zo’n periode waarin ze clichématig bedolven willen worden onder chocola [...]
30
Dec 11

Jaarafsluiting


Nog 24 uur te gaan! In mijn eerste blogpost dit jaar schreef ik dat ik weer meer wilde gaan bloggen. Dit goede voornemen is gelukt! In 2011 heb ik (inclusief deze) 27 berichten geplaatst, dat zijn er 17 meer dan in 2010. Hier zit ook meer beeldmateriaal bij, omdat het me wel leuk leek elk [...]
25
Dec 11

Fijne kerstdagen!


24
Dec 11

The legend of the Christmas Spider


This is a folk legend from Ukraine. There once was a widow, who lived with her children in a small house. One day a pine cone dropped on the floor and after a while, they discovered that it had took root. It grew and it grew and the children of the widow were excited that [...]
17
Dec 11

Een mooie dag