Skip to main content

Posts

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 / stock - analysis . py - # create SMA columns ./ coding / python / stock - python / stock - analysis / stock - analysis . py - # 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 / stock - analysis . py : stock [ '21SMA' ] = stock [ 'Adj Close' ]...

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...

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 PROCEDURE 2 MP4Box -add file1.mp4 -add file2.mp4 out...

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...

Save youtube videos from browser cache(new method)

This post supersedes the previous post that I wrote at http://kheyali.blogspot.com/2009/11/how-to-save-online-video.html 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. http://liori.jogger.pl/2010/11/08/getting-flash-videos-from-almost-deleted-files/

Non-English characters: How are they displayed

We have come a long way since every time we needed to read some non-English texts we needed to install special fonts in Windows. After I started using Linux I always wondered how does all these types of characters display so perfectly. I knew that it was Unicode. But what I didn't grasp immediately is how the OS can display such an enormous variety of characters. Unicode is not just a character set like we learnt in school. Instead it is an encoding algorithm (in some sense). What it does is that it assigns numbers different basic characters and then any characters can be constructed out of these elementary characters. What happens is that two characters like a and '   are merged to get  รก. People who know LaTeX would instantly realize that this is how LaTeX also works. But this composting is done in the browser directly in the OS itself not as a separate software. This process is called "pre-composition" or "...

How to add and synchronize subtitles

This is tutorial on Adding subtitle to a video clip and synchronizing it correctly.  Shifting the subtitles correctly for out of sync subtitles. Adding subtitle to a video clip Lets say that the video clip is from a movie and we want to cut the subtitles from that portion of the movie and add it to this clip. The only problem is that the subtitles files are written in a continuous manner which makes it difficult to plain cut and paste operation of the relevant section.  The steps involved are -- 1.Get the subtitle file.  2. Get the relevant portion of the subtitle file from the whole srt file and save it in another srt file. If for eg. we want know some words at the beginning and the end we can extract the text from the srt file using grep. Example file : The relevant section is in yellow. 1220 01:53:46,980 --> 01:53:48,140 Father-in-law! 1221 01:54:17,648 --> 01:54:23,780 I'm a foreigner , I came ...

Ubuntu screen lock freeze

Ubuntu screen lock freeze is a OpenGL problem. Fix it by setting  --- Install Compiz Settings Manager: Code: sudo apt-get install compizconfig-settings-manager -Go to OpenGL plug-in & uncheck the Sync to VBlank option. http://www.preshweb.co.uk/2011/05/ubuntu-11-04-x-freezing-after-screensaver-active-laptop-lid-closed/ If you are already into the fix restart X by opening a tty Ctrl+Fn > root login . Type /etc/init.d/lightdm restart for Ubuntu 12.04 or later or /etc/init.d/gdm restart for others. If you are using any other display manager then restart it instead.

Howto play HD clips in PS3

PS3 cannot play HD clips encoded in the matroska format, popularly known as MKV format . PS3 mostly supports MP4 containers with h.264 video and AAC-LC audio. The good news is that the MKV is just a container for H.264 HD format video. Therefore, the video need not be re-encoded. It just have to extracted from the MKV container and pasted into the MP4 container. However, MKV files contain uncompressed audio files in the PCM/WAV format. So these audio files have to extracted and converted to the lossy low complexity AAC formats. The LC in AAC-LC stands for low complexity. It is pretty easy to do. The required steps are same for Linux, Mac or Windows but the softwares used might be different. I would focus on Linux only. The video repackaging steps are taken from  http://askubuntu.com/questions/50433/how-to-convert-mkv-file-into-mp4-file-losslessly . The audio part is mine. 1. Reconnaissance -- Find which channels contain which format.  mkvmerge --ident...