Python 2-to-3 Tips
This is a short post to help those of you who need help translating code from Python 2 to Python 3. Python 2 is the most popular Python version...
Read more
How can I determine the size of a directory or folder in Linux?
du -hs /path/to/directory -h: human-readable -s: summary (don't show size of each individual file within the...
Read more
Tutorial: How to use Linux Screen
A problem that often arises when you’re dealing with lots of data is that it takes forever to process. So you SSH into your Amazon EC2 machine,...
Read more
Install all your statistics and numerical computation libraries for Python in one go on Ubuntu
sudo apt-get install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy...
Read more
How to password-protect a PDF file on Ubuntu
In a terminal, type: sudo apt-get install pdftk Then, to add a password to a PDF file, type: pdftk <input-file> output...
Read more
Find and Replace Text from the Command Line in Linux
Use sed sed -i 's/<original_text>/<replacement_text>/' <file.txt> Example: sed -i 's/Bob/Alice/'...
Read more
Setting up your dev environment
These days most start-ups / engineering teams are using the same dev setup, even if they are using different technologies in their stack. This is...
Read more
Output to standard out AND a file at the same time
Let’s say you’re running a script, and you want the output to show up in the terminal and be output to a file simultaneously. This is how to do...
Read more
Automation: For loops in bash (for loops on the command line)
If you have to run a script that processes data for a particular file for a particular day, i.e. your file is on hadoop with the date in the path,...
Read more
Can’t restart Apache in Ubuntu
When I try to restart Apache using the command: sudo apachectl -k restart I get this error: apache2: Could not reliably determine the server’s...
Read more
Installing the Python-MySQL (MySQLdb) connector using the Yum package manager and easy_install
You’ll notice if you try to just do this: sudo easy_install MySQL-python You’ll get some errors. That’s because you’re probably missing...
Read more
Backing up and restoring databases and tables in MySQL
My extreme laziness combined with my terrible memory means that I have to look up the backup/restore commands for MySQL almost every time I do it....
Read more
How Ubuntu users can get the arrow keys to work in “vi”
Most of you, if you’re lazy like me, will tend to use a normal text editor, like TextMate or gEdit. You’ll find that after having to SSH in...
Read more