Posts Tagged ‘hack’

The little twitter client I use :)

Here’s a small python script to update and read tweets from different timelines. You can use it with head/tail commands to customize the output. Actually, I wrote this script just for personal use and now I would like to share it with you 🙂 Thanks to tweepy python module, make sure it’s installed before trying the script 🙂

#!/usr/bin/env python
# Copyright 2011 Ershad K <ershad92@[nospam]>
# Licensed under GPL Version 3

import sys
import tweepy

CONSUMER_KEY = ' Fill here'
CONSUMER_SECRET = ' File here too'
ACCESS_KEY = ' Type yours here'
ACCESS_SECRET = 'Type yours here too'

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_SECRET)
api = tweepy.API(auth)

if sys.argv[1] == 'u':

elif sys.argv[1] == 'p':
    public_tweets = api.public_timeline()
    for tweet in public_tweets:
        print tweet.user.screen_name,":",tweet.text
        print ""

elif sys.argv[1] == 'r':
    mention_tweets = api.mentions()
    for mtweet in mention_tweets:
        print mtweet.user.screen_name,":",mtweet.text
        print ""

elif sys.argv[1] == 'h':
    friends_tweets = api.home_timeline()
    for ftweet in friends_tweets:
        print ftweet.user.screen_name,":", ftweet.text
        print ""

Hope you like it 🙂


Python Script to fix VBR errors of mp3 files in a directory, recursively

February 19, 2011 8 comments

If the seek bar of your rhythmbox is not working with some mp3 files, it might be an issue with Variable Bit Rate of them. The tool, ‘vbrfix’ written by William Pye solves the issue, but the problem is that it doesn’t have an option to search for files recursively. Here is a small python script that gets the paths of multiple mp3 files recursively and give them as arguments to vbrfix tool. Make sure you install vbrfix (from the software repo) before running the script.

Please see comments for a better, 1 line substitute to do the same. Thanks to Rajeesh ettan and Syam ettan 🙂

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#       Copyright 2011 Ershad K <>     
#       Usage: python
#       This program is free software; you can redistribute it and/or modify
#       it under the terms of the GNU General Public License as published by
#       the Free Software Foundation; either version 2 of the License, or
#       (at your option) any later version.
#       This program is distributed in the hope that it will be useful,
#       but WITHOUT ANY WARRANTY; without even the implied warranty of
#       GNU General Public License for more details.
#       You should have received a copy of the GNU General Public License
#       along with this program; if not, write to the Free Software
#       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#       MA 02110-1301, USA.

import sys
import os

quote = '"'
folder = sys.argv[1]
find_command = "find " + folder
find_command += " > mp3files_list"

os.system("sed 1d mp3files_list > mp3files_list1");

f = open("mp3files_list1", 'r')
for line in f:
    line = line[:len(line)-1]
    command = "vbrfix -always "
    command += quote + line + quote
    command += " " + quote + line + quote
    print command

os.system("rm mp3files_list mp3files_list1")

Improvements to code and suggestions are always welcome, Happy Hacking 🙂

Irssi notification in terminal using ‘write command’

In Desktop Environments like KDE or GNOME, we have special libraries like knotify or libnotify to display notifications from various applications. Some applications like Konversation has its own notification systems. But what about command line tools like Irssi? Imagine you are chatting in tty1 using irssi and doing something in tty2.How will you know if someone has mentioned you nick in channel message? Well, here is a small solution for this.

Luke Macken has written a wonderful  perl script to display notifications using notify-send command in desktop environments. Thanks to open source, I tweaked the call to notify-send command to suit our tty-notification. All that you have to do is this :

Step 1 : Get the Script and write it to a file ‘’.

Step 2 : Replace

