Custom vimrc

There are plenty of pages all over the internet dedicated to provided an ‘ultimate’ vimrc configuration, and although I don’t claim to have the ultimate configuration – I’m throwing mine into the mix too.

Obviously, the ultimate perfect configuration for me won’t be perfect for you, and everyone will want to do things differently but you can use the following as a rough guide to extend or modify as you wish. (more…)

Read More

Quickly list all files recursivly

More hackery today with this dirty little script to print out all files within a directory recursively. This is by no means perfect; any directory that includes a period/full stop (.) will be treated like a file, and any file that doesn’t include an extension (.txt, .jpg, .php etc) will be treated like a directory and ignored. Hey, I told you it was dirty.


find . | grep -Pv "^\.\/\." | grep -v ^\.$ | grep -Pv "^\.[^.]*$"

That’s obviously a little hard to remember so as always you can download the program here and place in /usr/bin or /home/user/bin.

Literally the only reason this came about is because I wanted to see how many lines of code I’d written – now I can find out by simply running


wc -l $(findall)

For anyone interested, it was 1507.

 

Read More

Kill a process running on port x (Ubuntu)

Recently I’ve started running into an annoying issue at work where I try and run a program which happens to already be running, because this program is bound to port X, it won’t start.

Obviously, this shouldn’t be a problem – locate and kill the process, restart the program, job done. And now it’s even simpler since I’ve discovered this lovely one liner;


sudo kill $(sudo lsof -t -i:3000)

Simply replace 3000 with the port you’re looking for and your sorted!

Read More

SCP commands for reference

SCP (secure copy) is a command which allows you to transfer files from one machine to another using SSH and is an extremely useful tool. Unfortunately the documentation can be a little confusing; the syntax for this command is:

scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port]  -S program] [[user@]host1:]file1 [...] [[user@]host2:]file2

And so I’ve documented some uses of the command here for future reference, which I will update as necessary.

(more…)

Read More