The Lumber Room

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

Archive for the ‘compknow’ Category

Using Gmail with mutt, the minimal way (IMAP update)

with 63 comments

As Gmail has IMAP access, it is fairly trivial to get it working with mutt. First, if you’re on Ubuntu/Debian, run sudo apt-get install openssl mutt to get mutt if you don’t already have it. Then, just put the following lines into your ~/.muttrc:

set imap_user = ""
set imap_pass = "password"

set smtp_url = "smtp://"
set smtp_pass = "password"
set from = ""
set realname = "Your Real Name"

set folder = "imaps://"
set spoolfile = "+INBOX"
set postponed="+[Gmail]/Drafts"

set header_cache=~/.mutt/cache/headers
set message_cachedir=~/.mutt/cache/bodies
set certificate_file=~/.mutt/certificates

set move = no

Make sure your ~/.muttrc isn’t world-readable; it contains your password. (Alternatively, you can leave them out and mutt will prompt you for the password each time.) Also, if you copy-paste from the above, make sure that you have only “normal” quotes, not “smart quotes” which WordPress might have inserted here into this post.

[Other things I have:

set sort = 'threads'
set sort_aux = 'last-date-received'
set imap_check_subscribed

ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
hdr_order Date From To Cc

I did not include above to justify the "minimal" :)]

Things work perfectly as you would expect them.
One thing to note is that the full headers will still contain the hostname of the computer you send messages from. I have not figured a way of hiding this, and perhaps it shouldn’t be possible.

The End

If for some reason you want to use POP, read on. And tell me why you would want to use POP. The rest of the post is an old version, which i had written before Gmail supported IMAP.

Old Stuff
There is a guide here, which is the first Google result on searching for the keywords Gmail, mutt and Ubuntu in any order, but I would advise against it: it does too much unnecessary stuff using too many unnecessary programs (okay if you don’t care), and involves putting your username and password in a world-readable file (not okay).

There is a guide here, but that site seems down, and so I guess it’s likely to be down again (a DynDNS domain; could be someone’s house), so putting a (fuller) guide here:

First, run sudo apt-get install openssl mutt

Next, in /etc/ssmtp/ssmtp.conf, put

Everything else seems to be optional.

Next, create a shell script with the contents
/usr/sbin/ssmtp -au "gmail-address" -ap "password" $@
and put it somewhere in your path (~/bin/gmailout, say) and make it executable (chmod u+x ~/bin/gmailout, I mean) and make sure only you can read it! (chmod og-r ~/bin/gmailout).

Now in ~/.muttrc, put
set pop_host="pops://"
set pop_last
unset pop_delete #Just makes mutt not ask, GMail uses config option
set sendmail="~/bin/gmailout"
set write_bcc=no #Important; sSMTP makes bcc non-blind otherwise

and you’re set (remember to make this world-unreadable too: chmod og-rw ~/.muttrc)

You can start mutt, and hit “G” (uppercase G) whenever you want to fetch mail. Can also put exec fetch-mail in ~/.muttrc to have it happen whenever you start mutt, but I find that irritating.

Problems with POP: Not that everything is perfect. I can’t have other mail-transport-agents like sendmail or postfix installed alongside ssmtp. I can’t figure out how to get my crontab reports sent to root, but they do go into ~/dead.letter :D
Also, with mutt I had the habit of adding a my_hdr bcc: my-email-address so that the mail I send is threaded along with the mail I receive (yaay, like Gmail), but somehow there seems to be simply no way of getting Gmail to give me, through POP, those messages I send using an external client. It’s a quirk [bug!] in the way Gmail implements POP. This I’ve fixed by setting mutt’s fcc to /var/mail/my-username, my mail folder. (Of course, if I were in the habit of moving mail to my mbox, I could fcc to mbox too.)
Apart from that, it works fine!

Written by S

Tue, 2007-07-31 at 02:16:03 +05:30

“expr: syntax error” with acroread

leave a comment »

I installed acroread (BTW it’s called “Adobe Reader”, not “Adobe Acrobat Reader”) on Ubuntu Gutsy from the Medibuntu repository, and running acroread gave lots of

expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error
expr: syntax error

in an apparent infinite loop.
Googling gave this link but it seemed to already have been fixed in the version I had.

Another link gave the clue:

The line that reads:
echo $mfile| sed ‘s/libgtk-x11-\([0-9]*\)\([0-9]\)00.\([0-9]*\)\|\(.*\)/\1\2\3/g’
should be
echo $mfile| sed ‘s/libgtk-x11-\([0-9]*\)\([0-9]\)000.\([0-9]*\)\|\(.*\)/\1\2\3/g’

The number of 0′s following ’1′ should match what the real libgtk is:

Running locate libgtk-x11 gave

so I removed the 0 on line 421 (not 418) to make it echo $mfile| sed 's/libgtk-x11-\([0-9]*\)\([0-9]*\).\([0-9]*\)\|\(.*\)/\1\2\3/g'
I still don’t understand exactly why it works (the above function would be returning 211050, but it does, and that’s all that matters.

Now to report it on Medibuntu…

Written by S

Sun, 2007-07-08 at 13:26:49 +05:30

Posted in compknow

Devil’s Pie

leave a comment »

is one of the things that can make GNOME usable. It is the perfect example of what I always meant when I said “GNOME is for advanced users” — to get anything except some set of “basic” things done in GNOME, you need real technical skill, while in KDE you only need patience to look through preference dialogs. And gconf-editor is quite reminiscent of regedit ;-)

Anyway, Devil’s Pie is amazing!

The main page here, a short documentation here, and extensive documentation here. These specs might help.

Two files that I have in my ~/.devilspie contain
(and (is (window_class) "Pidgin") (is (window_role) "conversation"))
to make my Pidgin conversation windows maximized, and
(and (is (window_class) "Gnome-terminal") (contains (window_role) "gnome-terminal"))
to have my terminal windows maximised.

To make Devilspie run at startup — go to System → Preferences → Sessions and Add it in the “Startup Programs” tab.

One hackish purpose I use Devilspie for is to get around GNOME’s lack of an equivalent of KDE’s “Activate window demanding attention” keybinding. (Ctrl-Alt-A by default)

Because I mainly need this for my Pidgin conversation windows, I have a file pidgin-conversation-focus.ds in ~/.devilspie/special (not in ~/.devilspie) which contains
(is (window_class) "Pidgin")
(is (window_role) "conversation")
(contains (window_name) "(*)")
and also have a which contains
devilspie ~/.devilspie/special/pidgin-conversation-focus.ds & sleep 1
kill -SIGSTOP $!
in it and is bound to Ctrl-Alt-a (using the painful way GNOME has for assigning keys…)

It sometimes doesn’t work (rather, Pidgin’s message notification plugin doesn’t always insert “(*)” in the title), but I’m getting by.

If there was a way, from within Devilspie, of checking whether a particular window is demanding attention or not, it would be great. I sent a (badly worded) email to the author and haven’t got a reply…

BTW: While testing the above I used
purple-remote "jabber:goim?"
a lot.

Written by S

Sat, 2007-07-07 at 09:13:15 +05:30

Posted in compknow

Online LaTeX

leave a comment »

Someone has collected a useful bunch of links: Using LaTeX in WordPress » Online LaTeX

(Pasted from somewhere, to be cleaned up –)

For typesetting mathematics, there is LaTeX, of course. But what does one do next with the LaTeX file, if you intend the document to be viewable online? Using PDF files for online viewing is frowned upon. There is simply nothing better than HTML, and so one might consider using latex2html. This, however, usually uses images for almost everything leading to huge files and slow-loading pages. Much better in this regard TtH, which tries to make the mathematics display in plain HTML by hook or by crook, but this ends up looking ugly and defeats what was probably one of the major goals in using LaTeX in the first place. One could use MathML — writing a MathML document by hand is absurdly painful, but there is TtM which can convert LaTeX to MathML. But MathML creates XML (not HTML) files, and thus doesn’t plug into general text easily; it also requires the user to have some specific fonts installed, etc., and if a browser (like IE6) fails to display it correctly, the result is a mess. I just discovered that there is ASCIIMathML, which seems to handle everything very well. LaTeX-style formulas work (one can also use their simpler language, it appears). It still needs the fonts to be installed and everything, but when it fails (if JavaScript is disabled, for example), the user will simply see the “source code” of the mathematical text, which can still be readable.

