Saturday, January 24, 2009

Kharcha

I stay with 4 other roomies in our rented flat @ pune. As usual, we share resources to cut down on expenses. rent, utensils, food raw materials, gas refills, electricity bill, paying the maid, internet, paper bill n what not. Different people pay for each of these, as and when required and based on availability of money. During the early few months, it was quite difficult to keep track how much each person owes others, at the end of the month. It was a boring procedure and there used to be a lot of confusion. There might be apps doing this, but the initial searches got me complicated apps that were designed to do some other things but not exactly what i want. May be i didnt search well. My requirements were quite simple, so i stopped hunting for apps. I could write some rudimentary ruby by then. So, Instead of finding an app to do this, I thought of writing a ruby script that make this easy.

So the script parses a simple text file(i call it a .kharcha file :) ) containing comma separated entries that talk about expenses.

Each line says the following:
1) who were involved in the expense.
2) who paid
3) the date of exp

a) one can use shortcuts for big names to make it easy to make entries in a .kharcha file.
b) for a line, if #1 is empty, it assumes all users were involved.
c) I usually create one kharcha file for each month e.g jan.kharcha, feb.kharcha

The script then spits text indicating "who owes whom what".

Sample .kharcha file => january.kharcha

Sample script output => kharcha.txt

Script => kharcha2.rb

If somebody finds this hacked together script useful, do let me know. If i find time, i might put together RoR based web ui for this.

Editing Remote Files

Not sure how many people already know about this / do this, but here goes.

I have seen many ppl logging onto remote machines via ssh and coding using terminal based editors like vi, emacs, nano,etc. If you love the power of the command line and prefer vi over GUI editors, thats fine. But, what if you thought its not possible to edit these files locally using your favorite GUI editor right on your desktops?.

All you have is an ssh account on the machine, so, how do we do this ?

Enter "sshfs". It lets you mount a remote file system on you local machine with your ssh crendentials.

sshfs {remote_user}@{remote_host}:{path_to_remote_folder} {local_folder}

Thats all, fire up your fav GUI editor and point it to the file in the local folder that mounted the remote folder.

One can tune the sshfs caching and timeout values to suit one's needs.

This also helps if you wanna run some some quick and dirty scripts on remote files and the script is difficult to setup on the remote machine due to limited access.