Thursday, 15 October 2009

cropping pdfs from terminal

From terminal you can use pdfcrop, which should be installed on most linux systems. As its terminal based it is easier to script.

example

pdfcrop --margins '5 0 5 10' --clip input.pdf output.pdf

Friday, 4 September 2009

Make tar.gz

tar czvf myarchive.tar.gz myfile

Monday, 15 June 2009

Multiple files in gnuplot

Seems obvious now but you can use paste

e.g.

plot "< paste file1.dat file2.dat" using 1:($2/$4) w points

Searching for tabs with grep

I was trying to search for an integer number, which had tabs after is
i.e grep 300 and it would come up with something like
300 -0.0137598 -0.00228325 0.930859 0.932037 -1.04561e+27 -1.73505e+26 7.07363e+28 7.08259e+28 -0.0129162 -0.00224769 0.874459 0.875568 0.00575037 0.00194563 -0.395375 0.396846 1.46282e+24
450 -0.00449249 -0.00663059 0.858427 0.869783 -3.41386e+26 -5.03861e+26 6.52322e+28 6.60951e+28 -0.00415084 -0.00613002 0.795084 0.805603 0.00124869 0.00187794 -0.257016 0.262097 1.46282e+24
etc....


i.e. where there is 300 within any number. To search for 300 i used
grep 300[[:space:]]

Friday, 22 May 2009

Wireless with Linux

This link shows how it is set up using the gnome GUI network manager

http://www.york.ac.uk/services/cserv/net/wireless/help/naslinuxnew.html

Thursday, 2 April 2009

Getting xorg to recognise two GPU's

In Ubuntu 8.10, after installation of the nvidia driver, xorg is unable to decide which card to use. To fix this, login in to a terminal, and then type

sudo lspci grep VGA

On my machine this gave the following output:
02:00.0 VGA compatible controller: nVidia Corporation Device 05e2 (rev a1)
04:00.0 VGA compatible controller: nVidia Corporation Device 05e2 (rev a1)

So to get the xserver working, you need to add the following line oin the device section of /etc/X11/xorg.conf:

Section "Device"
Identifier "Configured Video Device"
Busid "PCI:2:0:0"
Driver "nvidia"
EndSection

Then run:

sudo service gdm restart

to get the xserver working as normal.

Tuesday, 31 March 2009

Bash extract function

Extract function for bash. Put in .bashrc


function extract() # Handy Extract Program.
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via >extract<" ;;
esac
else
echo "'$1' is not a valid file"
fi
}