Blog archives

De speciaalbieren bij de Jumbo op de Westerstraat in Amsterdam

Photo 05-02-13 18 54 15

Ze hebben tegenwoordig Britse speciaalbieren bij de Jumbo op de Westerstraat in Amsterdam, midden in het hartje van de Jordaan. Leuk, maar hoe moet je daar een keuze uit maken, zonder dat je ze allemaal hoeft te kopen?

Geen nood, want ik ben zo’n nerd die dan foto’s maakt van alle bieren, de waarderingen en alchoholpercentages opzoekt op het geweldige BeerAdvocate en ze dan vervolgens als een lijstje op z’n website post.

Voor wie lui is: koop Flying Dog GonzoFuller’s ESB en Fuller’s London Porter.

En voor wie dat niet is, de hele lijst:

Blog archives

Stapes 0.7.0, and the end of create()

I’ve just released version 0.7.0 of Stapes.js, my MVC Javascript microframework. A big change in this release is the deprecation of the create method and the introduction of the new subclass method.

Why the change? The old system worked nicely for single modules, but was broken when trying to create an extension hierarchy. In the old system the creation of a class and the instantiation of that class were the same thing. In really simplified code that looked something like this:

The main problem with this approach is that every property that has been added to Animal after the initial create will become part of the prototype of Dog as well. Even if those properties are instance properties (e.g. Animal.bark = true instead of Animal.prototype.bark = true). This lead to difficult to detect bugs and behaviour.

So, i changed the API so you can create proper classes, based on the new Ecmascript Harmony classes spec. Those of you using Coffeescript or Livescript will feel right at home here.

constructor will become the function that is being called when making an instance with new. All other methods in the object will become part of the class prototype.

The new Module is just a standard Javascript class, so you can add prototype properties using Module.prototype or static properties using direct assignment. Stapes has two convenience methods for this called extend and proto that allow you to quickly add an object of properties to the prototype or directly to the module.

Inheritance can be done by simply calling subclass on a newly created class. The instanceof operator now works correctly too:

Every module now gets a parent property, referencing the parent’s prototype. You can use this to still call a parent method if you’ve overwritten it.

Note that for backwards compatibility the create method on the Stapes global will still work. However, because of the obvious problems it won’t work anymore on submodules. In the future i’ll remove Stapes.create. If you like the old style i recommend you switch to something like var module = (Stapes.subclass()).extend() which is more or less the same as the old Stapes.create().extend() pattern.

So, that’s it. Please leave any questions and remarks in the question section below or file tickets on Github.

Blog archives

Het beste van 2012: muziekalbums

Juist, het is weer die tijd van het jaar. Het einde van het jaar betekent: een lijstje, met de beste albums van het jaar. Het ultieme muzieknerd-ding.

2012 was wat mij betreft geen al te best jaar. Ik heb een hoop geluisterd, maar er was weinig wat er echt enorm uitsprong, veel dingen die zo-zo waren. Weinig verrassends. Maar misschien word ik ook wel oud en ben ik niet meer zo van de nieuwe muziek.

Net zoals voorgaande jaren heb ik bij alle albums die op Spotify beschikbaar zijn een icoontje gezet waar je direct op kan klikken, en heb ik een YouTube mix gemaakt met de beste nummers van elk album. Veel luisterplezier en een mooi 2013!

  1. Death Grips – The Money Store / NO LOVE DEEP WEB
  2. Grizzly Bear – Shields
  3. Kendrick Lamar – good kid, m.A.A.d city
  4. Jessie Ware – Devotion
  5. dEUS – Following Sea
  6. Grimes – Visions
  7. The Shins – Port of Morrow
  8. Dirty Projectors – Swing Lo Magellan
  9. Squarepusher – Ufabulum
  10. First Aid Kit – The Lion’s Roar
  11. Sharon van Etten – Tramp
  12. Leonard Cohen – Old Ideas
  13. Macintosh Plus – Floral Shoppe Gratis download!
  14. Godspeed You! Black Emperor – Allelujah! Don’t Bend! Ascend
  15. Japandroids – Celebration Rock

Voor de archieven: hier zijn mijn lijstjes van 201120102009, 2008, 2007, 2006, 2005 en 2004. En voor wie smult van nog meer lijstjes, check Best Ever Albums, Metacritic, Kindamuzik, Tiny Mix Tapes, NME (scroll naar beneden), OOR, Drowned in SoundPitchfork en Sander Spek.

Ik heb ook een lijstje van mijn favoriete films van dit jaar, die kan je hier lezen.

Blog archives

Het beste van 2012: films

