Useful vi commands

January 27th, 2012

some useful vi commands

i  - insert text

I - insert line before cursor

dd - remove entire line

x - remove single character

Esc (key) - To return to command mode after in edit mode.

:x - exit and save

:q - exit and don't save

Copying multiple directories using wildcards on linux

January 27th, 2012

If you had a file structure like

dir1
dir2
dir3
folder

And you wanted to copy all the three directories (and their contents) dir1, dir2 and dir3 into the directory called folder, you use the command

cp -rv dir* folder

Note: I like to use the "v" switch here, meaning verbose, so I know how the copy is progressing

If you then wanted to remove the directories from their original location, you could use the command

rm -r dir*

 

Removing directories and their contents on linux

January 25th, 2012

Use the command

rm -r <directory name>

Stack: How to multiply vectors

January 24th, 2012

Question Variables

x1= [1,1,1]
x2=[1,1,-1]
result1=x1.transpose(x2)
result2=transpose(x1).x2

Question Stem 

<p> Result1= @result1@ </p>

<p> Result2= @result2@ </p>

Output

Result1= 1

Result2= \begin{bmatrix} 1 &1 &-1\\ 1&1& -1\\ 1 & 1 & -1\end{bmatrix}

For more information about the STACK system see stack.bham.ac.uk

sftp or ftp

January 20th, 2012

on linux, use the command

sftp (or ftp) SERVER_NAME

to view the local directory list use lls

to view the remote directory list use ls

to move a file from local to remote use put filename

to move a file from remote to local use get filename

Note: local is the system you ran sftp (or ftp) from, and remote corresponds to SERVER_NAME

Coverting wmv to high quality avi on Linux

December 16th, 2011

run sudo apt-get install mencoder

then use the command  mencoder infile.wmv -ovc xvid -oac mp3lame -xvidencopts fixed_quant=4 -o outfile.avi

fixed quality can range from 1(high) to 31(low). I found 4 was good enough without making the file size too large.

You can then play it using mplayer with the command mplayer outfile.avi

But I found that this cropped the video during playback. Upon inspection in Windows Medai Player I found that the file had been created fine and there was no cropping. I'm sure there is a command line option for mplayer to avoid this but I can't be bothered to look at the moment.

Installing a game from CD in Steam

December 15th, 2011

Exit steam

Insert the disk into the cd drive

Run  "C:\Program Files\Steam\Steam.exe" -install E:

Edit this command line as necessary.

Find out your disk quota on linux

November 2nd, 2011

Use the command

quota

64bit or 32bit on Linux

November 2nd, 2011

Use the command

uname -a

Note: uname -m gives a simplified output

Overlaying two plots in Mathematica

October 10th, 2011

To overlay two plots we use the Show command. In this example I will overlay a plot of a function, f(x), and a list of datapoints.

p1 = Plot[f[x], {x, 0, 5}, PlotRange -> {-1, 1}, PlotStyle -> {Blue, Thick}];
p2 = ListPlot[plotlist, PlotMarkers -> {"image"}];
Show[p1, p2]

Where f(x) is the function and plotlist is the list of x,y coordinates of the datapoints. The placeholder "image" is for the image shown in the plot below. The result is