The Lumber Room

"Consign them to dust and damp by way of preserving them"

Archive for December 2006

X Error: BadDevice, invalid or uninitialized input device

leave a comment »

For errors like this:

X Error: BadDevice, invalid or uninitialized input device 168
  Major opcode:  145
  Minor opcode:  3
  Resource id:  0x0
Failed to open device

(First, note that these are usually harmless. If you’re debugging something that has just gone wrong, almost always the problem is with something else, not these errors.) To make these messages/errors go away, edit /etc/X11/xorg.conf (don’t forget to backup, or else you may have no GUI when you reboot!), find the lines corresponding to the InputDevices you don’t have (Stylus, Cursor, Eraser), and get rid of them by commenting out everything from Section "InputDevice" to EndSection for each of them. Also, in Section "ServerLayout", comment out the corresponding lines. Changes will take effect the next time X is started (so reboot, or logout and hit Ctrl-Alt-Backspace).
Got it from the top Google search; it’s here. If you can imagine even more “step-by-step” instructions than what I wrote above, they’re here.

Written by S

Sun, 2006-12-31 at 23:57:39 +05:30

Posted in compknow

k3b verification “Could not find file”

leave a comment »

Enable “Allow lowercase characters in ISO9660 file names”. Reported at https://launchpad.net/distros/ubuntu/+source/k3b/+bug/59089 and http://bugs.kde.org/show_bug.cgi?id=119544

Update: Probably fixed by now.

Other annoying k3b bugs:

  • When it ejects and reloads the CD for verification, KDE pops up a “What do you want to do?” thing that comes when CDs are inserted.
  • When it ejects and cannot reload the CD (it happens often with old drives) it aborts, instead of asking the user to put the CD in.

Written by S

Sun, 2006-12-31 at 19:18:04 +05:30

Posted in compknow

Tagged with , ,

Editing TEXTAREAs in an external editor

with 2 comments

For many people today, much more text editing happens in TEXTAREA forms than elsewhere, as observed here. But textareas have many problems — they don’t have all of the features your favourite editor has; it’s easy to lose text permanently (browser crash, or some confusion with undo operations, etc.); can’t save what you type for safekeeping, ….
The solution, of course, is to use your own external editor for entering text into textareas. Typing it somewhere and pasting it into the textarea is clumsy (and what happens when you decide to edit some more?). Fortunately, there are solutions which (promise to) work seamlessly:

  1. The ViewSourceWith firefox extension. This is what I use was using, and it works well. Despite its name (and all the things it can do), I suspect that this extension is primarily used for editing textareas :-)
  2. The It’s all text firefox extension. Haven’t used this myself.
  3. The MozEx firefox extension. Actually, this works only with Firefox 0.7–0.9; try the one at its homepage. I had tried this a while ago, and I vaguely remember there were some problems. It may have been fixed now, though.
  4. The Editus Externus firefox extension. Never heard of it before today. Doesn’t work on Firefox 2.
  5. The EmbeddedEditor extension. Experimental, works with Linux only.
  6. There’s also the Xinha here firefox extension, which starts a particular editor (“Xinha”) each time, but I think it’s pointless to learn one more entirely new editor, with probably its own set of limitations.

To use Emacs with any of these, simply set the external editor to use Emacs as a server, i.e. EmacsClient. (You could also set it to use emacs instead of emacsclient, but that would start a new instance of Emacs each time.)

There’s also an amazingly clumsy clever hack, which might work far better than anything else if you’re on X: a script called external-edit. (The Windows version external.exe is here.) This promises much, much more: being able to call an external editor from anywhere, not just Firefox. It works by getting the ID of the window with focus, simulating keypresses that correspond to those for Select All and Copy (so that the contents of the textarea get pasted into clipboard), creating a file with the contents of the clipboard, invoking your editor on the file and waiting for it to exit, moving file’s contents to clipboard, and generating the keystroke for Paste. Clever. Hack.
I haven’t tried the Windows version of course, but the Linux version is buggy (at least, I couldn’t get it to work directly). After much effort and a long time (that’s because I’m an idiot, not because there was much to change), I think I’ve fixed it. I’ve tested it on {GNOME,KDE}×{Firefox,Konqueror,Opera}×{emacs,emacsclient,gvim -f,gedit,kate}. You can get it here.
Simply set up a keystroke to invoke (say) “external-edit emacsclient”, and no matter where you’re typing something, if you suddenly decide you want to do it in Emacs, just hit the key. Nothing could be better :-)

Written by S

Fri, 2006-12-29 at 02:09:10 +05:30

Posted in compknow

ssh through a proxy (Squid, etc)

with one comment

If you are somewhere where the only way of connecting to the outside world is through a proxy, then to get ssh to work, here’s what to do:

Get connect.c.

Compile it (gcc connect.c -o connect), and put connect somewhere in your path. That page says /usr/local/bin, but you probably don’t have permissions to that, anyway. You can do mkdir -p ~/bin && mv connect ~/bin and add a line export PATH=$PATH:~/bin to ~/.bashrc or ~/.bash_profile (or both), and restart the terminal, or start a new one.

Edit the file ~/.ssh/config (create it if it doesn’t exist) and add the two lines

Host *
  ProxyCommand connect -H proxyusername@proxyname:3128 %h %p

Replace proxyusername by the username for the proxy, and proxyname by the location of the proxy, and 3128 by the port number (it’s usually 3128 for Squid).

