Saturday, January 31, 2009

Access JavaScript function arguments as an Array

One rather cool feature of JavaScript is that you can access a method's arguments from a special variable conveniently named ...arguments. Quite annoyingly though, the arguments variable is not a real array. Sure, you can get the arguments length or iterate through it's members. But you cannot call other Array methods like .push(), .shift() etc..

Fear not, the following one-liner converts the arguments variable to a real Array:

var args = Array.prototype.splice.call(arguments, 0);

The Array .splice() method is injected into the special arguments object to extract it's members and return a new Array.

Thursday, January 15, 2009

How to disable ipv6 on Ubuntu

There are many reasons to disable ipv6 on Ubuntu (If you don't really need it). Among others:

  • Some users report a noticeable improvement in network performance.
  • It's a workaround for a serious Tomcat6 bug

After a short Google session I found many (slightly different) 'solutions'. Nothing worked though. Eventually, I came across a solution that did the trick:

$ vi /etc/modprobe.d/blacklist

append the following line:

blacklist ipv6

save the file and restart your machine!

You can verify that ipv6 is actually disabled using the following command:

$ ip a | grep inet6

If you see not output this little exercise was successful. Go make yourself a cup of coffee!

BTW, I tried this on Ubuntu 8.10

Sunday, January 4, 2009

The benchmark

If you constantly compare yourself to others, then all you’ll ever be is just as good as them, maybe a little better. You’ll also miss out on all the fantastic things you might actually be good at while you’re focused on being better than them at what they’re good at.

Zed Shaw, 2008