Daar zijn we weer. De Lijst. Voor de eerste keer heb ik naast een lijst met beste muziekalbums ook een lijst gemaakt met mijn favoriete films van het jaar. Voor een volledige lijst van alle films die ik dit jaar heb gezien klik hier. Ik heb zowel documentaires als fictie op de lijst staan.

  1. Jagten
  2. Moonrise Kingdom
  3. Marley
  4. Le Havre
  5. Holy Motors
  6. Cave of Forgotten Dreams
  7. Intouchables
  8. Little World
  9. Teddy Bear
  10. Monsieur Lazhar
Blog archives

Stapes 0.6 is out

Version 0.6 of Stapes.js, my tiny MVC Javascript library has been released.

Thanks to people submitting issues many of the changes are straight from the small but vocal Stapes community :)

New features include:

  • A silent flag for set, push and remove that makes it possible to update attributes without change events being triggered.
  • The above methods, and update can now be chained, just like many of jQuery’s methods.
  • remove now also triggers namespaced events

One change that might be a bit controversial is the removal of the whole Stapes.util module, with lots of Underscore.js-like methods. These were initially added in 0.4, but i’ve come to the conclusion that they’re not needed. The focus of Stapes should be on simplicity and on ‘do one thing and do it well‘. The utility methods are widely available in other libraries (like Underscore), many of them are also available in ES5-compatible browsers (such as Array.prototype.map and Function.prototype.bind.

If you have old code that depends on Stapes.util you might find the compatibility plugin useful.

If this is the first time you’re trying out Stapes, why not build a todo app in less than 100 lines of code?.

Blog archives

A simple Greasemonkey / Userscript to remove all Google Plus UI

If you recently tried reading a Google Plus post without having an account you’ve probably seen something very similar to this:

Lots of UI that you don’t use. And most of it is ‘fixed’ to the screen, so when you’re reading the post most of your screen is filled with useless buttons like ‘Join Google Plus’.

I’ve written a really simple and basic Userscript to remove most of this UI.

If you’re using Chrome:

  1. Right click on this link and select ‘Save link as’, save it to the Desktop
  2. Open up the ‘Extensions’ window (Window –> Extension)
  3. Drag up the file into the window and select “Add” on the pop-up.
Refresh the Google Plus page you were viewing and voila, no more useless stuff:

 

Blog archives

A cached version of Crockford’s Object.create, up to ten times faster

Most Javascript programmers know Douglas Crockford’s famous prototypal inheritance utility, Object.create (written here as a global clone function):


    function clone(o) {
        function F(){}
        F.prototype = o;
        return new F();
    }

You can use this utility to do inheritance in Javascript ‘the right way’:


    function Parent(name) {
        this.name = name;
    }

    Parent.prototype = {
        "getName" : function() {
            return this.name;
        }
    }

    function Child() {
        Parent.apply(this, arguments);
    }

    Child.prototype = clone(Parent.prototype);

    var child = new Child("John");

    child.getName(); // 'John'
    child instanceof Child; // true
    child instanceof Parent; // true

The clone function can be made even faster by caching the F function:


    var F = function(){};

    function clone(o) {
        F.prototype = o;
        return new F();
    }

Because the complete prototype is overwritten you can use F over and over again. Speed differences can be pretty big, according to a jsperf.com testcase i made. In IE8 the cached version is up to ten times faster.

Blog archives

Getting the element index in a SASS @each loop

I wonder why this isn’t in the default SASS documentation. If you want to iterate over a list in SASS using @each, how do you get the index of the current item? For example, to make odd-even colored table rows?


    $list: foo, bar, baz;

    @each $item in $list {
        .#{$item} {
            // Right, so we want to see if the item index is
            // odd or even, but how do we get the index?
        }
    }

Turns out this is not possible with @each, but you can use a combination of a @for loop and the little-used nth function:


    $list: foo, bar, baz;

    @for $i from 1 through length($list) {
        $item: nth($list, $i);

        .#{$item} {
            @if $i % 2 == 0 {
                background: red;
            } @else {
                background: blue;
            }
        }
    }

Note that lists in SASS start at 1, not at zero.

Blog archives

Stapes 0.5.1 released

I’ve just released version 0.5.1 of Stapes.js, my tiny Javascript MVC framework. This is a minor bugfix release, mostly because of a bug that would break events in submodules. If you’re using 0.5, please upgrade to 0.5.1. No API changes are present in this release.

The only other change concerns the scoping of private utility methods in the Stapes object. These methods couldn’t be reached from outside the object, which makes it difficult to write plugins that alter the basic functionality of Stapes. I’ve moved all those methods to a single subobject in the Stapes object called Stapes._ (yes, just an underscore).

So if you would, for example, like to change the way Stapes creates submodules you could overwrite the Stapes._.createModule method. These methods aren’t documented, so you should take a look at the source.

As always, comments and patches are very welcome.