## Stamp Papers with Their Citation

Wouldn’t it be convenient if the citation of the paper was available as part of the pdf document? You wouldn’t have to google for the information.

We can do so with the help of a simple perl script — the stamp is formatted using latex and is integrated with the original document to generate another version that has the stamp at the top of the page.

Below is a snapshot of document that was stamped using this script. Note the publication venue, location, month and year of publication at the top of the paper. The pdf is available here.

Here is the script:

#!/usr/bin/perl

$numArgs =$#ARGV + 1;
if($numArgs != 3){ print "Usage: ./stamp.pl <input pdf> <output pdf> \"year etc.\"\n"; exit; }$input_pdf = $ARGV[0];$output_pdf = $ARGV[1];$text = <<END
\\documentclass[letter]{article}
\\usepackage{fancyhdr}
\\pagestyle{fancy}
\\begin{document}
%\\fancyhead[CO,CE]{\\protect \\centering $ARGV[2]} \\centering$ARGV[2]
\\fancyfoot[c]{}
\\end{document}
END
;

open TEX_OUT, '>stamp.tex';
print TEX_OUT $text; close TEX_OUT; system('pdflatex stamp.tex'); system("pdftk$input_pdf stamp stamp.pdf output $output_pdf");  Categories: best practices ## Using latexdiff to Highlight Revisions in a LaTeX Project April 21, 2014 Leave a comment Typically research papers are put together as LaTeX projects. I was under the impression that it is a challenge to keep a visual track of who made what changes; typically there are more than one authors on the paper and we try to learn from the experienced writers. But then I came across a useful tool, latexdiff, which opened the door for many possibilities. What latexdiff does is that it highlights, in color, the differences between two LaTeX files. Consider a trivial example below. Latexdiff compares the two LaTeX files (original.tex and revised.tex) and generates a LaTeX file as output (diff.tex), which can then be compiled into pdf to view the output. latexdiff original.tex revised.tex > diff.tex pdflatex diff.tex  An example is shown below, where red color highlights the text that was deleted and blue color highlights the text that was added. When collaborating, the LaTeX project includes multiple files that are pulled into the primary LaTeX file. This can be done using the flatten option. latexdiff --flatten original.tex revised.tex > diff.tex  I’ll leave it to you to explore the documentation for other possibilities. The tool can also be used along with version control systems (e.g., svn). Below is a crude bash script that pulls an old version from the svn repository and compares it to the version in your working directory. #!/bin/bash # Version: 0.01 # Author: Umar Kalim if [$# -ne 2 ] ; then
echo "Usage: $0 <svn revision no.> <filename>" exit 1 fi svn_revno=$1
filename=$2 mkdir tmp echo "exporting svn repo$svn_revno"
svn export --force -r $svn_revno . tmp echo "generating diff" latexdiff --flatten tmp/$filename \$filename > diff.tex

echo "compiling output with highlights"
pdflatex diff.tex

echo "cleanup"
rm -rf tmp

Categories: best practices Tags:

## Tack Sharp Portraits

Until few months back, I used to wonder: why is it that my portraits aren’t tack sharp? I would feel that I could have eeked out more sharpness. However I wasn’t sure what was it that I was doing wrong. I would make sure that I:

• Use spot focusing and choose a focus point so that I could aim for the eyes,
• Choose a shutter speed that is fast enough to freeze motion when I want it to,
• Choose an aperture so that I could blur the background,
• Choose the lowest possible ISO,
• Try to adjust my exposure settings to expose for highlights and
• Choose a focal length greater than 50mm.

However, irrespective of the output, I would always feel that the portrait could have been sharper. I had seen stunning portraits (with the same lens) and I knew it could be done. Yes, the glass matters, but my Tamron 17-50mm f/2.8 wasn’t too shabby.

After much research, I found that not all apertures of the lens capture images with the same sharpness. (What? How can this be true? This called for a serious investigation.)

