Thursday, December 27, 2012

Batch cropping images using Mogrify


The command 'mogrify' can crop multiple images simultaneously. Sample case is below.
mogrify -crop WidthxHeight+x+y        images*.png
mogrify -crop 2796x983+429+327        images*.png
The values of width, height, x and y can be obtained by opening an image in Gimp and selecting the rectangle of interest.

Monday, December 24, 2012

Firefox/Thunderbird already running but not responding

Firefox and Thunderbird can sometimes give this error when you restart a linux box or when you try to make multiple log ins into a shared file system. The result is that Firefox/Thunderbird will not open. The causes for this are not entirely clear to me but I found a solution. Simply delete the .parentlock file in both cases and restart the service. Locations for this file are as follows:
Firefox: ~/.mozilla/firefox/xxxxx.default/.parentlock
Thunderbird: ~/.thunderbird/xxxxx.default/.parentlock
Since both the folders and files start with a dot, they are not visible with a simple
ls -lrt
You have to use
ls -lrta

Saturday, December 15, 2012

Emacs Primer

I decided just a little while ago that it was time I learned how to use a text editor other than vi. Below are my notes as I keep learning more about Emacs.

Open a new file: emacs newfile.txt &

Starting writing in the file.

Save: ctrl x s
Search Forward: ctrl s
Search Reverse: ctrl r

Exit emacs: ctrl x c

Select Region:      ctrl space and arrows
Mark Activate:      ctrl space
Mark Deactivate: ctrl space or ctrl g
Select All: ctrl x (wait) h

Delete Region: ctrl w
Copy Region:   Esc  w
Paste buffer: ctrl y

Delete till end of sentence: ctrl k

Delete line: ctrl S backspace

Delete next word: Esc d

Undo last action: ctrl _ (underscore)

Jump to end of file: Esc >
Jump to start of file: Esc <
Go to line 10: Esc x 10   

List all buffers: ctrl x (leave ctrl) b

Split screen:                                   ctrl x (leave ctrl) 2
Close all but current buffer:     ctrl x (leave ctrl) 1
Close only the current buffer:  ctrl x (leave ctrl) 0

Repeat 9 times: ctrl u (leave ctrl) 9
Type - 9 times: ctrl u (leave ctrl) 9 -

If you start a command and then decide you don't want to complete it, type C-g to cancel it.

http://doors.stanford.edu/~sr/computing/emacs.html
http://www.nbcs.rutgers.edu/newdocs/unx01101/unx01101.php3
http://dept.cs.williams.edu/~kim/cs136/s04/emacs.html

Edit: Dec 28, 2012
I was writing a manuscript in Emacs and the bibtex reference key had a beta symbol which meant that I had to type this into Emacs;   Kheterpal2000Aβ and not Kheterpal2000$\beta$. To do this I copied the following two lines into ~/.emacs and solved my problem. Thanks to this site.
(global-set-key (kbd " a") "α") ; F9 followed by a
(global-set-key (kbd " b") "β")