docbook? tex4ht?


Written by S

Mon, 2007-05-21 at 19:34:26 +05:30

Posted in compknow

Tagged with , , ,

Pidgin “now playing” plugins: updating status messages to song being played

with 59 comments

Plugins for Pidgin (the IM client formerly known as Gaim) that update the status message to show the currently playing track, somehow getting it from your music player. Found so far, in what I think is the descending order of something no particular order:
[Note: Before you install any of these, you should be aware that most of them have been known to crash Pidgin rather frequently, and ask yourself whether it is worth it. Your friends really don't care what you're listening to. Really.]

  • D-Bus script by Pidgin developer: works with Rhythmbox and Quod Libet. Will almost certainly not cause a crash. If you are on a Unix system and using one of these two music players, just run “python [name of script]” while Pidgin is running. If you’re on Windows… it’s not so easy. (And you’re probably using different music players anyway.)
  • musictracker

    MusicTracker is a plugin for Pidgin (previously known as Gaim) which displays the music track currently playing in the status message of various accounts such as AIM, Yahoo, MSN, Gtalk (Jabber), etc., i.e. any protocol Pidgin supports custom statuses on. Support for a wide range of audio players on both Windows and Linux platforms is planned. Currently supported players: Amarok, Rhythmbox, Audacious, XMMS, MPC/MPD, Exaile, Banshee, Quod Libet on Linux. Winamp, Windows Media Player (9+), iTunes, Foobar2000 (incomplete support) on Windows.

    Is apparently the best option, but also a very frequent cause of crashes.

  • Pidgin-currenttrack

    Current Track plugin will update your Gaim/Pidgin user info, available message or away message, and buddy icon from iTunes, Winamp, RealPlayer, WMP, Musicmatch, MediaMonkey, XMPlay, Yahoo! & Foobar2000 in Windows and XMMS, Rhythmbox, & Amarok in Linux.

    Has been known to crash Pidgin. I’ve heard it has a feature where you can type “/currentrack” in a conversation window to send your current track, which is pretty cool. Not very useful if it crashes Pidgin though, is it?

  • Pidgin Now Playing

    This plugin will replace %now-playing in your status message with metadata from the currently playing song in a MPRIS compatible media player (currently including BMPx 0.4, VLC SVN trunk, Audacious 1.4.0 devel), if any.

    It appears that MPRIS is an informal standard for music players to support a common interface. In an ideal world, all music players would support this standard, and in the real world, this may or may not happen. Amarok is also probably supported already.

  • MusicInfo

    MusicInfo is a plugin for the Pidgin instant messaging client. It lets you display the music that you are listening to in your away message, available message, and profile.

    For Winamp, and some players that have a Winamp emulation mode.

  • Autoprofile

    AutoProfile is an extension to Gaim that allows users to create customized away messages and profiles using dynamic “components” that automatically update on a regular basis. Generated text can include song names from XMMS/Winamp/iTunes, fortune quotes, computer uptime, the contents of a Web page or a text file, the output of a program, and timestamps.

    Is for Gaim 2.0.0beta3, not updated for Pidgin as of 2007-11-11 (last updated 2006-04-05, so don’t hold your breath).

  • AmarokPidgin

    A plugin for Amarok that updates your Pidgin status message with what you are currently listening too.[sic]

    Is for Amarok only.

  • Pidgin-Rhythmbox

    The Pidgin-Rhythmbox plugin will automatically update your Pidgin user info and status message with the currently playing music in Rhythmbox. If the artist and title are known, it will also attempt to create a link to the song’s lyrics by using Google’s “I’m Feeling Lucky” feature. Pidgin-Rhythmbox will replace %rb in your user info and status message with the song information.

    Is for Rhythmbox only.

  • Write your own script. You can set status from the command line with purple-remote "setstatus?status=whatever&message=whatever". For example, purple-remote "setstatus?status=available&message=" will clear the status message. You can also use D-Bus. There is a very good introduction to D-Bus here, and Ars Technica has some examples of using Pidgin’s D-Bus interface. This is essentially what many of the above plugins do (those that don’t crash your Pidgin). Assuming that you have a way of getting the song (or whatever string you want in your status message) somehow (through D-Bus, maybe) in a script, this is certainly the most flexible option, as you can do exactly what you want with the status message (append to it v/s replace it, add the current time, artist but not title, whatever). You can also look at D-Bus Howto for Pidgin (who wrote that? :), but the harder part is getting the current song from your music player.

