Archive

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

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

Idea
Here it is:

$ ./slow_operation.sh; beep

Implementation
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
#PATH=$PATH:$HOME/bin
#export PATH

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

Test
Open a new terminal and try this:

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

mplayer doesn’t quit

June 28, 2013 Leave a comment

Problem
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…

Solution
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

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

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

curl https://www.googleapis.com/urlshortener/v1/url -H 'Content-Type: application/json' -d '{"longUrl": "https://ubuntuincident.wordpress.com"}'

Sample output:

{
    "kind": "urlshortener#url",
    "id": "http://goo.gl/Zeigx",
    "longUrl": "https://ubuntuincident.wordpress.com/"
}

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

import requests
import json

url = "https://www.googleapis.com/urlshortener/v1/url"
data = {"longUrl": "https://ubuntuincident.wordpress.com"}
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
r = requests.post(url, data=json.dumps(data), headers=headers)
print r.text
print 'Short URL:', r.json()["id"]

Links

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

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

Solution
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

How to Stop Procrastinating by Using The “2-Minute Rule”

How to Stop Procrastinating by Using The “2-Minute Rule”

Recently, I’ve been following a simple rule that is helping me crush procrastination and making it easier for me to stick to good habits at the same time.

Categories: Uncategorized Tags:

10 Minute Mail: a great TrashMail.net alternative

Usually I use the TrashMail.net service but 10 Minute Mail is even simpler.

Thanks Jeszy for the tip.

Alternatives

Digitally Imported station URLs

June 6, 2013 6 comments

Problem
You want to listen to Digitally Imported radio channels from command line for instance. For this you need the URL of the stations but it’s somewhat hidden on the web interface.

Solution
There is a public list of stations at http://pub7.di.fm/. You can write pub1, pub2, …, pub7 in this address.

I wrote a quick and dirty script that extracts station URLs (see the script here).

The output of the script is here (download the list here):

