LocalStorage gotchas in Internet Explorer and Safari

localStorage.setItem will throw an “Access denied” error in Internet Explorer InPrivate Browsing mode. Likewise, Safari will give you QUOTA_EXCEEDED_ERR: DOM Exception 22: An attempt was made to add something to storage that exceeded the quota. To avoid those errors, you will need to wrap your localStorage access in a try/catch block.

How to speed up apt-get on Digital Ocean

For some reason, downloading packages using apt-get install was unusually slow on DigitalOcean this week, barely exceeding 4kbps. Since DigitalOcean droplets are configured to download packages from mirrors.digitalocean.com, all I had to do was to revert them to the default Ubuntu sources using these two commands: sudo sed -i “s/mirrors.digitalocean/archive\.ubuntu/g” /etc/apt/sources.list sudo apt-get update Downloads […]

Deleting directories while preserving symlinks

At work, we needed to replace a pre-existing folder with a symlink. We wanted to symlink the user’s .git/hooks folder to ../build/git-hooks every time the script was run. We wanted to delete .git/hooks if it existed and replace it with a symlink, but we also wanted to avoid deleting ../build/git-hooks‘s contents by accident if the […]

Finding your own phone number in Android Lollipop

If you are a traveller like me, you might often forget your phone number. Here is how to find it: Open Settings Click “About phone” completely at the bottom Click “Status” Click “SIM status”. Your phone number is under “My phone number”

Fixing “/usr/bin/env: node: No such file or directory”

After a fresh install of npm and bower, you may run into the following error while running bower install: /usr/bin/env: node: No such file or directory The fix on Ubuntu is very simple: sudo ln -s /usr/bin/nodejs /usr/bin/node

How to fix slow file read/write in Node.js

This morning, I had trouble with one of my grunt tasks taking several minutes to finish instead of 3-4 seconds. After a bit of troubleshooting, I isolated the bottleneck to a bunch of seemingly harmless file reads. Guess who was the culprit? The company-supplied McAfee. Turning off on-access scan immediately fixed the issue and dropped […]

Fixing Tunnelblick disconnecting in OS X 10.10 Yosemite

If you have just upgraded to Yosemite, you might have run into issues with Tunnelblick. First, it will connect properly, then disconnect immediately after. To fix this, open the Tunnelblick connection settings, click “Advanced settings” and uncheck “Flush DNS cache after connecting or disconnecting”.

Fix garbled file names in SMB shares

If you have files in your SMB networked folders that look like this: TRZB4~J.mp4, there is a very easy fix to get the original file names. Open your smb.conf file (usually at /etc/samba/smb.conf) and add the following line under [global]: mangle case = no mangled names = no Once this is done, enter the following […]

Ping once and return true/false

The ping command will usually try pinging a device forever, returning the response time after each pingback. If you want to ping a device once and use the answer to perform an action, use the following snippet: ping -c 1 [your ip or hostname] > /dev/null This command will either return 1 on failure or […]

Knowing the difference between mtime, ctime and atime

If you are dealing with files, you might wonder what the difference is between mtime, ctime and atime. mtime, or modification time, is when the file was last modified. When you change the contents of a file, its mtime changes. ctime, or change time, is when the file’s property changes. It will always be changed […]