Note: While MusicTracker seems to be the plugin that the maximum number of people have been successful in using, it appears that it sometimes crashes Pidgin as well (especially on non-ASCII characters in the title/artist). Evidently, no plugin is perfect (except one that you write yourself :P) and you should take a moment to consider whether you really need a plugin of this sort. I know it seems cool and several IM clients provide a feature like this, but is it really necessary? Do your friends really care what music you’re listening to?

Written by S

Sun, 2007-05-20 at 21:19:06 +05:30

Idea: Poor man’s conference

leave a comment »

The Yahoo! Messenger protocol has “conferences” / “group chats” / “synchronous realtime multiuser text transfer” / “multiplayer notepad” / whatever you call it. Google Talk doesn’t (yet?). This is one of the things that (some) people sorely miss in Google Talk. So people who primarily use their Google accounts for IM are forced to use alternative protocols, such as YMSG or Skype, if they want to group chat…

In a “sudden flash of inspiration”, I realised how easy it would be to create a bot that would make it work even on one-to-one-only services like Google Talk. It could work like this:

  • Suppose Alice Bob Carol and Dave want to have a conference.
  • They each have the bot (“Trent”, say) on their buddy list (“contacts”).
  • The bot is given the list of the four users
  • Each person sends his/her messages to the bot (buddy Trent).
  • The bot sends all messages from user X to all other users, prefixing X: to the messages.

Would work well, AFAICS.

Note that the way the above is constructed, all that the above bot is good for is for exactly Alice Bob Carol Dave to chat… (of course, we could reset this and give the bot new instructions). Having one account for every conference doesn’t seem a feasible idea :-)
Actually, it could easily support multiple conferences as long as they have disjoint sets of members — it would forward the messages of user X only to other users in the conference X is in.
We can also get around the disjointness restriction by making users who are in multiple conferences somehow specify which one they want the current message sent to, in each message…

Another annoyance is what names are displayed… what name the bot shows you a message as coming from might well be different from the alias you have for that person :)

There could be insane security problems, so not considering “rolling it out”, but maybe I can code up something for three-four of my friends (and I) to use…

Update: A few seconds of searching (and the many minutes of debugging/installing!) can save a few hours (or days?) of coding. And to think I was actually trying to write a Jabber client in Python :)
Here it is: Google Talk: Conference Bot.

Sigh. All the good ideas have already been thought of.

Adam was the only man who, when he said a good thing, knew that nobody had said it before him.

said Mark Twain.

Am having some problems installing it, though.

Things that needed fixing:
Update: Nvm, ignore this list below. Just remember to give not, but just username, the first time it asks.
* Manually change confbot.ini so that the server is, not
* Get the newer libraries (and put them in this directory, because for some reason they won’t install)
* Try changing the port from 5223 to 5222 or something. Actually, no: get rid of the extra options in the second line
* Change debug=False to debug=[]
* In the file from SVN, change the “13″ to “4″

This page also seems to be important.

Someone has made a plugin for Google Desktop… listed here too.

Come to think of it, considering that a bot for Google has already been written, what I should write is a sort-of cross-protocol bot… use libpurple and write it in C? :-)

Written by S

Wed, 2007-04-25 at 00:42:51 +05:30

Posted in compknow

Tagged with

Getting xchat to open Firefox instead of whatever

leave a comment »

It’s covered in the XChat FAQ: What’s the deal with opening URLs in XChat on Unix/Linux?.

