Converting from Tikz to PNG

Here’s how I did it:

\documentclass[preview,border=4mm,convert={density=600,outext=.png}]{standalone}
 
\usepackage{url}
\usepackage{tikz}
\usepackage{color}
\begin{document}
 
\begin{tikzpicture}
add figure source here
\end{tikzpicture}
 
\end{document}

Then compile using:

latexmk  smr.tex -shell-escape

Squashing git commits

to squash the last n commits (e.g 37) into one

git reset --soft HEAD~37 && 
git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
git push -f

source: http://stackoverflow.com/questions/5189560/squash-my-last-x-commits-together-using-git/5201642#5201642, thanks david

OCaml Development in Vim

This is a quick run-through of how I set up my development environment in vim:

Install pathogen.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

Install Syntastic

cd ~/.vim/bundle
git clone https://github.com/scrooloose/syntastic.git

Then quit vim and used :Helptags to check installs so far have worked.

Install Merlin

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

Quick Guide: Remotely adding a new user on Ubuntu 12.04

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.

$ visudo

Now add the following line to the file that has been opened:

ALL=(ALL) ALL

Now exit the machine and log back in as ubuntu.
You can now switch to this newly created user with
$ su
$ 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

Logout and return to local machine
$ scp -i originalkey.pem ubuntu@:/home/ubuntu/mykey mykeyNow you can ssh into your remote machine as this new user:$ chmod 400 mykey$ ssh -i mykey @url-of-server