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

Wednesday, June 24, 2009

PHP SQLite 3 exec not working

I've spent at least a week wondering why my db->query statements work on my PHP files whereas the db->exec randomly seems to work or ceases working. This is mostly with the PDO opening of SQLite 3 onwards, where it behaves almost read-only.

Turns out, not only do you need to allow write access to the database file itself, but also to the folder containing it. Some google searches also seem to suggest that the full path needs to be given. But trust me - simply enabling write on the directory worked. This seems like a potential security issue, though :(

P.S. - For my facebook friends being forced to read this note - sorry, I'm still trying to figure out how to decouple the RSS I had once linked. :(

Thursday, June 4, 2009

Migrate or roll back an entire svn repository

If you have suddenly been stuck doing a stupid commit to svn and don't know how to just get back, here is a quick hack which I found at http://stackoverflow.com/questions/402159/roll-back-or-revert-entire-svn-repository-to-an-older-revision.


svnadmin create --fs-type fsfs /svnroot/<repo>.fixed
svnadmin dump -r 1:24 /svnroot/<repo> --incremental > dump.svn 
svnadmin load /svnroot/<repo>.fixed < dump.svn
 
The next step, as you might have guessed, is to move the repo.fixed to . This way, you can also copy a repository as it is to someplace else by just doing the load into some other server somewhere.