I manually added the “Open link in Firefox” option, and haven’t bothered figuring out how it works on Edgy’s Xchat (2.6.6), and decided to wait and see how things work in Feisty (Xchat 2.8.0), as the FAQ says everything’s changed in 2.8.0.

Update: I’m using Ubuntu Gutsy, which has XChat 2.8.4, and everything works fine by default, without having to tweak anything.

Written by S

Wed, 2007-02-07 at 21:20:58 +05:30

Posted in compknow

Debian/Ubuntu: Find out which packages are taking the most space

leave a comment »

There is a package called debian-goodies (that’s what it’s called on Ubuntu as well :-)) which has this utility called dpigs — for telling you which packages are “pigging out” on your system. (So install it with sudo apt-get install debian-goodies, and then run dpigs). This and other utilities, from the description:

 debget       - Fetch a .deb for a package in APT's database
 dpigs        - Show which installed packages occupy the most space
 debman       - Easily view man pages from a binary .deb without extracting
 checkrestart - Help to find and restart processes which are using old
                versions of upgraded files (such as libraries)
 popbugs      - Display a customized release-critical bug list based on
                packages you use (using popularity-contest data)


Written by S

Tue, 2007-02-06 at 02:20:17 +05:30

Posted in compknow

Tagged with , ,

Symbol’s function definition is void: outline-font-lock-level

with one comment

Using Emacs and todoo-mode (the todoo library / todoo.el).
I got the message

Symbol’s function definition is void: outline-font-lock-level

whenever I tried to insert a new sub-item (using C-c M-i which is bound to todoo-insert-sub-item) in my TODO file. Searching Google gave someone’s old diary, from which (although it’s in Japanese ;-)) I found that it’s related to Debian bug 244681: emacs-goodies-el: todoo.el doesn’t work at XEmacs21. I’m using GNU Emacs and not XEmacs, though.

Update: Before you try the “fixes” below (and in the comment), try just downloading the latest version from Debian. It appears that this got reported as bug 447760, and got fixed.

Anyway, the fix (I haven’t learnt Emacs lisp, so this may be far from the “best” way to do it):

  1. Open the todoo.el file (M-x find-library RET todoo RET) and find the todoo-insert-sub-item function. (Better, use C-h f todoo-insert-sub-item RET and follow the link.)
  2. Replace (outline-font-lock-level) with a value, like 3 or something. You might also want to do the same in the other place that (outline-font-lock-level) is used — in the function todoo-indent-line
  3. Another solution, if you don’t want to / can’t edit the file (no permissions, for example), might be to define the function (outline-font-lock-level) — put (defun outline-font-lock-level nil 3) somewhere.

    Another solution might be to redefine the function entirely. This requires knowledge that I don’t have, but, for example, making some local transformations, I replaced it with this:

    (defun todoo-insert-sub-item ()
      "Insert a new todoo-sub-item."
      (goto-char (- (todoo-item-end) 1))
      (insert (concat (make-string todoo-indent-column ? )
                      todoo-sub-item-marker " \n"))

    The space after the ? is important.

Written by S

Sun, 2007-02-04 at 20:14:31 +05:30

What to do with a Debian/Ubuntu source package

leave a comment »

A Debian source package (something like this) often has files like xxxxx.orig.tar.gz, xxxxx-1.diff.gz and xxxxx-1.dsc. It wasn’t clear what to do with them, so I gathered courage and asked in #debian, and despite all the stories I’d heard about the channel, a couple of people were actually nice enough to answer: do dpkg-source -x xxxxx-1.dsc, which will extract the .tar.gz (don’t do it yourself) and apply the patch correctly. Then you have the source directory, where you can go and configure, make ….

Written by S

Mon, 2007-01-22 at 18:39:44 +05:30

Posted in compknow

The Firefox right-click bug

with one comment

I was having a bug with Firefox where right-clicking in some places would bring up two context menus, a sort of double-menu with one on top of the other, and with both of them working (but clicking somewhere else outside dismisses only one of the menus).
I searched around on Google a bit and found no mention of it… Recently, one of my friends had the same bug, so we knew what to do — look in the list of extensions that we had both installed, and find which one was causing it. The culprit turned out to be Image Zoom. I uninstalled it, and now everything works fine.

Update: There is a video of this behaviour.
Update: It seems (seems) to be fixed: here.

Written by S

Mon, 2007-01-22 at 18:24:44 +05:30

Posted in compknow

Tabs in Emacs

leave a comment »

Here is an incredibly detailed page on Tabs in Emacs, and I’m sure it doesn’t even explain the issues completely :-)

