How to fix HP scanning errors in MacOS

If you made the mistake of buying an HP printer and encountered one of the following symptoms: Scanner does not work. Both HP Easy Scan and the OSX Printers and Scanners utilities fail. Printing might still work. In HP Easy Scan, you get a message that says Scanner reported an error: An error occurred while […]

How to clear Terminal output on Mac

If you want to delete all previous output in an OS X terminal window, just press Cmd + K. This will clear the output, but it won’t kill the currently running tasks. I often use this command to remove thousands of lines of logs, so that the new output is easier to search. If you […]

How to flatten a directory on Linux and MacOS

If you want to flatten a directory with lots of deeply nested files (for example ./2012/06/09/images/previews/200×200/image1.jpg becomes ./image1.jpg), you can run this simple command: find target/ -mindepth 2 -type f -exec mv -i ‘{}’ target/ ‘;’ All the files in target‘s subdirectories will be moved directly under target. If multiple files have the same name […]

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.

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 […]

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”.

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 […]

Solving AirPort Extreme FTP issues

Recently, I’ve been having tons of problems when using FTP at home. I have a Macbook Pro, an Airport Extreme and use Cyberduck to access my remote FTP servers. It appears that the latest firmware (7.6.x) for the Airport Extreme has issues with FTP connections. In my case, the router would randomly crash while using […]

How to create big test files in OS X and Linux

If you need to have large files to test your application, there is a command in OS X and Linux that allows you to create a file of an arbitrary size. We already know that you can create an empty file by using touch: touch myfile.ext You can also create files with a preset size […]

Can’t output OS X audio to AirPlay? Here’s the fix.

Once in a while, I won’t be able to output my Macbook’s audio to my Apple TV. The solution is rather simple: you need to kill coreaudiod. You can achieve this from Activity Monitor or enter the following command in Terminal: sudo kill `ps -ax | grep ‘coreaudiod’ | grep ‘sbin’ |awk ‘{print $1}’`