system(“notify-send -i gtk-dialog-info -t 5000 ‘$dest->{target}’ ‘$stripped'”);


system(“echo ‘$dest->{target}’ ‘$stripped’ | write <Your username>”);

Make sure you replace <Your username> with your system username.

Step 3 : Put it in ~/.irssi/scripts/ directory.

Step 4 : Execute the following commands in irssi:

/load perl
/script load notify

Done, you will get notification to the latest tty to which you are logged in!
Good luck 🙂

PS: The notification that you get is not eye-candy, please adjust for it now 🙂

Configure Gmail in Mutt easily!

It’s always wonderful to play with terminal. Last week, I tried to configure my Gmail account in mutt, a powerful console based mail client, using this tutorial. I had to create some configuration files for various related applications and executed some commands. Hence I thought it would be nice if there is any script/program to configure mutt easily by simply entering the Gmail ID and password. Here is such an application, written in C++, which will help you to configure mutt very easily. All that you need to do is install mutt and follow these steps :

1. Download this file
2. Exctract it to your home directory
3. Execute the following commands :

$cd muttgconf


Get its source from git://    Good luck 🙂

C++ Program to tweet

September 20, 2009 16 comments

It’s very interesting to play with C++ and if it is in GNU/Linux, lots of tools like ‘wget’, ‘grep’,etc. are there to help us in time. Here is a simple C++ snippet which tweets directly to your time line. Feel free to add more features and would be great if you could share it with me too 🙂

 *      shell-tweet.cpp
 *      Copyright 2009 Ershad K
 *      Licensed under GPL Version 3
 *      Please change USERNAME, PASSWORD and compile with g++
 *      To compile - g++ shell-tweet.cpp
 *      To execute - ./a.out

#include <iostream>
#include <string.h>
#include <stdlib.h>

using namespace std;

int main()
char name[] = “username”, password[] = “password”, status[500], cmd[500];

char sym[] = {char(34),”};

again: cout << “\n Status: “;
fgets (status,140,stdin);

cout << “\n Length = ” << strlen(status);

if (strlen(status) > 139)
cout << ” Exceeds 140 character limit, Type again \n”;
goto again;

strcpy(cmd,”wget -nv –keep-session-cookies –http-user=”);

strcat(cmd,” –http-password=”);
strcat(cmd,” –post-data=”);


cout << “\n Done”;
return 0;

Easy Clarity – Connect Easily!

September 5, 2009 2 comments

‘Disconnection’ is a routine process in dial up internet. Here is an C++ snippet which dials BSNL WLL Clarity without asking for password again and again. It automatically closes on disconnection with a beep sound.

 *      easyclarity.cpp
 *      Copyright 2009 Ershad K
 *      Licensed under GPL Version 3
 *      Please change USERNAME, PASSWORD and compile with g++
 *      To compile - g++ easyclarity.cpp
 *      To execute - ./a.out

#include <iostream>
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int main ()
	char username[] = "USERNAME";
	char password[] = "PASSWORD";
	puts("\n EasyClarity - Connect wisely!\n\n");
	ofstream myfile;
	system("sudo wvdialconf"); ("/etc/widial.conf");
        myfile << "[Dialer Defaults]\nInit1 = ATZ\nInit2 = ATQ0 V1 E1 S0=0 "
               << "&C1 &D2 +FCLASS=0\nInit3 = at+crm=1;+cmux=1;+cps=33;+cta=0"
               << "\nModem Type = Analog Modem\nISDN = 0\nPhone = #777\nModem"
               << " = /dev/ttyUSB0\nUsername = "<<username<<"\nPassword = "
               <<password<<"\nBaud = 460800\nStupid Mode = 1\nAuto DNS\nCheck"
                <<" Def Route";
	system("sudo wvdial");
	cout << "\a";
	return 0;

How to connect BSNL Clarity in ubuntu 9.04 ?

Though we have many tools to connect BSNL Clarity in Linux Systems, unfortunately they don’t work in ubuntu 9.04 and in other lastest OS’. Here, i will explain how to get connected with BSNL clarity in ubuntu 9.04.

First, you need to edit the grub and add a line to ubuntu’s kernel. Follow the steps to do that:

sudo gedit /boot/grub/menu.lst

Modify the ubuntu’s boot configuration to like this :

title        Ubuntu 9.04
uuid        b744ea84-c1b7-4519-9223-3bb99103d42f
kernel        /boot/vmlinuz-2.6.28-11-generic root=UUID=b744ea84-c1b7-4519-9223-3bb99103d42f ro quiet splash usbserial.vendor=0x15eb usbserial.product=0x0001
initrd        /boot/initrd.img-2.6.28-11-generic

I simply added  ‘usbserial.vendor=0x15eb usbserial.product=0x0001′ to the kernel.

Next step is to install wvdial. Since the ubuntu 9.04 CD edition doesn’t have wvdial by default, we need to install it manually. Follow the steps to install it :

1. Download this file

2. Extract it in your home directory

3. Give the following commands in terminal

cd wvidal

sudo dpkg -i *.deb

4. Restart the computer

It’s done ! Now you can browse like the older versions of ubuntu by executing Mr.Dipin Krishna’s executable (./bsnlclarity in terminal after copying it in your home directory) . You can get it here. Good Luck 🙂

Categories: Experiments Tags: , , , ,