Written by S

Sat, 2007-01-20 at 22:46:00 +05:30

Posted in compknow

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 and

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

BSNL DataOne’s DNS

with 6 comments

The manual I got asked me to use and as the domain-name servers, but it appears that this is not really optimal. I found other sources, and confirmed by looking at one particular DataOne manual.
Here are the first few lines of my /etc/resolv.conf now:

nameserver #BSNL, primary for South, secondary for North
nameserver #BSNL, primary for North, secondary for South
nameserver      #BSNL, primary for East
nameserver      #BSNL, secondary for West
nameserver #BSNL, primary for West, secondary for East
nameserver  #OpenDNS
nameserver  #OpenDNS

The first one is really faster slightly (about 63 ms instead of 79 ms, or so), but I doubt if it matters…

[Update, asked in the comments: use this on Windows.]

Written by S

Mon, 2006-11-13 at 16:41:46 +05:30

Posted in compknow

The pefect (non-)markup solution

with 4 comments

I just found something that’s amazing in its simplicity, and yet neatly solves a problem. Maybe you’ve sometimes wondered how to markup your email (perhaps in cases where you want the same text to be reusable) and yet retain its readability. (I have a friend who sometimes writes email in TEX markup, which is just incredibly wrong and annoying.) There is a solution that is as close to perfect as imaginable: Markdown. Its Basics page was itself written in Markdown. The syntax is perfectly readable; it is available on Ubuntu and Debian, and can even be generated from HTML, in case one wants to go in the other direction. It even has a Wikipedia article, and (even without looking!) I’m sure it’s the best “lightweight markup language” there is. There seems to be a markdown mode for Vim, but no “standard” mode for Emacs yet. (But with such good and readable syntax, who needs an Emacs mode, anyway?) There is a comparison here. There are converters from MarkDown to other formats (such as LaTeX), see Pandoc (written in Haskell!) and MultiMarkdown.

Another thing that looks impressive (and even more useful, because it is well-integrated into Emacs) is Emacs Muse, can be published to a lot of formats, including DocBook and LaTeX. Documentation here, and someone’s personal notes here.
I haven’t tried either of them yet.

[Update] Emacs Muse is nice, but it’s really not polished enough yet. (Either that, or if it’s not going to change then I don’t like it.) There are no nested lists yet. (It does now.) Markdown says

The overriding design goal for Markdown’s formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions. While Markdown’s syntax has been influenced by several existing text-to-HTML filters, the single biggest source of inspiration for Markdown’s syntax is the format of plain text email.

That doesn’t seem to be Emacs Muse’s “overriding design goal” to me (I need to figure out why I feel so, but somehow the syntax feels kludgy and seems to have many bad corner cases).
As I see it, the most powerful and compelling features of Emacs Muse are

  1. The entire publishing system, where you can take a document and publish to multiple formats based on syntax translation rules, keeping a daily journal, etc. (planner-el depends on Emacs Muse for some of its functionality.)
  2. Its integration with Emacs

Frankly, IMHO, the actual markup language is not one of its greatest features, and it would be great if they used — or allowed plugging in — other existing languages.

(Update-update: This does seem to be the idea, or at least was at some point of time. See this thread, which contains a file that provides some MarkDown support in Muse.)
[End update.]

Written by S

Sun, 2006-11-05 at 21:18:55 +05:30

Linking to the New York Times

leave a comment »

The New York Times have a policy whereby links to them from weblogs require no payment (nor registration, it appears).

Someone has put up a link generator here. Please use it when linking to the NYT from blogs.

Written by S

Sun, 2006-11-05 at 17:26:13 +05:30

Posted in compknow

Emacs copy/paste and X

with 17 comments

