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.


Read More

Scrape Bing using Perl

In my last article I discussed the different techniques that could be used in order to scrape Google’s search engine without being detected. This week we’ll be looking at creating a script to scrape another popular search engine – Bing, using the API which Microsoft provide. It should be noted that Google also provide an API; which allows you to make 100 queries a day (approx 3000 / month); compared to 5000 queries a month with Microsoft Bing.

Using the API is certainly the recommended method for scraping results from either search engine, and the previous article should only be used for education purposes. Wink Wink.


Read More