(01) http://pub7.di.fm/di_ambient                  Ambient - a blend of ambient, downtempo, and chillout
(02) http://pub7.di.fm/di_bigroomhouse             Big Room House - The most uplifting, floor-filling Big Room House!
(03) http://pub7.di.fm/di_breaks                   Breaks - a fine assortment of trance and house breaks
(04) http://pub7.di.fm/di_chillhop                 ChillHop - Trip Hop infused, downtempo nujazz and chillout beats.
(05) http://pub7.di.fm/di_chillout                 Chillout - ambient psy chillout, check out our trippy flavors!
(06) http://pub7.di.fm/di_chilloutdreams           Chillout Dreams - relax to the sounds of dream and ibiza style chillout
(07) http://pub7.di.fm/di_chiptunes                Chiptunes - Playing the best chiptunes and video game music.
(08) http://pub7.di.fm/di_classiceurodance         Classic EuroDance - Finest imported cheese on the net!
(09) http://pub7.di.fm/di_classiceurodisco         Classic EuroDisco - Relive the sounds of Euro & Italo Disco.
(10) http://pub7.di.fm/di_classictrance            Classic Trance - relive the classic trance hits!!
(11) http://pub7.di.fm/di_classicvocaltrance       Classic Vocal Trance - Classic fusion of trance, dance, and chilling vocals together!
(12) http://pub7.di.fm/di_clubdubstep              Club Dubstep - Enjoy the liquid sounds of Dubstep
(13) http://pub7.di.fm/di_clubsounds               Club Sounds - the hottest club and dance tunes 24/7
(14) http://pub7.di.fm/di_cosmicdowntempo          Cosmic Downtempo - A downtempo journey into the cosmos
(15) http://pub7.di.fm/di_darkdnb                  Dark DnB - A twisted blend of heavy hitting Dark Drum and Bass!
(16) http://pub7.di.fm/di_deephouse                Deep House - Only the sexiest, silky smooth and groovy Deep House.
(17) http://pub7.di.fm/di_deepnudisco              Deep Nu-Disco - The new sounds of Deep Disco!
(18) http://pub7.di.fm/di_deeptech                 Deep Tech - Deeper shades of House and Techno with Dub and Blues influences.
(19) http://pub7.di.fm/di_discohouse               Disco House  - Grooviest Disco House hits on the planet!
(20) http://pub7.di.fm/di_djmixes                  DJ MIXES - non-stop DJ sets featuring various forms of techno & trance!
(21) http://pub7.di.fm/di_downtempolounge          Downtempo Lounge - Relax with some Downtempo grooves.
(22) http://pub7.di.fm/di_drumandbass              Drum and Bass - tasty assortment to satisfy your drum and bass fix!
(23) http://pub7.di.fm/di_dubstep                  Dubstep - Dubstep hits and mixes!!!!
(24) http://pub7.di.fm/di_eclectronica             EcLectronica - An eclectic mixture of modern electronica.
(25) http://pub7.di.fm/di_electrohouse             Electro House - an eclectic mix of electro and dirty house
(26) http://pub7.di.fm/di_epictrance               Epic Trance - Epic & uplifting trance hits
(27) http://pub7.di.fm/di_eurodance                EuroDance - the newest and best of Eurodance hits
(28) http://pub7.di.fm/di_funkyhouse               Funky House - A fine selection of funky house music!!
(29) http://pub7.di.fm/di_futuresynthpop           Future Synthpop - Finest selection of futurepop and synthpop!!
(30) http://pub7.di.fm/di_glitchhop                Glitch Hop - Bit-crushing, dub-infused Hip Hop sounds!
(31) http://pub7.di.fm/di_goapsy                   Goa & Psychedelic Trance - a voyage out of this world!
(32) http://pub7.di.fm/di_handsup                  Hands Up  - Dance to the best Hands Up hits!!
(33) http://pub7.di.fm/di_hardcore                 Hardcore - DJ mixes, hard dance and NuNRG!
(34) http://pub7.di.fm/di_harddance                Hard Dance - are you ready for this!
(35) http://pub7.di.fm/di_hardstyle                Hardstyle - Banging Hardstyle for your ears!!!
(36) http://pub7.di.fm/di_house                    House - silky sexy deep house music direct from New York city!
(37) http://pub7.di.fm/di_latinhouse               Latin House - Finest selection of Latin house!!
(38) http://pub7.di.fm/di_liquiddnb                Liquid DnB  - Flowing with the freshest Liquid DnB!!
(39) http://pub7.di.fm/di_liquiddubstep            Liquid Dubstep - Mellow out to the rolling, soothing deep bass of Liquid Dubstep.
(40) http://pub7.di.fm/di_lounge                   Lounge - sit back and enjoy the lounge grooves!
(41) http://pub7.di.fm/di_mainstage                Mainstage - The biggest DJs from the best festivals around the world!
(42) http://pub7.di.fm/di_minimal                  Minimal - Finest selection of Minimal Techno & House!!
(43) http://pub7.di.fm/di_oldschoolacid            Oldschool Acid - Oldschool sounds of Acid Techno, House, and Trance!
(44) http://pub7.di.fm/di_oldschoolelectronica     Classic Electronica - old school techno, trance & rave!
(45) http://pub7.di.fm/di_progressive              Progressive - house, techno, and trance beats for your mind!
(46) http://pub7.di.fm/di_progressivepsy           Progressive Psy - progressive psychedelic grooves
(47) http://pub7.di.fm/di_psychill                 PsyChill - downtempo psychedelic dub grooves, goa ambient, and world beats.
(48) http://pub7.di.fm/di_russianclubhits          Russian Club Hits - Russia's hottest club hits.
(49) http://pub7.di.fm/di_sankeys                  Sankeys Radio - The sound of the white isle direct from Sankeys Ibiza.
(50) http://pub7.di.fm/di_soulfulhouse             Soulful House - house music selected from Paris with love!
(51) http://pub7.di.fm/di_spacemusic               Space Dreams - ambient space music for expanding minds
(52) http://pub7.di.fm/di_techhouse                Tech House - A fusion of techno and house with a deep, soulful vibe.
(53) http://pub7.di.fm/di_techno                   Techno - From Minimal to Detroit to Schranz & all in between!
(54) http://pub7.di.fm/di_trance                   Trance Channel - we can't define it!
(55) http://pub7.di.fm/di_trap                     Trap - Electronic 808 beats with Hip Hop roots.
(56) http://pub7.di.fm/di_tribalhouse              Tribal House - Finest selection of tribal and tech house!!
(57) http://pub7.di.fm/di_ukgarage                 UK Garage - The latest and greatest in UK Garage!!
(58) http://pub7.di.fm/di_umfradio                 UMF Radio - UMF Radio
(59) http://pub7.di.fm/di_vocalchillout            Vocal Chillout - Enjoy the relaxing vocal sounds of ibiza chillout
(60) http://pub7.di.fm/di_vocaltrance              Vocal Trance - a fusion of trance, dance, and chilling vocals together!

Play a station with mplayer for instance: “mplayer http://pub7.di.fm/di_ambient“.

Update (20140703)
Another way is to extract all links and then filter the result:

$ ./get_links.py http://pub7.di.fm | grep -v "\.xsl$" | grep -v "http://http://" | grep "fm/" | sort -u

The get_links.py script is here.

Follow

Get every new post delivered to your Inbox.

Join 70 other followers