Posts Tagged ‘ coding ’

Welcome SAM!!!

How many of you are bugged by Cyberoam at your workplace or college??

For those who don’t know, Cyberoam is a corporate firewall used by many organisations including our college… 😡 😡 😡 to block websites and restrict user’s internet accessibility. To continue (so called) uninterrupted access to internet user needs to login ever hour in Cyberoam client. In our college it also restricts the amount of data that user can access in 24 hrs to 100Mb. So if your usage exceeds than there are only three options for you:-

1. Wait for clock to Pass Midnight.
2. Plead your friends to give you their account details.
3. Make a fool of Cyberoam(Bypass it)….. 😛

Well for third option you need to be a genius…:D and for 2nd option you need cooperative friends… 😀

Enough of Cyberoam, lets talk about SAM(Syberoam Account Manager). SAM is simple GUI developed in Python with Qt bindings in collaboration with dhinchak (who gave birth to it… :D) for managing Cyberoam Accounts. In this you can add multiple accounts if you know your friend’s usernames and passwords and to reduce your annoyance we added certain features to it.

It re-logins into the current account after definite interval of time defined by user itself, it can also switch accounts if usage of one account reaches critical limit specified by user or it maxes-out. There are also notifications options which user can customize according to his liking. There are many more features in it which user can exploit if user wishes so as it’s OPEN SOURCE …. :D.

That’s my friend SAM( 😀 ). Do you like him?….NO…it’s your choice. It’s my creation and I love himm… :P.

After reading the post ,if you are slightly excited to check out SAM, it’s source is available at
SAM. For for information please have a look at README file in the source.

Though it’s still in development phase and since its tested only on our college’s server, it might not work fully or even partially outside our campus. Although we are working on it.

See you later….
Adios and Do comment… 🙂 .

Package Synchronizer [Arch]

This is a small script that I wrote yesterday in order to synchronize my packages that are stored in my cache directory (/var/cache/pacman/). It creates a directory defined by user where it stores all the latest version of the installed packages available in your cache directory.
This script first gets the list of all packages installed in your computer. Just running the “pacman -Q” command and then searches for .pkg file for each package installed, in your cache directory.
If found it then checks whether a newer version is already present in the user directory, if not then transfers the package to the user directory and if an older version is already present in the user directory then it transfers it back to the cache directory

#A simple Package Synchronizer
Author: Mohit Kothari <>
import os
import shutil

pkg_dir = "/var/cache/pacman/pkg"
lat_dir = "/var/cache/pacman/bck_pkg"

if not os.access(lat_dir,os.F_OK):
	os.system("sudo mkdir "+lat_dir)

os.system("pacman -Q > list")
list_fl = open("./list","r")
pkg_list = list_fl.readlines()
length = len(pkg_list)
ctr = int (1)
print"Completed [",
for l in pkg_list:
	perc = float(ctr)/float(length)*100
	print"\rCompleted["+"-"*int(perc/4) + "] "+str(int(perc))+"%",
	spli = l.split(" ")
#	print spli[0]
	com = "ls {1} | grep ^{0}-[1,2,3,4,5,6,7,8,9,0] > pkg".format(spli[0],pkg_dir)
	pkg_fl = open("./pkg","r")
	pkg_list = pkg_fl.readlines()
	if len(pkg_list) is not 0:
		size = len(pkg_list)
		pkg_name = pkg_list[size-1].split("\n")
#		print pkg_name[0]
		com = "ls {1} | grep ^{0}-[1,2,3,4,5,6,7,8,9,0] > pkg".format(spli[0],lat_dir)
		pkg_fl = open("./pkg","r")
		pkg = pkg_fl.readlines()
#		print pkg
		if len(pkg) is 0:
			com = "sudo mv {1}/{0} {2}/".format(pkg_name[0],pkg_dir,lat_dir)
#			print com
#			print "IN VEEVR"
			pack2 = pkg[0].split("\n")
			if pack2[0] < pkg_name[0]:
#				print "MOVING"
				com = "sudo mv {1}/{0} {2}/".format(pkg_name[0],pkg_dir,lat_dir)
				com = "sudo mv {1}/{0} {2}/".format(pack2[0],lat_dir,pkg_dir)
#				print com
	ctr = ctr+1

Just run the script as root as it makes changes in var directory which requires root privileges.
It will show the status of completion as follows

[zarthon@zarkost ~]$ sudo ./
Completed[-----------------------] 92%

By default the user directory is specified as “/var/cache/pacman/bck_pkg”
You can change it in the script.

ΖψϊΓΓє® Welcomes You!

After reading the Headline you might be wondering if this post contains any text regarding Hermaphrodites(Zwitter in German) or of Rammstein’s Song.

But NO!.

It is just a front-end GUI for twitter API created using python, Qt bindings for python and twitter module for python developed by DeWitt Clinton (My Sincere Thanks to him for creating such an awesome module).

The name happens to be just fusion of my Nick Zarthon and Twitter i.e Zwitter ..:P

When started settings dialog gets opened asking for your username and password.

After Entering the details it loads your data and then displays the main Window, now you can perform any function you like just by clicking the button. Titles of the buttons are self explanatory for their functions.

The major coding was done to support contextMenu(Menu that appears after we Right Click) in listWidget(Main Display Area)

Different contextMenu is displayed depending on what type of element is clicked and currently what type of list is being shown,

  • Elements are of two types, User and Status
  • List type can be of Public Timeline, Get Replies,  Latest Friends Status and Direct Message

Through them you Create friends, Destroy friendship, Reply, Retweet(I just retweets them, you cannot edit it), Get information about a particular user, Post New Direct Message, reply to one etc….

You can also reply to more than one person at a time, when you press Reply button, you will see following dialog

It shows you all your friends list, you can also see their Real Names just selecting Real Names from combo Box.

To add a user to reply list just Double Click its name, you can also filter out the list by entering initials in search label, it will show all the members that contain the string in Search Field.

There is one constraint, you can only edit one line as soon as you press enter the text is posted.

Similarly there is a dialog for Message.

Source code can be found at

Try IT!! And please Reply how you like it or have any questions and feel free to send bugs at


A simple Command line API for Twitter update

After having wasted almost half of my vacations, one night I though of developing a simple command line API for Twitter, though there are thousands of applications available for tweeting, I developed it to only get more knowledge of libcurl .

AUTHOR: Mohit Kothari
It's a simple Command Line API for updating your status

Enter Username: abc
Enter Password(Max 100):
Enter the message: add

It will return a blob of JSON information

using namespace std;

void input_user(string &user){
	cout<<"Enter Username: ";

void input_pass(string &pass){
	char ch[100];
	printw("Enter Password(Max 100): ");
	pass = ch;
int main(int argc, char* argv[]){
	string msg,user,pass,final="";
	string status = "";
	char *fina, *sta;


	cout<<"Enter the message: ";

	status += "status="+msg;
	final += "http://"+user+":"+pass+"";

	fina = new char[final.size()+1];
	sta=new char[status.size()+1];
	CURL *curl;
	CURLcode res;
	curl = curl_easy_init();


	return 0;

I have shared the Source in git-hub:

It just updates your status, it doesn’t have the function to get recent tweets, I am trying to implement it
and also is looking forward to build a GUI using Qt.
Lets hope it turns out good.