I googled for a lens-test chart. To test the lens, I stuck the chart to a wall. After arranging sufficient ambient lighting, I setup the camera on a tripod and switched to aperture priority mode. After setting the ISO at 100, manually focusing on the chart with live view and using a release cable to trigger the camera, I took photographs for all aperture settings at different focal lengths.

The results were astonishing. See the pictures below at 17mm. With all other parameters fixed (except for shutter speeds, which is understandable) the photograph at f/2.8 is not as sharp as the one at f/4.0. Similarly, the one at f/4.0 is not as sharp as the one at f/5.6. However I started to lose sharpness at the other extreme too. I observed the same behavior at all focal lengths, though with slight variations. Nevertheless, the trend was the same. Sharpness was poor at extreme apertures, which in my case was f/2.8 and f/32.

 f/2.8, 1/400 sec, 17mm, ISO100 f/4.0, 1/200 sec, 17mm, ISO100 f/5.6, 1/60 sec, 17mm, ISO100 f/22, 1/4 sec, 17mm, ISO100

The lesson was that by stopping down once (f/4.0) I would get a pretty good image. Stopping down twice (f/5.6) would result in a much more sharp photograph. From there on I would observe diminishing returns, until the sharpness started to deteriorate.

Therefore, your f/1.4 may not produce pictures as sharp as you would have expected it to produce at f/1.4. While it is important to consider other aspects — e.g., avoid camera shake, making sure that you’ve focused where you intended to and choosing other exposure settings — avoiding extreme apertures is important to obtain tack-sharp photographs.

I have not tested the same with L series lenses. I would expect similar trends though.

There is another aspect to this discussion; I also realized that we should not confuse the lack of sharpness due to extreme aperture settings with the blurry feel of photographs that have a narrow depth of field. When we choose a small aperture (say f/16), we are increasing the depth of field; when we choose a wider aperture (say f/2.8), we are narrowing the depth of field. Depending on your focal plane, a photograph with a large depth of field may have a “feel” of being sharper than a one with a narrow depth of field. However, the discussion above is not with reference to the overall feel of the photograph, but instead about the sharpness of the subject(s) that fall within the region that is in focus.

Categories: photography

Disclaimer: This post is inspired by emails exchanged between myself and Dr. Mark Gardner (Virginia Tech). The term “password reconstructor” has been coined by him. The software mentioned below is developed by Richard B. Tilley.

Most of us are familiar with the best practices of choosing our passwords. When following these best practices — such as not using the same password for different websites; using alphabets, numbers and symbols — it is impractical to memorize all our passwords. Subsequently we use password managers such as Lastpass, 1Password, KeePass, or similar software. Now, with the news of the heartbleed bug everyone has been forced to change their passwords. This change of all the passwords has not been fun for me.

After discussion with several colleagues, I realized that I can do away with the problem of managing my passwords. There is something called a “password reconstructor”, where you are not required to remember, store or manage hundreds of passwords; you do need to remember one phrase though. But that is not a challenge for us, after all we’ve been memorizing passwords that look like Egyptian hieroglyphs.

So what are these password reconstructors? and how do they work?

The idea is that you use a secret phrase or a master password along with labels to generate your passwords. The phrase would act as your secret key and the label would indicate the purpose of the password. For example, you may use the phrase “intelligence is imagination” and the label “bank” to generate a password for your bank account. Similarly, you would use the same phrase with the label “amazon” to generate the password for your amazon account.

As the password constructors use cryptographic hash algorithms, the smallest of differences in the phrase or label would result in substantially different passwords. For example, below are two passwords generated by slightly different labels.

phrase:intelligence is imagination; label:bank; password:JBB1H4O1G0Nur3.H0k
phrase:intelligence is imagination; label:Bank; password:p5ZMIXL1OuHaIZ.H0k


Note that I used the same phrase, but I changed the first alphabet of the label — the first uses “b”, while the second uses “B”. The passwords generated are altogether different.

