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

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

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

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

How to install Festival text-to-speech on Ubuntu

There is a very limited set of quality text-to-speech software for Linux. One of the commonly recommended solutions is Festival. As is common with open source software, you will need to Google your way through a bunch of old mailing list archives before you find the correct instructions to install it on your system. Since […]