If it is a low-security thing and the password is already well-known (guest account?), then might as well put the password in the above .bash… files, to save the hassle of typing it each time:
export HTTP_PROXY_PASSWORD=proxypassword

Then ssh should work as usual: ssh username@hostname , etc.

Written by S

Tue, 2006-12-19 at 13:40:58 +05:30

Posted in compknow

Simplexity of songs

leave a comment »

Knuth’s paper The Complexity of Songs
Paper by Broder and Stolfi, Pessimal Algorithms and Simplexity Analysis.

More generally, there is a paper A Stress Analysis of a Strapless Evening Gown which led to an apparently good book of the same name.

Apart from The Worm-Runner’s Digest which was the source of the above, there was Manifold (and a book), source of excellent stuff such as this, there is the Journal of Irreproducible Results, its rival Annals of Improbable Research (which awards the Ig Nobel Prizes), and (found through Wikipedia) Null Hypothesis. Sigh, there is competition in every market.

Written by S

Mon, 2006-12-04 at 07:47:08 +05:30

Posted in funny

Tagged with

Editing subtitles on Linux

leave a comment »

Note: This was written in 2006, so it’s probably out-dated by now.

First, the not-so-good ones:

There is Ksubtile (note: it’s not Ksubtitle!) which is a KDE app. It handles only SRTs (but I think it can import from other formats), and doesn’t even seem to have a way to change the framerate. Pretty useless, but if you want it, the package’s name is ksubtile.
Then there is gsubedit, but it hasn’t released a stable version since June 2002, so I’m guessing it’s dead (or it’s perfect ;-)).

Then the good ones:

But what is alive and good is subtitleeditor. debuntu.org has written a couple of articles and has it in its repository. Subtitleeditor seems to have almost everything one could possibly ask for (including spell-check and Find/Replace!). Update: subtitleeditor is available in universe on edgy; no need for an “outside” repository.

I also discovered gaupol, which seems to be much better. Because I hadn’t used subtitleditor much, I didn’t realise how many badly needed features are missing in it (especially Undo). The edgy repos have gaupol too (but it’s slightly broken).

Also recently added is libsubtitles-perl (install with perl -MCPAN -e 'install Subtitles'), which comes with a commandline tool called subs… it’s already my favourite :-)

Other things to do:

If you want to make your own subtitles, the tutorials Subtiteling with Linux and Linux Digital Fansubbing Guide might help.

For rudimentary tasks, it may not even be necessary to install anything: there is an Online Subtitle Synchronizer / FPS & Format Converter.

BTW, there’s one thing I’d very much like to know: Is there any hope at all for removing hard subtitles? Maybe some kind of clever pattern recognition and then filling the region with the local background colour? Something? :-(
(Update: I must try Subrip, AVISubDetector and Subtitle Workshop sometime… I think they promise to extract the subtitles from the video stream, but I don’t know if this means they can remove them…) In the meantime, mplayer has a “delogo” filter, intended for detecting fixed logos and removing them. It works, somewhat — it replaces the subtitles and interpolates from the surroundings, but leaves a rectangle which is somewhat blurred. For one particular video, I used
-vf delogo=120:250:400:70:-1,expand=:::::4/3
, or -vf expand=:::::4/3,delogo=120:320:400:70:-1. The parameters are x:y:w:h:t, where (x,y) are the coordinates of the top left of the rectangle (with origin at top left of the screen), and w and h its width and height. Remove the -1 after you have the right rectangle; it’s for a green border.

Some general info on subtitles (I use mplayer):

Sync

If the subtitle and audio are out of sync, first try using the `z` and `x` keys till you get them in sync. `z` rewinds (delays) the subtitles (makes them come later wrt the audio) (recalls subtitles that already went by), and `x` prepones the subtitles (makes the subtitles come earlier, gets subtitles from future). (Perversely, for reasons I don’t yet know, mplayer calls the former a negative “sub delay” and the latter a positive sub delay.)
If after some time they start falling out of sync again (one quick way to check is to seek forward or backward a few minutes and check if they are still in sync), then the problem is probably that the video and subtitles have different framerates (fps). To fix this, you must run mplayer with -subfps [correct_fps]. You might be able to find the correct fps at the place you downloaded the subtitle from ;-); else simply try the three values 23.976, 25, and 29.97; which work in most cases. (If *that* doesn’t work, try all three values for the video as well (-fps [value]). One of the nine pairs should hopefully work!)

Placement

`r` raises the subtitle, and `t` lowers it. (Or you could also start mplayer with -subpos [value])
I used to wonder whether it was possible to have the subtitles not covering the actual movie (there was usually some blank area below and above the actual movie content…), and I just discovered that it is! Basically, you have to expand the video so that some blank space is part of it, and then `r` and `t` will go into that blank space. Using -vf expand=0:-50:0:0 adds a 50-pixel blank space at the bottom of the video. (Leaving out the 0:0 and using only -vf expand=0:-50 adds the 50 pixels but centres the video, so that there are 25-pixel bars at the top and bottom.) Another way to get blank space would be to use -vf expand=:::::4/3 which means “Expand the video so that the aspect ratio is 4/3″. In fact, it may be a good idea to add either vf=expand=0:-50:0:0 or vf=expand=:::::4/3 to ~/.mplayer/config. (Update: Screen ratio is 16/10 on the MacBook.)

Written by S

Fri, 2006-12-01 at 16:11:37 +05:30

Follow

Get every new post delivered to your Inbox.

Join 70 other followers