These passwords were generated by software available here. It does not generate passwords with symbols or punctuation. Therefore the author chose to add a four-letter suffix “.H0k”. This allows the password to be compliant with the requirements of websites that ask for at least one character from the upper and lower case, numbers and punctuation.

So there you go. We do not need to store any password. We do not need to painstakingly think of a combination of words with weird characters, later to be prompted that the password provided does not meet the website’s requirements. All we need is one secret phrase, and a label to obtain a strong password.

The software developed by Brad is available for OSX, Linux and Windows. The source code is available too.

I am grateful to Mark for bringing this software to my attention and thankful to Brad for publicly sharing the software and the code. I’ve setup a copy of the Javascript version here.

Categories: best practices

## Ghazal: Dard Se Mere Hae Tujhko Beqarari Haae Haae!

I came across this beautiful ghazal, “dard se mere hae tujhko beqarari haae haae”, by Mirza Asadullah Khan Ghalib, sung by Rahat Fateh Ali Khan. I thoroughly enjoyed listening to the verses and felt like sharing it with others.

Unfortunately, those who do not understand the language Urdu would not be able to follow the poetry. For those who do understand Urdu, I’ve tried to translate the difficult-to-understand words and phrases.

Enjoy!

Dard ho dil main to dawaa kijiye,
Dil hi jab dard ho to kiya kijiye!

Ham ko fariyaad (request) karni aati hae,
Aap sunte nahi to kiya kijiye!

Ranj (sorrow) uthaanay se bhi khushi ho gi,
Pehle dil dard aashna (familiar) kijiye!

Maut aati nahi kaheen Ghalib,
Kaab tak afsos zeest ka kijiye!

Dard se mere hae tujhko beqarari (restlessness) haae haae,
Kiya huwi zaalim teri ghaflat-sheari (callousness) haae haae!

Apni hasti hi se ho jo kuch ho,
Agahi gar na sahi ghaflat hi sahi!

Tere dil mein gar na tha aashob (agitation) e-gham ka hosla,
Tu ne phir kiyun ki thi meri gham-gusaari (commiserate) haae haae!

Kiyun meri gham-khargi (share sorrow) ka tujhko aiya tha khayal,
Dushmani apni thi meri dost-daari (fellowship) haae haae!

Umr bhar ka tu ne paeman-e-wafa (sworn loyalty) bandha to kiya,
Umr bhar ko bhi to nahi hae paedaari (certainty) haae haae!

Zahar lagti hae mujhe aab-o-hawa-e-zindagi,
Yaani tujh se thi ise nasaaz-gaari (inappropriateness) haae haae!

Zindagi apni jab is shakal se guzri Ghalib,
Hum bhi kiya yaad karein ge ke Khuda rakhte the!

Gul-fishaani (lavish with flowers) hae, naz-e-jalwa (beauty) ko kiya ho gaya?
Khaak per hoti hae teri lalakaari (stringing of flowers) haae haae!

Sharm-e-rusawaae (fear of shame) se ja chupna naqaab-e-khaak (veil of ashes) mein,
Khatam hae ulfat (love) ki tujh per parda-dari (privacy) haae haae!

Khaak mein namoos-e-paeman-e-muhabat (respect for the benchmarks of affection) mil gae,
Uth gai se dunya se rah-o-rasm-e-yari (custom of fellowship) haae haae!

Ishq mujhko nahi wehshat (agony) hi sahi,
Meri wehshat teri shohrat (popularity) hi sahi!

Ishq ne pakra na tha Ghalib abhi wehshat ka rang,
Reh gaya dil mein jo kuch zauq-e-khari (experience of anguish) haae haae!

Dard se mere hae tujhko beqarari haae haae,
Kiya huwi zaalim teri ghaflat-sheari haae haae!

–Ghalib

Categories: poetry Tags:

## Hokie Snow

March 12, 2012 2 comments

