Skip to main content

Posts

Small Nifty Dictionary in Python

We all have to look up words in a dictionary at some point or other. Whatever the reason it might be --  maybe because their jobs are text intensive, maybe because they a non-native speaker looking for the right pronunciation dictionaries are indispensible. There used to be some really good dictionary apps 6 years back. Now with google acting as the dictionary, a stand-alone dictionary app is kind of redundant. However these quick visits to google.com can slowly eat into our productive time. So I thought it will behelpful if a small little app sits in the corner of my screen not using any space which can act as a dictionary. So I wrote this app. The full app can fetch word meanings, IPA pronunciation guide and the actual pronunciation audio. The following code snippet implements the pronunciation part only. I have written this to work exclusively in Linux -- the Python code calls a Bash script to grab the pronunciation files from the internet. The choice of bash script is to per...

Merge multiple pdf script

A simple script to merge pdfs. Nothing fancy. It just saves me the time to look up the complex command-line options needed to merge them. To edit pdfs see my previous post  - http://kheyali.blogspot.com/2014/02/remove-pages-from-pdf.html. Just copy the following script and paste in a text editor and save as pdfmerge.sh ------------------------------------------------------------------------------------------------------------------- #!/bin/bash # pdfmerge v 1.0 by JOnes Feb 2015 # a simple script to simplify complex command line options echo "Merges multiple pdfs. Usage : pdfmerge file1.pdf file2.pdf ..... [-o outputfile.pdf]. Without the -o option the defualt output filname is merged-pdf.pdf." gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=merged-pdf.pdf $* echo "File written to merged-pdf.pdf" echo ------------------------------------------------------------------------------------------------------------------- Make the script executable...

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