August 2009
5 posts
5 tags
Snow Leopard Web Development Configuration
After installing Snow Leopard on my iMac I found I had to tweak some settings before I could continue my daily web development workflow. First, you should note Snow Leopard now comes with PHP 5.3 and it will overwrite your custom Apache configuration. Here’s what I did to get up and running: Moved /etc/php.ini.default to /etc/php.ini. Edited php.ini (using search/replace) so that...
Aug 29th
4 tags
Internet Explorer, Javascript and base elements
Internet Explorer treats the base element a bit diffently from other browser. I ran into the issue when trying to change the current page’s hash through javascript: window.location.hash = 'some_value'; Internet explorer took the entire base URL and prepended it to the hash, resulting in an URL like http://domain.tld/http://domain.tld/#some_value. That’s clearly not my intention. ...
Aug 21st
3 tags
Removing deleted files from the Git index
When working with Git it can be cumbersome to have to remove files from the index (marking them deleted rahter missing) if you did not delete them using git-rm. Here’s bash one-liner for that: git rm $(git ls-files -d) I’ve got that aliased to grd (Git Remove Deleted).
Aug 17th
2 tags
Argument-specific memoization
There is another way of memoizing expensive operations in JavaScript, which is also fit for argument-specific results: base._fooCache = {}; base.foo = function(arg) { if(base._fooCache[arg] === undefined) { base. _fooCache[arg] = ...expensive operation... } return base. _fooCache[arg]; }; This just keeps a local key/value cache of the result of the expensive operation for...
Aug 13th
2 tags
Awesome JavaScript memoization
Here’s an easy way to memoize expensive Javascript functions. It introduces slightly obscure code and an extra function call, but if your operation is expensive enough to memoize, it is probably worth the extra overhead: this.foo = function(){ var foo = expensive_operation(); return (this.foo = function() { return foo; })(); }; What this function does is redefine itself, so on...
Aug 13th