Many people have problems getting copy-paste working in Emacs. Sometimes this can be ascribed to a misunderstanding of how the system works, but often it is a bug with Emacs itself.

First, a general word about how cut/copy/paste work in Linux and all applications:
Much of the confusion arises because there are actually two mechanisms for copying text between applications:

There is an explicit “clipboard”, just as in Windows. If you select some text, and explicitly click “copy” (or “cut”) somewhere (that is, either in the right-click menu or in the Edit menu, usually), it goes into the clipboard. You can paste it elsewhere by again explicitly clicking on “paste” (or Ctrl-V, often). This works perfectly well within itself, and just as in Windows, so there are no problems at all (except in Emacs sometimes, and we’ll come to that).
Primary selection
In addition, there is the “primary selection”. Consider it an additional feature which you can ignore if you like. It works like this: when you select some text (just select… highlight it, that’s all), it gets automatically “copied”, and you can paste it into another location simply by middle-clicking. This is intended for more temporary tasks, and shouldn’t be used for anything serious. A thing to watch out for is that unlike in the case of the clipboard, the text doesn’t really get copied anywhere. What actually happens when you middle-click to paste, is that the destination program asks the source program the text to be pasted. A consequence of this is that if you select some text and close the source program, you can’t paste that text anymore. In short, a good way to think of this is as “extended drag-and-drop“, in which you are allowed to let go of the mouse, change windows, and maybe even do a little bit of work (which does not require selecting) in some another window before finally “dropping” with the middle-mouse click.
[There is also a "secondary selection" and another ancient mechanism involving "cut buffers", but neither of them is in use these days. Clipboard managers, like Klipper or the GNOME clipboard tool, can often be asked to use either the clipboard alone or the primary selection too.]

This general picture is explained at jwz’s page and in this spec.

Second, the problem: Somehow, Emacs has problems with this. It is very inconsistent, so it’s hard to pin down the exact nature of the problem, but in general copying text between other applications and Emacs seems to just not work sometimes. With me, pasting into emacs works (almost always) by default; copying from emacs doesn’t, no matter what I try. Others have had the opposite problem.

Some possible solutions/ideas:

  1. This page claims to have a fix, which is essentially to add the lines
    (setq x-select-enable-clipboard t)
    (setq interprogram-paste-function 'x-cut-buffer-or-selection-value)

    to ~/.emacs. It didn’t help.

  2. There is mouse-sel-mode, which seems to affect pasting into emacs, whatever the name might say.
  3. The emacs manual says

    To copy text to another X window, kill it or save it in the kill ring. Under X, this also sets the primary selection. Then use the “paste” or “yank” command of the program operating the other window to insert the text from the selection.

    , but it didn’t help me either.

  4. I’ve discovered that the situation is better when Klipper is running — selecting (or copying) text in Emacs results in it being copied (imperfectly) to Klipper, and I can then paste in other apps, provided I first click on Klipper and choose that text. Weird.
  5. I can select in Emacs, and middle-click it onto konsole. It works. I can then select that and paste it into Firefox. That works too. So maybe Emacs and Firefox don’t have a good way of talking to each other. (The same seems to be true of any GNOME app, not just Firefox.)

The bug is clearly somewhere under x-set-selection, because invoking it directly doesn’t work either.

And, trying to set the Emacs font today, I discovered another bug: I couldn’t paste from the xfontsel selection to any KDE app. I could do the thing of pasting into Firefox and then pasting into Emacs, though. There is also this discussion about what happens (or should happen) when something is “copied” without being selected first.

There are some other discussions at , , and this Slashdot article about copy-paste, although none of it has been useful.

Please leave comments here if you have something to say; I still haven’t managed to find a workaround.

Updates: I found that M-x clipboard-kill-ring-save and M-x clipboard-yank seem to work for copying from Emacs to the clipboard and pasting from the clipboard into Emacs. In some of the comments below, Richard Lewis had the idea of using xsel, and Hugo Heden completed it further.

Written by S

Sun, 2006-10-22 at 23:55:00 +05:30

Posted in compknow


Get every new post delivered to your Inbox.

Join 67 other followers