Javascript: Add URL parameter

Here’s a handy function for adding a new parameter to a URL: function addUrlParam(param, value) { var url = location.href; if ( != -1) return url; var hash = location.hash, sep = url.indexOf('?') == -1 ? '?' : '&'; return url.replace(hash,'') + sep + encodeURIComponent(param) + (value ? '=' + encodeURIComponent(value) : '') + hash; […]

SynoExt add-on for Firefox 4, 5 and 6

The SynoExt add-on for Firefox is great for people who have a Synology DiskStation: downloading torrents on the NAS straight from the browser. Too bad the extension isn’t being maintained, and is now incompatible with new Firefox versions (everything newer than 3.6 won’t work). Turns out that there is a very easy fix, simply editing […]

Slow/crashing IE9, blank screens

At work, I am running Windows 7 (64-bit) on a Dell Optiplex 780 PC. When Internet Explorer 9 was released, I installed the 64-bit version on this PC. Right from the start IE9 was unbearably slow, pages didn’t load, or only showed after you moved the mouse (it reminded me of a “peekaboo” bug). It […]

Javascript addClass/removeClass functions

While looking for compact Javascript addClass and removeClass functions, I stumbled upon This code allows for a few optimizations: The ‘match’ method is deprecated, ‘test’ should be used instead. The ‘addClass’ function references a non-existing ‘this’ object. The ‘removeClass’ function declares a new variable ‘reg’, which is unnecessary. The ‘removeClass’ function doesn’t handle multiple […]

PHP: Determine the Quarter for a timestamp

PHP’s date and strftime functions are great for retreiving date-related info formatting them. The only thing missing is a way to determine the quarter (Q1-Q4) for a timestamp. Here’s a very short function that will return the quarter for a timestamp: /** * Return the quarter for a timestamp. * @returns integer */ function quarter($ts) […]

PHP: Replace \u characters in json string

In PHP, if you JSON-encode a string that contains accented characters, the result contains unicode sequences (for example: \u00e9 represents the é character). <?php $string = 'åbcdéfg'; print json_encode($string) . "\n"; ?> Running this gives the following output: "\u005e5bcd\u00e9fg" If you want to replace the unicode sequences back to their character representation, here’s what you […]

Enable SSH&SCP on DiskStation

Enabling SSH on a DiskStation is easy. Download and install the Synology “Enable SSH” patch. Install it via the DiskStation manager (via System -> Firmware Update). Voila: you should now be able to SSH to your DiskStation. But SCP does not work yet. When you try to SCP to the DiskStation, you probably see either […]

Configuring DiskStation for multiple websites

The Synology DiskStation comes with the Apache webserver. The “Web Station” functionality allows you to host a website. You can even run multiple virtual hosts. These “default” virtual hosts, however, cannot be configured in detail. But it is very well possible to host multiple websites on a single DiskStation, while still being able to configure […]

Windows 7 and Parallels 5: Activation issues

I have an iMac 27 (Core i5, 4GB, Snow Leopard). Using Bootcamp, I also installed Windows 7 Professional (64 bit) on this machine. I want to run Windows virtualized (via Parallels 5) as well, using the installation on the Bootcamp partition. Setting this up is all very straightforward. First make sure Windows is installed properly […]