Saturday, March 22, 2008

vim sorcery: read/write pdf files

I hate switching windows to refer some manual while coding.. completely breaks the flow. I was browsing through some vim tips, which had an entry for reading MS Word docs in vim and wanted to do the same with pdf files... and then decided to take it a notch higher. By adding the following entries to your .vimrc, you can read/write pdf files transparently, as if they were just regular files. Of course, you can also open these pdf files in regular pdf viewers.

Here's how to do it:
  1. Get xpdf and cups-pdf. On Ubuntu this should do the trick:
    sudo apt-get install xpdf cups-pdf
  2. cups-pdf prints the pdf files and saves them in ~/PDF/ by default. I am assuming that these settings wont be changed.
  3. Add the following lines to ~/.vimrc
    autocmd BufReadPre *.pdf set ro nowrap
    autocmd BufReadPost *.pdf silent %!pdftotext "%" -layout -q -eol unix -
    autocmd BufWritePost *.pdf silent !rm -rf ~/PDF/%
    autocmd BufWritePost *.pdf silent !lp -s -d "%"
    autocmd BufWritePost *.pdf silent !until [ -e ~/PDF/% ]; do sleep 1; done
    autocmd BufWritePost *.pdf silent !mv ~/PDF/% %:p:h
BTW, I have also added this tip to vim Tips. Once setup properly, you can open, save, write pdf files in vim as if they were regular text files.(I guess I already said that earlier.. but what the heck)

Saturday, March 15, 2008

Changing times...

me: Hey am getting a new computer.. 8.1 G hard disk, 64 MB ram for about $1000
friend: What!! are you gonna live inside it?? Why would you need that much storage??

me: Hey am getting a new computer.. P4, 40 G hard disk, 512 MB RAM for about $1000
friend: neat man.. NFS will rock on that.

me: Hey dude... I got a new laptop.. P4, 80 G HDD, 1 GB RAM for $1000
friend: I guess that should be enough for a student.

me: Hey I got a laptop for my uncle: Dual core Pentium centrino 2 GHz, 4 GB RAM, 160 GB 7200 RPM with collision sensors for about $1000
friend: Good deal... will that be enough though?

Based on above conversations, my corollary to moore's law: Human expectation and dependence on technology is directly proportional to the rate of growth of technology.

And on a totally unrelated note.. I have already decided on my next desktop that I will be purchasing next year: a dual quad core Intel Xeon with atleast 4G of RAM. This is the sweetest machine at my workplace and should be inexpensive this time next year... but based on my proposed corollary above, my friend might declare me a retard.

Saturday, March 01, 2008

Lens Fetish

I think its time I introduced you to my new love.. Canon Rebel XT. I had iffy affairs with couple of point and shoots and one really prehistoric film camera but there was something always missing in our relationship. I purchased this camera at a black friday sale last year and have never looked back since. I know I know.. she is not as good looking as Nikon D200 or as smart as Canon 5D.. but she gets me and I know that we are meant for each other. We had couple of lenses, filters, a tripod and a remote control together.. we are really settled now for some time.

Jokes aside.. I am still an amateur photographer.. infact I can safely say that I know most of the theory that goes into photography (after reading few books, manuals, articles and watching some videos)... but still suck at executing them. Exceptional photographs take a lot of patience, skill and time. If I take a 100 pictures in a day.. only 5 to 10 of them are worth keeping (which eventually make it to my flickr page). I have the most inexpensive gear that one can get and all individual items are less than $200 (thats dirt cheap if you ask any photographer)... This does mean that I have compromised alot on the build and optical quality of the lenses, but come on.. you don't learn drifting on a BMW with traction control :P .. and hey thats just my way of looking at things. Am showcasing two of my favorite pics to add credibility to my self proclaimed "amateur" photographer status.. the mistakes in these will be obvious to a seasoned professional.

A lot of my friends are into photography at some level and often ask me about it. Since SLRs are not cheap and the hobby isn't really meant for casual photographers who just buy cams and toss them aside for "occasions", they are wary about getting into it. Here are my two cents to those who are just planning on purchasing an SLR (from a point of view of a hobbyist.. not a professional):
  • If you never owned a camera before, DONT buy an SLR. Get a point and shoot.. experiment for atleast an year before getting into it.
  • Decide on the brand: Canon, Nikon, Kodak, Olympus, Sony etc etc.. its really important that you do your research before choosing a brand. Lenses are more expensive than the camera itself, so even if you go for a low end camera, you will eventually buy some decent lenses and quite obviously lenses meant for one brand are not compatible with others. (There are convertors, but you dont want to go down that road).
  • Dont buy a high end professional camera.. go for the inexpensive one first. I say this for two reason: Firstly, higher end SLRs are heavy and huge.. you dont want one strapped around your neck all the time.. unless you are making money off your pics. Lower end SLRs like Canon Rebel XT are lighter.. though it still takes some time to get used to the fact that you cant shove it in your jeans pocket; Secondly you might not wanna go all the way.. believe me, photography gets to the point where you have to get into science and physics involved to get a good effect. It takes more effort than you think. Be kinder to your pocket and start with a cheaper camera.. if you are not able to take good pictures with a cheaper SLR, an expensive one wont do you any good.
  • Buy a good tripod, but don't go overboard. Bogen Manfrotto 728B is perfect for beginners.
  • Be a flickr group regular.. atleast be a passive listener there. The information and help you can get from people in these groups is phenomenal.. Find out a group that gels with your needs. You can find many experienced professional to help you with your problems.
  • Read, read, read.. Read manuals, articles, tutorials on anything related to photography.
  • Learn to use a photo manipulation software like Gimp or Photoshop.. and no, picassa wont do.
  • Keep clicking.. I cant belabor the point enough.. probably the first few hundred, even thousand photos you click from your SLR will be worse than those clicked using a point and shoot.. don't give up hope.
  • Explore pictures on Flickr, look around for photographs.. see their EXIF information. Set those values on your camera and try reproducing the shot. I find this the best way to learn.
Also accept the fact that a decent picture of you will never be taken once you get good behind the camera :)