Tag Archives: linux

The Loser’s Script – How to wish facebook friends on their birthdays automagically in linux

Yes, It does what it tells it does. It may be one of the geekiest ways of wishing your friends on their birthdays. You won’t have to check every morning for people having birthdays, and go on writing on their walls. The script does it for you. And believe me, when you wish someone using a script for the first time, it feels terrible. You will start to see the fickleness, frailness of human relationships, freaks and fakes around us in a Web 2.0 world. But, if you dare to go forward and test it for yourself, scroll down to see the step-by-step instructions.

Step 1: Install cURL and Gnome-schedule

cURL is a command line tool for transferring data using various protocols. Gnome-schedule is a GUI for managing cron-jobs. Install them by running the famous command

sudo apt-get install curl gnome-schedule

Step 2: Setup a new application
Goto http://www.facebook.com/developers/ and setup a new application. Fill in all the required fields. Don’t forget to set ‘Application Type’ to ‘Desktop’. Remember the ‘Application ID’ and ‘Application secret’ given in the end of the process.

Step 3: Request an OAuth access token with the proper permissions
Facebook Graph API authorization documentation Has a detailed explanation about this. But if you are in a hurry,

  1. Enter the following URL in your browser, replacing YOUR_APPLICATION_ID with the application ID you got in the earlier step.
    https://graph.facebook.com/oauth/authorize?client_id=YOUR_APLICATION_ID&redirect_uri=http://www.facebook.com/connect/login_success.html&type=user_agent&display=popup&scope=offline_access,publish_stream,friends_birthday

  2. After a successful login and granting necessary permissions,  you will be given a verification code. Save it for later use.
  3. Enter the following URL in your browser, replacing YOUR_APPLICATION_ID with ‘Application ID’ and YOUR_API_SECRET with ‘Application secret’ you got earlier, and VERIFICATION_CODE with the code you got in the previous step.
    https://graph.facebook.com/oauth/access_token?client_id=YOUR_APLICATION_ID&redirect_uri=http://www.facebook.com/connect/login_success.html&client_secret=YOUR_API_SECRET&code=VERIFICATION_CODE
  4. Now you will be given the precious ‘Access Token’. Save it somewhere

WARNING: Facebook does not recommend following this procedure and storing Access Tokens or Application secrets in desktop applications, because if somebody gets hold of that code, you are dead. I mean your facebook profile security is severely compromised and can be used in any malicious way they desire.

Step 4: Writing the script
No. Actually you just have to copy the following script I wrote and save it in a file like ‘/home/yourName/birthdayscript.sh’ after  entering THE precious access token of yours in the proper place.

#!/bin/bash

NOW=$(date +"%m/%d")

#Enter your access token below within quotations
ACCESS_TOKEN="blah-blah-blah-your-precious-access-token"

#Get the names and UIDs of your unfortunate friends born on a day like today
curl "https://api.facebook.com/method/fql.query?access_token=$ACCESS_TOKEN&query=SELECT%20first_name,uid%20from%20user%20where%20uid%20in%20(SELECT%20uid2%20from%20friend%20where%20uid1=564121985)AND%20substr(birthday_date,0,5)%20==%20'$NOW'" > birthdaywishtemp.xml

names=`sed -n -e 's/.*<first_name>\(.*\)<\/first_name>.*/\1/p' birthdaywishtemp.xml`
ids=`sed -n -e 's/.*<uid>\(.*\)<\/uid>.*/\1/p' birthdaywishtemp.xml`

F_ARRAY=( `echo ${names}` )
U_ARRAY=( `echo ${ids}` )

#Wish each of them with the same old boring message
for (( i = 0 ; i < ${#U_ARRAY[@]} ; i++ ))
do
curl 'https://graph.facebook.com/${U_ARRAY[$i]}'
curl -F 'access_token='$ACCESS_TOKEN'' \
    -F 'message=Hey, Happy Birthday...'${F_ARRAY[$i]} \
    https://graph.facebook.com/${U_ARRAY[$i]}/feed >> birthdaywishbackup.log

#Let you know the progress
echo "Wished ${F_ARRAY[$i]}" >> birthdaywishbackup.log
done

echo "Completed on $(date)" >> birthdaywishbackup.log

Now you can browse to the location where you saved the script via terminal and execute the script with the command

./birthdayscript.sh

And you can see the progress in the file birthdaywishbackup.log

Step 5: Automating the script
Yes, it is of no use if you have to run this manually each and everyday to wish somebody. So you can schedule it to run and write automagically on walls of birthday boys/gals everyday. If you are the geekiest type you can do it using a cron-job and you won’t need this tutorial anyway. But if you are interested, you can find how to do that here.
For the ordinary geek, there’s this dumb-simple GUI based tool called gnome-schedule. Run the command

gnome-schedule

in a terminal and you will be able to come up with a scheduled cron-job like the following in few easy steps.

IMPORTANT: Make sure you set a time of the day that you will keep your computer switched on, because a cron-job is not god, and doesn’t know how turn on the computer it is running, by itself 😀

It’s done!!! Enjoy being a lazy, cold-hearted nerd, who has no sense of finer things in life.

UPDATE: With all the controversial comments about this post here and in Reddit, I found an article written by another one who has thought on the same lines which totally explains my idea behind this script and blog post. Read and post your comments

It Was Your Birthday? Social Media Didn’t Tell Me That! by Jason Douglas

Edit or shift subtitles easily with Gaupol

It’s the holiday you were waiting for after a few days hard work. You settle at the monitor, looking forward to a movie marathon… Few minutes in to the movie and you realize that it’s not going to work.The accent of the actors and foreign language phrases… you can’t get a thing! So you go for the subtitles..
After trying many subtitle sources all over the web, you find every dialogue is either few seconds late or early than the subtitles! Trying to synchronize the lips and the voices makes you feel dizzy… What a day its turning out to be…
Don’t panic. Here comes Gaupol – The free and open source subtitle editor. Built for GNOME using GTK, it supports a variety of subtitles including .txt, .sub, .srt and .ssa

To install use synaptic package manager or type the usual line in the terminal

sudo apt-get install gaupol

Then open your subtitle file in gaupol to edit as you wish. [Tools] >> [Shift Positions] will let you shift it by a desired time interval to synchronize it with the movie. Save the modified file and it’s done!

Sit back and enjoy the movie.

Linux/UNIX Terminal Commands – Quick Reference Wallpapers

Since I got my Vostro equipped with the new version of LinuxMint – Felicia, I had the opportunity of sharing the FOSS/Linux experience with most of my friends. And the requests for Mint, Ubuntu ISOs & hands-on tutorials kept on increasing…

Although these fancy UIs & Graphical fireworks take our concentration away from getting our hands dirty, its always better to keep an eye on how things work down there. The simple reason is because the terminal is the way to do things faster,better & safer. There are plenty of tutorials on the internet teaching us how to get things done using linux/unix OS, but its always handy to keep the manual or a cheatsheet by your side for a quick reference.
So I thought of sharing some interesting wallpapers & reference manuals I found some time back on the internet regarding Linux/UNIX commands.

Linux Commands Wallpaper I

Linux Commands Wallpaper II – For Beginners


Unix/Linux Command Reference List

THE ONE PAGE LINUX MANUAL

Important Note: Dear guys & gals please note that these interesting material were not created by me. All the credit should go to the original authors and owners. I hope they wont get angry with me or sue me for posting these stuff here.

Thanx Dhanaja for the idea…