Skip to main content

Posts

A script to fetch bibliography list from inspirehep by parsing through the latex file citing the references

While writing short scientific papers a major workload is in sorting the reference list. A professional article requires that the references be sorted in the bibliography list in the order that they appear in the main text (and not alphabetically which most LaTeX bst files do). This is a manual task which is laborious and needs to be repeated every time a reference is added. Therefore, it is instructive to write a script which will automate this tedious task. The following script that I wrote will look for the citation tags for the references and then fetch the references straight from the server at inspirehep.net and prepare a reference file for the user to copy. Not only do we no longer need to copy and paste the references manually but the script will also sort the references in the order of their appearance. An example of a citation appearing in the main text ... as it was shown in \cite{Chatterjee:2013daa} that merging black holes may not violate the second law of thermodynam...

sed one liners explained

1. To select blocks of text and select only the first block (match) sed -n '/PATTERN START/,/PATTERN END/p' -n suppress multiple prints or sed ''/PATTERN START/,/PATTERN END/!d' had the same effect. It deletes all lines which do not fall under this REGEXP matching pattern. But this will select ALL blocks which match. Worse if there is PATTERN START and no PATTERN END then sed will go to the EOF and print everything. This is something we do not want. PATTERN START ...... ...... PATTERN END PATTERN START ...... ...... EOF so we have to make it quit after matching the first block. sed ''/PATTERN START/,/PATTERN END/!d;/PATTERN END/q' ; ends the first command and sed starts executing the next set of commands which in this case is match pattern /PATTERN END/ and the command for sed is to quit on encountering this pattern which happens after matching the first block of code. Also see:  http://www.catonmat.net/blog/sed-one-li...

Remove pages from a pdf

Let's say we want to remove the first page of a bunch pdf files. Or there is one particular page that needs t be removed. Or the pages needs to be rearranged. There is no need for professional software for this like Adobe pro. A simple program called pdftk can do the job. Let us say that we want to remove just the first page from the pdf. The following command does the trick. pdftk file.pdf cat 2-end output newfile.pdf More complicated page rearrangement can be done too. Say we want pages 3-5 after page 18. First we save pages 3-5 in file temp2.pdf. Then cut out those pages and save the file in temp.pdf. Now the page 18 is page 15 since we have removed 3 pages from the original file. So we get pages 1-15 in one file and the rest in another. We can then join 1-15 + 3-5 + 16-end and voilà. pdftk file.pdf cat 3-5 output temp2.pdf pdftk file.pdf cat 1-2 6-end output temp.pdf pdftk temp.pdf cat 1-15 output temp1.pdf pdftk temp.pdf cat 16-end output temp3.pdf gs -dBATCH -d...

Eclipse does not run any JAVA programs

Problem : Eclipse does not run any JAVA program because it is not loading any JREs. Window -> Preferences -> Java -> Installed JREs   An error has occurred when creating this preference page. No JREs loaded :( Solution: Solution is to reset the JAVA timezones . 1. sudo apt-get --reinstall install tzdata-java 2. putting the line -Dcom.ibm.icu.util.TimeZone.DefaultTimeZoneType=ICU at the end of eclipse.ini Source:  http://askubuntu.com/questions/186986/eclipse-has-multiple-issues-after-jre-6-openjdk-upgrade/187043#187043?newreg=ce380b31191b40948500f37474958dce

Rsync usage

rsync -varR cara-files/ /media/work/research/coding/cara-files/ rsync  -arv /media/work/research/ -e ssh sukaa@192.168.11.24:/Pdf/back/research/ dry run + delete files that no longer exist. >> rsync -n -arv --delete  /media/work/research/ -e ssh sukaa@192.168.11.158:/Pdf/back/research/ delete files that no longer exist. >> rsync -arv --delete  /media/work/research/ -e ssh sukaa@192.168.11.158:/Pdf/back/research/ rsync  -arv /Pdf/back/research/ /work/research/ RSYNC Local:  rsync [OPTION...] SRC... [DEST] Access via remote shell:  Pull: rsync [OPTION...] [USER@]HOST:SRC... [DEST]  Push: rsync [OPTION...] SRC... [USER@]HOST:DEST Access via rsync daemon:  Pull: rsync [OPTION...] [USER@]HOST::SRC... [DEST]     rsync [OPTION...] rsync://[USER@]HOST[:PORT]/SRC... [DEST]  Push: rsync [OPTION...] SRC... [USER@]HOST::DEST     rsync [OPTION...] SRC... rsync://[USER@]...

Get HDMI sound working in Ubuntu without logging out

It is a known issue in Ubuntu that the when a HDMI cable is plugged in, the sound settings do not automatically show the HDMI sound output option. The only way to make it work was to log out and log back in again with the HDMI cable plugged in. This bug is discussed here: https://bugs.launchpad.net/ubuntu/+source/gnome-control-center/+bug/974963 But the page also lists a very useful workaround thanks to Beltrachi, The idea is to send noise to the hdmi output. $ cat /dev/urandom | aplay -f S16_LE -c2 -r44100 -D hdmi Press Ctrl+c when the noise is heard in the TV. The hdmi should be working now. The sound in the speaker might disappear after the hdmi cable is unplugged. The dosage is similar for this case also. Just send noise to the default speakers. $ cat /dev/urandom | aplay -f S16_LE -c2 -r44100 If that doesn't seem to work then try to select the PC speakers as the output device in the Sound controls.

GRtensor commands

I would try to collect some useful resources for GRtensor package of Maple. I contains a host of commands which are very useful but the documentation is scarce. A good page to learn the applicability of the commands through example is http://www.smf.mx/~dgfm-smf/TallerVI/CursoSussman/hoja2/hoja21.html All GRtensor outputs needs o be simplified one way or another and GRtensor provides specialized routines to accomplish just that. The gralter command does the job instead of the Maple command simplify . http://grtensor.phy.queensu.ca/Griihelp/gralter.help And everyone needs to know the keyboard shortcuts of any program they are using. It makes life efficient. http://www.maplesoft.com/support/help/Maple/view.aspx?path=worksheet%2fdocumenting%2f2DMathShortcutKeys For example, I was unable to enter the Greek symbols for a long time till I found that it is very easy to do so in Maple. Just type the Greek word in Eng...

Using the 3D modelling software Blender3D efficiently

Blender 3D is an excellent tool for building 3D models. It is a free alternative to professional 3D modelling softwares like 3DS MAX and MAYA. I personally found it to be easier to use and more efficient than 3DS MAX. Its shortcuts are easier to remember and the workflow is much more streamlined than 3DS MAX. There are plethora of superbly written tutorials out there on Blender3D so I am not going to go into that. People who are interested in some tutorials can look at  http://en.wikibooks.org/wiki/Subject:Blender_3D I would start with a list of useful keyboard shortcuts which makes the Blender3D experience all the more enjoyable. The following are not a complete list of keyboard shortcuts for Blender3D but they are most useful ones in my opinion.  BLENDER shortcuts Manipulate view select -> right click  pan : middle mouse + shift zoom middle + ctrl rotate view : middle click + drag select multiple object : shift + right click or...

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