This is a quick run-through of how I set up my development environment in vim:
mkdir -p ~/.vim/autoload ~/.vim/bundle; \ curl -Sso ~/.vim/autoload/pathogen.vim \ https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
Add the following to ~/.vimrc:
execute pathogen#infect() syntax on filetype plugin indent on
cd ~/.vim/bundle git clone https://github.com/scrooloose/syntastic.git
Then quit vim and used :Helptags to check installs so far have worked.
opam switch 4.01.0dev+trunk opam update opam upgrade opam install merlin
Add the following to ~/.vimrc
:set rtp+=~/.opam/4.01.0dev+trunk/share/ocamlmerlin/vim :set rtp+=~/.opam/4.01.0dev+trunk/share/ocamlmerlin/vimbufsync let g:syntastic_ocaml_checkers=['merlin']
:SyntasticInfo will return a list of syntax checkers available to Syntastic, check that this now includes merlin
Install OCP Indent
opam install ocp-indent
Add the following to ~/.vimrc
autocmd FileType ocaml source /home/heidi-ann/.opam/4.01.0dev+trunk/share/typerex/ocp-indent/ocp-indent.vim
Squeeze is the code name Debian gives to the current stable release, wheezy is the name given to the current unstable release
A combo of curl and regular expression, e.g.
Ross Andersons “Security Engineering” is avalaible online under CC here but you must download each chapter as a seperate pdf, this is can the fixed using:
$ curl http://www.cl.cam.ac.uk/~rja14/Papers/SEv2-(toc|pref|acks|c[01-27]|biblio|index).pdf
$ plink -ssh -D 9090 <csid>@linux.pwf.cam.ac.uk
Then connect to socks proxy on port 9090 and local host.
In the following is a quick guide to creating a new user (we will be calling this user “username”) on a Amazon Cloud EC2 instance with Ubuntu 12.04 AMI
CREATING NEW USER
We will begin by adding the new user and setting the new users password
$ sudo adduser
This command will then take you though the setting up a password. You can check the users that you now have my opening the /etc/passwd file
Now we are going to make use of a unix command called “visudo”, this allow you to edit the sudoerrs file in a concurrent access safe way. Before using visudo, we need to check that the default editor is the one that we would like and change it, if required:
$ sudo update-alternatives –config editor
Now you will be given a dialogue where you can select your favourite text editor.
Now add the following line to the file that has been opened:
Now exit the machine and log back in as ubuntu.
You can now switch to this newly created user with
$ cd /home/
GENERATING KEYS FOR SSH TO NEW USER
We are now going to generate the public key for public/private key pair that will be used later to SSH directly into this new user
$ ssh-keygen -b 1024 -f mykey -t dsa
This line has generated two files, the public key mykey.pub and the private key mykey. To be able to ssh from a local machine to the new paws user on this remote machine, we need to place copy the contence of paws.pub into /home/username/.shh/authorized_keys and we need to have a copy of the private key (called mykey) on the local machine
$ mkdir .ssh
$ chmod 700 .ssh
$ cat mykey.pub > .ssh/authorized_keys
$ chmod 600 .ssh/authorized_keys
Now that we have the key we need to transfer this key on to our local machine and generate the private key
$ sudo chown :ubuntu .ssh
$ sudo cp mykey /home/ubuntu
$ sudo chown :ubuntu .ssh/authorized_keys
$ sudo chmod 777 /home/ubuntu/mykey
UCS does a great job of explaining it here:
My aim to reproduce Figure 1: Internet users and non-users by age group (years), 2012 Q3 from the Internet Access Quarterly Update, Q3 2012 from the Office for National Statistics. For this I will be using Octave
1) Download data as xml and convert to csv
2) Read the data into Octave and check this it has been read in correctly
data = data = dlmread(“<my_file.csv>”,”,”);
The expected output will be 8 4
3) Divide the date into the correct axis
x = data(:,1);
ya = data(:,2);
yb = data(:,3);
yc = data(:,4);
4) Plot the new data
5) Label the x and y axis
ylabel(“Percentage who have used the internet”);
6) Give the graph a title
7) Output the graph and save
Learning to escape VIM
I have a confession, the first I launched vim I could not even work out how to quit it so I took the lazy way out and just closed the terminal. This put me right off vim for quite a while. Now its time to really try to learn it.
Vim has two modes: insert and normal, when you launch vim it will go straight into normal mode, from normal mode type i to switch to insert mode and then press ESC to return back to normal mode.
Normal mode basics
You can delete the character under the cursor using x and using :w to save. To cut the current line use dd, this will delete the text on the current line and also delete the line itself, the cursor will move to the next line, which is now where the original line was. To copy the current line use yy. Now to paste the recently cut line, use p to insert the text onto the line below where the cursor currently is or P to insert text before cursor.
Instead of the arrow keys, you can make use of hjkl to move the cursor, but personal I prefer to use the arrow keys
Entering Insert mode
So far we have entered insert mode using i, there are some alternative ways to enter insert mode, which allow you to move to insert mode and perform a useful operation in one key stoke, some of the alternative methods to enter insert mode are:
Moving around normal mode
As well as using the arrow keys (or hjkl) to navigate around normal mode, there are plenty of useful extra shortcuts for navigating around. 0 jumps to first character in the row and $ goes to the last character in the row. ^ jumps to the first non-blank character of a line and g_ goes to the last non_blank character of line.
To search for a particular work or character, use / and enter search term. This will move the cursor to the next occurrence of the search term after the cursor, so to search for the first occurrence of a term in a file, put the cursor at the start of the file and then use / to search for the term.
To jump to the start of the next word use w and to go to end of this word use e, when a word is composed of letters and underscores only, if you want to word to include special characters use W and E instead
Text editor basics
u is used to undo and Crtl-r to redo. To open a file use :e , :w to save, :saveas , to save and quit. :q! to quit without saving. . will repeat last command and N