Code for Concinnity

beautiful and elegant solutions


Getting the currently running host name in Capistrano

I don’t know if it is so obvious that no people talked about it, or that people actually don’t need to use it. I find that for any non-trivial tasks, it is necessary. There is a thread on Google Groups that talked about it but it didn’t spell out the answer directly. So here it is:

1
current_host = capture("echo $CAPISTRANO:HOST$").strip

Kind of anti-climatic lol.

Published by kizzx2, on November 29th, 2009 at 3:31 pm. Filled under: Useful tips Tags: , No Comments

Stop Gmail Notifier from asking the password every time upon login

I use the very out-dated Gmail Notifier client. I know it hasn’t been updated since 3 years ago but very sadly it’s still the best Gmail client around (it’s lightweight, works properly and official).

Today I finally solved one annoyance I have with this application, is that it keeps popping out the password dialog box every time I login. Until stumbled upon the solution:

If you want Gmail Notifier to do NOT ask for password each time it starts, the next time that windows pops up asking for username and password, do not use it: just close it. The Gmail Notifier icon will get an (!) warnning after that. Just open Internet Explorer and go to http://mail.Google.Com/ and login with your mail and password, and choose to keep the session open. Then go to Gmail Notifier, yet with the (!) and with the right mouse button choose the option Check Mail Now.

It will not ask you again the password with a desktop window.

Oh well, so the answer turned out to be IE, lol! It looks like the Gmail Notifier client uses IE’s component to access the server, so the password session stored in IE can be used directly. Hooraay!

Published by kizzx2, on November 16th, 2009 at 3:45 pm. Filled under: Uncategorized Tags: 3 Comments

gvim — E303: Unable to open swap file for “[No Name]“, recovery impossible

vim is my editor of choice and I install it in Windows. All is working quite good except one little annoyance — when I open the editor fresh and started editing by going into insert mode, it will give this error message:

1
E303: Unable to open swap file for "[No Name]", recovery impossible

This is usually harmless, as soon as I save the file everything would be great, it’s just that 1 – 2 seconds of pause that doesn’t make me feel good, so today I tried to pin down the problem and here’s how it went:

1
2
3
4
5
6
7
:help E303
(So it's related to the swap file. Let's see where our swap file fails to be created.)
:set directory?
directory=.;c:\tmp;c:\temp
(Oh, those are the default %TEMP% which I moved to another drive! But anyway, the first priority should be the current directory. So let's see where we're now)
:pwd
C:\Windows\system32

Solution

OK it’s pretty obvious now. It probably needs a little bit of manual fixing. Let’s put this in our .vimrc

1
2
3
4
5
" Thanks for an anonymous guest to provide this generic, better solution
set directory=.,$TEMP

" This is line I used at first. The above line is better than this

set directory=.,d:\temp

Great, problem solved!

Published by kizzx2, on November 6th, 2009 at 3:58 am. Filled under: Useful tips Tags: , , , 6 Comments