Archive for June, 2013

Online Security

June 29, 2013 Leave a comment

Read this: The Best Browser Extensions that Protect Your Privacy @lifehacker.

I installed the following extensions:

Categories: firefox, security Tags: ,

beep when ready

June 29, 2013 1 comment

Sometimes I launch a script and if it takes too much time to finish, I leave the machine alone. I do something else but I check back from time to time to see if it has finished. It would be nice if I could get an audio notification when the job is done.

Here it is:

$ ./; beep

There is a package called “beep” that should do it but it was mute on my system, so I came up with an own solution. First, you need a short audio file. Here is mine: alert.wav. Download it and put it in the directory $HOME/bin. Make sure $HOME/bin is in your PATH.

Then add the following lines to your ~/.bashrc file:

#uncomment the next 2 lines to add $HOME/bin to your PATH
#export PATH

alias beep="mplayer -ao alsa $HOME/bin/alert.wav &>/dev/null"

Open a new terminal and try this:

$ sleep 2; beep
Categories: bash Tags: , , ,

mplayer doesn’t quit

June 28, 2013 Leave a comment

When I play a song with mplayer (from the package mplayer2), the song is played but mplayer doesn’t quit, I don’t get the prompt back. This is annoying if I want to play sound effects from a script and tens of mplayer processes are hanging…

Add the “-ao alsa” switch as a temporary solution (tip from here):

mplayer -ao alsa audio.mp3
Categories: bash Tags: ,

Google’s URL shortener

June 25, 2013 Leave a comment

You want to shorten a long URL from the command line / from a script.

There are lots of URL shorteners. With the Google URL shortener you can do it like this:

curl -H 'Content-Type: application/json' -d '{"longUrl": ""}'

Sample output:

    "kind": "urlshortener#url",
    "id": "",
    "longUrl": ""

Let’s do it in Python using the requests module:

import requests
import json

url = ""
data = {"longUrl": ""}
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r =, data=json.dumps(data), headers=headers)
print r.text
print 'Short URL:', r.json()["id"]


Name generators

June 25, 2013 Leave a comment

I had a project idea that would have needed fake names. I postponed this project but I found some useful links that I would collect here for future references:

Categories: python Tags: ,

Locate by IP

You have an IP address and you want to get more info about it.

infoSNIPER does the job. However, I didn’t find an API to it.

MaxMind offers several services. They also have a free service called GeoLite, which is a bit less accurate and the databases are updated once a month. If you want to use it from Python, here is an API (pygeoip) to the databases (that you need to download and extract and they take about 44 MB disk space).

If you don’t want to download any databases then IPInfoDB can be a nice solution. They have an API, thus you can use this service in your applications. You’ll have to register for a free API key. There is a Python library to it called pyipinfodb.

Categories: python Tags: ,

10 Productivity tips for software developers