Thursday, October 15, 2009

Firefox crashing with Adobe PDF plugin

I had struggled for quite a while with the way Mozilla Firefox would crash each time I tried to open a PDF document - I always had to save the link independently and then open the doc. The default behavior of in-browser opening of the document was the problem, it seemed. So here is how you solve it.

From the Firefox menu, go to Tools->Options. There, on the Applications tab, you will find a long list of applications/document types and what is supposed to be used to open each of those. It would look like this:

In there, like I've shown here, find the Adobe Acrobat documents and instead of "Adobe Acrobat (in Firefox)", select "Adobe Acrobat Reader", i.e. the program itself. If that does not show up by default, select "Other", and browse to find Adobe Acrobat Reader.

There you go - no more crashes! :)

Sunday, September 13, 2009

Suspend/Hibernate from command line

On a *NIX system, there are two main message buses: a system-wide one and one for each user session. The "dbus-send" command can send messages to either of the buses with --system or --session options along with a variety of options. Long story short, if you want to suspend or hibernate your machine, you need to send messages to org.gnome.PowerManager, not sure how it is for KDE systems. This is what your respective GUI options do internally.

To suspend, say:

$ dbus-send --session --dest=org.gnome.PowerManager --type=method_call --print-reply --reply-timeout=2000 /org/gnome/PowerManager org.gnome.PowerManager.Suspend

To hibernate, say:

$ dbus-send --session --dest=org.gnome.PowerManager --type=method_call --print-reply --reply-timeout=2000 /org/gnome/PowerManager org.gnome.PowerManager.Hibernate

Thursday, September 10, 2009

Changing HTML class attributes using Javascript

If you try to change the HTML class of an object on the fly using javascript, you might find that it works on Firefox but doesn't work with Internet Explorer. In that case, you're probably doing this:
document.getElementById("myObject").class = "newclass";
However, after being ready to bang my head on the desk for two days and doing a binary search on 500+ subversion revisions to find the exact working/non-working combo for IE, I have discovered this. You ought to use
document.getElementById("myObject").className = "newclass";
Heh... the joys of life.

Thursday, August 13, 2009

The Rules of SYS::SYSLOG

From the Perl documentation of Syslog:

The First Rule of Sys::Syslog is: You do not call setlogsock .
The Second Rule of Sys::Syslog is: You do not call setlogsock .
The Third Rule of Sys::Syslog is: The program crashes, dies, calls closelog , the log is over.
The Fourth Rule of Sys::Syslog is: One facility, one priority.
The Fifth Rule of Sys::Syslog is: One log at a time.
The Sixth Rule of Sys::Syslog is: No syslog before openlog .
The Seventh Rule of Sys::Syslog is: Logs will go on as long as they have to.
The Eighth, and Final Rule of Sys::Syslog is: If this is your first use of Sys::Syslog, you must read the doc.

Sunday, August 9, 2009

Downloading flash videos

Here is a hack where you have to do very little actually, its mostly about the discovery. When using Firefox on GNU/Linux, the Adobe Flash plug-in automatically downloads flash videos you are viewing in Firefox to your /tmp directory.

e.g. when I view http://www.youtube.com/watch?v=xO0gSJGJ7Fs in Firefox, a randomly named file /tmp/Flashn3T33b shows up, which I can play using mplayer, copy, rename, do anything with. When I close the tab, this file is deleted, but the plug-in does forget to clean up on few occasions.

Saturday, July 25, 2009

Viewing man pages in Emacs

As the default Emacs shell is designed as a text buffer (with its advantages of close text-editor integration), it makes it a bit inconvenient to view man pages. A special way for doing that is by invoking man: "M-x man" and entering the command you need to look up. If you would rather view the listing in color, use the aptly named "M-x woman".

Saturday, July 11, 2009

10 programming languages worth checking out

A stimulating article and a good starting point for hackers interested in experimenting with new languages.

http://www.h3rald.com/articles/10-programming-languages