(2/19/2012) Finally! It snowed; it snowed as it typically does in Blacksburg. I wasn’t feeling well, stressed with all the juggling that I have to do, so I thought, I am going out for an adventure. This will be a nice distraction. Crazy as I am, I charged my camera’s batteries, setup lens protection — snow melts into water you know and that can get inside the camera (smart thinking :P), — put on layers and layers of clothing, cued the music and off I went.

As soon as I stepped away from the building, whoooaaa!! it was pretty slippery out there. If this was a sign of things to come, I’d be sitting on the ground more than taking pictures. Anyway, I took it as character building and moved on.

While I was walking down the winding toms creek road, a few police cars went by. Someone must have got into an accident. It was snowing pretty heavily. I had to spit out snow every few steps. Never the less, the views were spectacular.

By the time I reached campus, it must have snowed a couple of inches. Snow in my face, on my shoulders, on the bag. The camera was all covered in snow. But then, I was out for an adventure.

I was glad that I made the effort. It was worth it. The view from War Memorial was amazing. Everything was covered in white. There were so many people around, some making snowmen, some building thrones to sit on, some just mucking around throwing snowballs. I had to wait minutes to get a reasonable shot. Nevertheless, all the wait was worth it in the end.

The trees looked beautiful. They had this majestic appeal to them. I do not think the pictures do justice to the beauty.

And then someone opened the flood gates. It started snowing like crazy and everyone wanted to get out of there. I thought that I too should start heading back, I decided to take the long route and go via duck pond and see if I can get some more shots there.

The snow would just keep coming and coming.

But the I thought, wait a minute, the poor photographer is always left out. I need to get some photographs of myself. Despite the god-awful snow in my mouth and finding its way onto my back through my shoulders, I setup the tripod and took few pictures of myself. Got all my jeans wet.

Anyway, as I was trotting back along the duck pond, trying to exercise my creative abilities, this girl comes up to me, “ooh, so you are on a photography assignment? … by the way, do you know when does the bus come?” and I was like … “hahahaha … No. I just enjoy photography … unfortunately I do not know the schedule. Sit tight and bus should be here”. She must be new and I realize how lost new students feel; I was once a new student. I imagine that the delay was because there was an accident. The driver slammed the SUV into the fire hydrant :|. It doesn’t seem much, but trust me, there was a lot of snow. Driving would not have been easy. In fact, it is snowing at this moment.

I am just glad that I got new tires for my car in time.

Anyway, at this time, my fingers stared aching. I removed my gloves, and what do I see? Blue fingers. OK, I realized, time to head home before I lose my fingers. I couldn’t pack the camera. If I tried to do that, it would have got the lens all covered with snow. I was barely keeping snow out of my mouth.

My fingers hurt so bad, that I thought of calling someone to take me back home. But then I went towards a building. Brushed off all the snow, all that I could and stuffed the camera in the bag and started rubbing my hands fiercely. In few minutes, I started feeling better. Thanked Allah that I got my fingers back. Time to head home.

On my way back, I was thinking I should have taken pictures of my blue fingers — a souvenir of my escapade. Anyway, getting back home was not easy either. Toms creek is not a steep climb, but with all the snow, it was difficult to walk back. And then my toes started hurting. Note to self: no snickers in snow.

Anyway, I kept chugging away. Along the way, one or two people passed by me. Smiling as they usually do in Blacksburg. But there was something about their smile. I couldn’t figure it out untill I got back home. My red cap had turned white, I had a white beard and a grey and moist mustache, snow on my shoulders …. No wonder they were smiling. It seemed as if I had surmounted K2 or something :).

I got back home and changed. After few minutes when blood started flowing to the numb parts of my body (e.g., butt cheeks) I realized what all had frozen.

Nevertheless it was fun. It has been quite some time that I got to enjoy photography. I missed an opportunity in Fall last year. I hope I’ll be able to mange it this year.

The views are amazing. I wish I could teleport everyone so that you could experience the same. See the al

Now I am feeling hungry, it is time to cook dinner. I think I will make biryani and some pakoras perhaps; the occasion demands so.

Categories: photography