Skip to main content


Showing posts from September, 2012

Add arXiv hyperlink to bibtex in under 1 seconds

Add hyperlinks of arXiv numbers to all the bibtex entries in a bib file in under 1 second. This is accomplished by a script.  The user only needs to have a bibtex file which already has the eprint entry for every bibtex item. The rest would be handled by the script.

This procedure is not necessary for some packages and bst files. it becomes necessary when specialized citation packages, like natbib, are used. Natbib generally do not include the hyperlink to the eprint number and some bst files for natbib like pjgsm.bst would completely ignore the eprint field.

The following script would amend this situation. It basically hard codes the hyperlinked arXiv number  into the journal entry. So hen the bibtex is run the journal entry would include the hyperlinked arXiv number. I wrote this script with bibtex from the NASA ADS server in mind. Bibtex from other sources might need some modification.

Critical comments and suggested improvements are welcome.


Search inside text files

When we have many text files such as code samples or research documents then more often than not we want something which is in one of the files but we cannot remember which one. This is when searching inside text files becomes necessary.

There is a one-liner that can do the job.

find . -name "*" | xargs -d '\n' grep -i -A2 -B2 --color=auto "KEYWORD" 2> /dev/null

For example,

$find.-name"*"|xargs-d'\n'grep-i-A2-B2--color=auto"21sma"2>/dev/null./coding/python/stock-python/stock-analysis/ create SMA columns./coding/python/stock-python/stock-analysis/ min_periods starts averaging from day-0 not day-200 so it is always continuous with no initial 200-day gap./coding/python/stock-python/stock-analysis/['21SMA']=stock['Adj Close'].rolling(window=21,min_periods=0).mean()./coding/python/stock-python/stock-analysis/['200SMA']=sto…

How to join audio tracks smoothly in Audacity

Audio tracks can be mixed easily in full fledged video editors like kdenlive or Adobe Premiere but for mixing or joining audio they would not provide the amount of control that audio editors like Audacity provide. The example I am going to show today would demonstrate the range of tools in Audacity that allows us to control the waveform and to mold it to our desire.

Today I am going to take a small track like a small 1 min. clip of storm sound and make a long continuous sounding storm audio clip from it.

STEP 1 : Open file
Open the clip in Audacity.

STEP 2 : Removing unwanted audio portion
There is always unwanted sections of the audio that we have to discard. Select the portion of background noise or unwanted audio.

Press DELETE key.

STEP 3 : Duplicating the track
Now we make a copy of the entire waveform and paste it at the end of the track.

Select the SELECT tool (the one which looks like I). Then select the whole waveform and prss Ctrl+c. Now click approximately at the end of the…

Joining Mp4 Files

The following parts are independent.

PROCEDURE 1 Try the simple one first. Just copy the video and the audio stream.

mencoder file1.mp4 file2.mp4 -ovc copy -oac copy -of lavf format=mp4 -o output.mp4

Sometimes this might not work. Many times the audio copy would fail with the errors like.

Audio format 0x4134504d is incompatible with '-oac copy', please try '-oac pcm' instead or use '-fafmttag' to override it.

In these cases it is better to re-encode the audio with lame.

mencoder file1.mp4 file2.mp4 -ovc copy -oac mp3lame -of lavf format=mp4 -o output.mp4

If we want free format encoding we could also use FAAC encoder (Freeware Advanced Audio Coder.). In this example the video codec used in also a free format to encode to H.264 HD format.

mencoder video1.mp4 video2.mp4 -o video3.mp4 -of lavf -lavfopts format=mp4 -vf harddup -oac lavc -ovc lavc -lavcopts acodec=libfaac:vcodec=libx264

MP4Box -add file1.mp4 -add file2.mp4 output.mp4

If your m…

To convert a video file to HD format

In the following exposition we would discuss the command line procedure to produce videos with HD aspect ratio from normal videos. This would allow the video to fill a HD screen .

NOTE: This procedure will not improve quality of a video. If it is grainy then it would remain grainy in the final result. Changing aspect ratio only allows the video to fit HD screens and not improve its quality. To improve quality you can try smoothing in AVIDEMUX.

There are many GUIs to convert a video file to HD 16:9 format. But I find its best to use the CLI.

STEP 1 : Get video file info We have to get the file to the 16:9 ratio.  To achieve this first obtain video info using mplayer. Just play the video and press ESC immediately upon starting.  Now look at the line starting with VIDEO.
It should say something like this,

VIDEO:  [H264]  640x380  0bpp  29.970 fps  138.8 kbps (16.9 kbyte/s)

The 2nd column would be video codec. 3rd would be resolution. 5th is fps for video and 4th is sound encoding quality…

Save youtube videos from browser cache(new method)

This post supersedes the previous post that I wrote at

A new method have to be used because flash changed the way it stored the cached file. The file is deleted immediately upon creation but a file handle is kept open. This is similar to the situation that if a copy is open in memory and someone deletes the file from disk, upon saving the file the file reappears on disk.

But someone already did the work of writing the procedure down. So I list it here.