Archive

Archive for the ‘Programming’ Category

My first XChat plugin :)

March 28th, 2008 2 comments

Recently I started using IRC a lot. As I was doing some django, PyQT and KDE/C++ development. Yes, its lot of development. And then whenever I want to ask some question on IRC, I have to use pastebin/dpaste. ( dpaste is developed upon django framework. :) ). Now, to dpaste any code, I have to switch to Firefox, I have to use mouse as well. I have to copy paste the link to xchat. This was tedious task for me. So, I started making a plugin for xchat so that I could easily paste my code. Fortunately XChat has python plugin interface.

This plugin runs with the command:

/dpaste language

If you keep <language> empty, it will assume it to be “Plain”. You can use any language supported by dpaste.com. The command will open a gtk window, in which you can paste your code. And then “dpaste” button will copy paste the link (containing your code) on your xchat input box. :) . As of now I am sure, it works fine in IITK proxy system. I am pretty much sure it will work fine if you are behind no proxy.

Before using the proxy, you will need to change few parameters in the script, namely “proxy_username”, “proxy_password”, “proxy_server”, “proxy_port”. If you are not behind proxy, just keep “proxy_server” empty.

Also, you should install python module “ClientForm”, “pygtk”, and “urllib2″.

aptitude install python-clientform python python-gtk2

To load the script, a simple way is /load <path to plugin file> . Or you can copy the script in ~/.xchat2 folder. That way the script will be loaded whenever you open xchat.

You can download the code from here. As of now I haven’t made docs, but its an easy plugin, and some commenting as well. :)

Updates : Download the plugin version 0.6, and you don’t need to change anything in it. The plugin uses xchat proxy settings by itself. :)   As of now, http proxy and no proxy is supported.
http://rohitj.net/myscripts/xchat_plugin_dpaste

Categories: dpaste, FOSS, Fun, GTK, Python, xchat Tags:

How to run feedparser behind proxy

March 13th, 2008 No comments

So, I had to change the feedparser code to run it behind proxy. Basically the idea is that python by default doesn’t user environment variables http proxy. You have to specify it in the python code.

In feedparser code, url is accessed at the line # 1895. Now, opener has to have http settings so that it could access the url. For that, I added 2 lines before calling opener:

proxy_support = urllib2.ProxyHandler({"http" : "http://<username>:<passwd>@<proxyserver>:<proxyport>"});
opener = urllib2.build_opener(proxy_support)

Here is the final feedparser : FeedParser With Proxy Support

Categories: FeedParser, Proxy, Python Tags:

Must Attend in FOSSKriti

February 9th, 2008 No comments

For last few days, I have been talking to people (mainly IITK students) about different events we have in FOSSKriti. I found people pretty enthusiastic about different events. I am pointing out those events here:

0: RoR : Y4 batch, being highly affected by Prof. TVP’s, is highly interested in attending RoR workshop. Some people want to learn RoR, some people want to discuss RoR. And I assume that some people will come because they know Saurabh Nanda. :)

1: Linux Kernel : Those who eff around there linux distro, especially Gentoo users, and those who have slightest interest in systems, were found interested in this.

2: Lisp : I personally am going to attend this event as a participant, not as organizing team. :P . And I am sure I will bring 10 more people. Actually no, some people were found interested in this workshop, specially those who are doing compilers course, or those who have done compilers course.

3: Linux Chix : :) :) :) :)

(female.isIITian())&&(female.isGeek())&&(female.hasTalkedTorohitj()) = 0

So, I am not sure how many females will turn up, but I am sure people will be there. This is the second event I want to attend. I want to see what they are upto.

4: KDE4 : Those who do not know, recently there was a big shift in IITK linux community. People broke their long loyalty for Gnome, and shifted to KDE. Alas!! KDE4 is still not in official repos, but they are still on KDE. They think its worth waiting for KDE4. Of course, this talk will attract these people.

Left are beagle hackfest and Clutter talk. Beagle is a must-attend hackfest. (afterall it substitutes stupid google desktop :) ). And clutter? I have no idea about it. :)

I will let you feel jealous!!!

January 26th, 2008 3 comments

Linux Stickers on Laptop

Categories: Debian, Firefox, Linux, Python Tags:

C++ vs C

September 22nd, 2007 No comments

Remember I once said that C is better than C++, so, I know I am completely biased. But I simply like C. I am a fan of its simplicity. And of course C has to be faster than C++ (which was never distinguishable in the type of programming I have done till now  :P ). So, today I got another material to support the point that C is better than C++. Checkout here. I will keep calling Linux Linux, not GNU/Linux :D .

Categories: C, Programming Tags:

Latex on wordpress

September 8th, 2007 20 comments

So, you are a geek. You want to write lot of technical things on your wordpress blog. And since you are a geek you want to write technical things in Latex. How do you do? One way is that you write latex code, make pdf, take screenshot, pick the desirable part, and use that image on blog. Ofcourse thats inconvenient and surely doesn’t go with your nerd personality. You want to write Latex code in your blog post. Here are 2 solutions. One is that you use wp-latex plugin. Using this plugin you will be able to write proper Latex code in your blog using <latex></latex> tags. But the problem is that this plugin uses Latex, which is not usually supported by web hosts, including Bluehost. And installing tetex locally is painful. So, here comes the second solution. Use mimetex. Checkout http://www.forkosh.dreamhost.com/mimetex.cgi?l_2 . Similarly you can get other latex output by replacing l_2. One guy used this property and made a plugin. Using this plugin you can use latex code, basically mimetex (which is a bit different from Latex) with <tex></tex> tags. I couldn’t get it working. Another guy changed this script and made it working with \[tex\]\[\/tex\] tags. It didn’t work as well. This new plugin downloads this image and stores in wp-content/cache folder. But it downloads this image every time someone opens the post. Of course it consumes lot of server and bandwidth. So, I made a small tweak in it. I replaced it’s 15 lines with 1 line. :) Basically, now instead of downloading the image, it puts src as http://www.forkosh.dreamhost.com/mimetex.cgi? blah blah. And see I am able to use latex code.

 f(x) = x^2 + l_2

Enjoy

Update : You can download the plugin (after my modification) from Plugin for using Latex

Update2 : The plugin is under GPL.

Update3 : So, the code I changed was suggested by Nitin Munjal. You can find him here

Categories: Bluehost, latex, Wordpress Tags:

is C++ better than C?

August 7th, 2007 1 comment

I never liked C++. It is complex and has nothing special as compared to C. I anyways don’t like OO languages. They are slow and complex. Though I always heard people saying that C++ is better than C. Rather my friends ( those who do not use Java) use C++. I always try to use C. At least when the choice is between C and C++, I prefer C. Sometimes, when I am doing projects with other guys, they will prefer C++ and I will say lets use C and for this favor I end up doing more coding, but its better than touching C++. C is simple and fast. No stupid complexity.

It’s time to sleep, otherwise I would had written more. But I think this page says it all. ( my apologies, the link is aspx page ) http://geekswithblogs.net/chrishan/articles/72646.aspx

Categories: C, Programming, Reviews Tags: