Vim's built in spell checker seems a little easier than externally using aspell. Firstly activate the feature in Vim
:set spell
Choose your language (for example)
:set spelllang=en_gb
You can add words that are spelled incorrectly (goes in something like ~/vim/en.utf-8.add) by simply going to the word that is highlighted and using the key sequence
zg
to add the word. See
:help spell
for more information.
Wednesday, 2 May 2012
Friday, 20 April 2012
dos2unix on Mac OSX
File conversion from dos to unix files on OSX has always been a bit flaky for me. Handily the tr command in one of two variants does the job:
tr '\r' '\n' < dosfile > unixfile
tr -d '\r' < dosfile > unixfile
tr '\r' '\n' < dosfile > unixfile
tr -d '\r' < dosfile > unixfile
Tuesday, 27 March 2012
Padding for superscript and subscript axis labels in gnuplot
By default gnuplot doesn't align superscripts and subscripts:
But, that leaves an ugly space between the symbol and superscript. You can force alignment with an @ character:
To give the desired result. You can change the factor 0.5 to whatever you need, with 1.0 being full character width.
T_c^{/Symbol \245}
But, that leaves an ugly space between the symbol and superscript. You can force alignment with an @ character:
T@_c^{/Symbol \245}This works fine for standard characters, but for slanted variables, the align character makes the superscript overlap. To fix this we insert a partial before the infty symbol in the superscript. To do this we combine two text effects, blank characters &{a} and font size scaling {/* }:
T@_c^{{/*0.5 &{c}}{/Symbol \245}}
To give the desired result. You can change the factor 0.5 to whatever you need, with 1.0 being full character width.
Tuesday, 20 March 2012
Bash function to wget from user space in york
This can be placed in .bashrc and can be used to get a file from (your username abc500)
http://www-users.york.ac.uk/~abc500
(this is on unix0 in the web directory.
wgetyork ()
{
if [ -f "$1" ];then
rm "$1";
fi
wget http://www-users.york.ac.uk/~abc500/"$1"
}
it checks for the file because wget will save the file you download as filename.1 if you already have a file called filename. Call it using
wgetyork filename
http://www-users.york.ac.uk/~abc500
(this is on unix0 in the web directory.
wgetyork ()
{
if [ -f "$1" ];then
rm "$1";
fi
wget http://www-users.york.ac.uk/~abc500/"$1"
}
it checks for the file because wget will save the file you download as filename.1 if you already have a file called filename. Call it using
wgetyork filename
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
example
pdfcrop --margins '5 0 5 10' --clip input.pdf output.pdf
Friday, 4 September 2009
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
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:]]
i.e grep 300
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
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
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.
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
}
Friday, 27 March 2009
Fixing backspace on edred vim
To fix the backspace key on the vim on edred add this to .vimrc
set backspace=indent,eol,start
Thursday, 26 March 2009
latex figures
To get rid of strange behaviour in latex where it does weird things with figure numbers its has to be done in a strict order.
\begin{figure}
\begin{center}
\includegraphics{...}
\end{center}
\caption{...}
\label{...}
\end{figure}
I think caption can go above \begin{center} but it must be outside of the centre section
\begin{figure}
\begin{center}
\includegraphics{...}
\end{center}
\caption{...}
\label{...}
\end{figure}
I think caption can go above \begin{center} but it must be outside of the centre section
Gnuplot PDF+Latex files
To create a pdf file from gnuplot with latex text do the following:
In the plot use the terminal:
Then convert the eps to a pdf file.
Include the figure using
In the plot use the terminal:
set terminal epslatex
Then convert the eps to a pdf file.
Include the figure using
\input{figure.tex}
Wednesday, 25 March 2009
Printing variables from gnuplot to a file
To output variables such as fitting parameters from gnuplot use.
set fit errorvariables # creates a_err type variables for fitting errorsset print "tmp.dat"print a,a_err,b,b_err
Tuesday, 24 March 2009
Labeling figures in Latex
If labeling of figures has gone wrong in latex it's probably because the \label{} must be at the end of the figure block after the includegraphics and caption.
Compiling OpenMPI with Intel Compilers on Ubuntu
Compiling OpenMPI with Intel compilers can be a bit of a nuisance, and so the following seems to work with version 11.074 Intel Compilers, OpenMPI v 2.8.1 and Ubuntu 8.10:
1) Install The Intel Compilers with defaults
2) Put iccvars.sh and ifortvars.sh into /etc/profile.d, and comment out the lines referring to non 64 bit binaries
3) source /etc/profile
4) Unpack the OpenMPI
5) Run ./configure --with-fortran CXX=icc FC=ifort LIBS=-lstdc++
6) type LANG=C
7) make all
8) sudo make all install
9) sudo ldconfig
10) type mpiCC --showme to verify the compiler wrappers are working correctly
1) Install The Intel Compilers with defaults
2) Put iccvars.sh and ifortvars.sh into /etc/profile.d, and comment out the lines referring to non 64 bit binaries
3) source /etc/profile
4) Unpack the OpenMPI
5) Run ./configure --with-fortran CXX=icc FC=ifort LIBS=-lstdc++
6) type LANG=C
7) make all
8) sudo make all install
9) sudo ldconfig
10) type mpiCC --showme to verify the compiler wrappers are working correctly
Awk Scripting, combining columns
If you have multiple files named filename.< a number > e.g. filename.0, filename.1, filename.2,filename.3 etc then you can take an average of multiple columns using awk as below:
you need to know how many files you have, in this num_files=16, and you need to know the total number of columns per file in this tot_num_cols=13. Here I wanted to average colums 1 and 4. Using the paste command which pastes a number of files to the screen side by side and piping to awk the script will output the average of columns 1 and 4 to a file called anewfile.txt
you need to know how many files you have, in this num_files=16, and you need to know the total number of columns per file in this tot_num_cols=13. Here I wanted to average colums 1 and 4. Using the paste command which pastes a number of files to the screen side by side and piping to awk the script will output the average of columns 1 and 4 to a file called anewfile.txt
paste filename.* | awk 'BEGIN{num_col=4;num_files=16;timecol=1;tot_num_cols} {c=0; for (j=0;j < num_files;j++){c+=$(timecol+tot_num_cols*j)}}; s="0;" i="0;i < ="num_files;i++){s+="$(num_col+tot_num_cols*i)};" > | anewfile.txt
Bash number formatting
Use printf as in c. For zero padding add a 0 infront of the field length, eg: %06i
So to delete more files than rm can handle
So to delete more files than rm can handle
for i in `seq 0 100`; do file=`printf "%06i" "$i"`; echo $file; done
Subscribe to:
Posts (Atom)


