You Need A ‘Go’ Command

If you study your command line history, you’ll probably notice that you often do something like this.

cd somedirectory/

This is incredibly inefficient. Why write two separate commands just to change your directory and list its contents? You need a ‘go’ function which does both.

In your .bash_profile file (usually located in your home directory), add these lines.

go () {
 cd "$1";

Et voila! You now have a ‘Go’ function. Its usage looks a little bit like this.

Screen Shot 2013-06-18 at 12.57.28

I’m a Vim convert, and so should you.

It’s not especially rare for people to extol the virtues of their preferred text editor. Programmers are especially famed for their fervent adoration of their chosen one, and will defend its honor with every iota of their being. The fierce rivalry between Vim and Emacs users feel like the type you’d only usually see at the Glasgow derby between Rangers and Celtic.

Until this week, I had treated my text editor as little more than a vehicle for dumping characters into a text file, which I would then execute or compile. I generally used Sublime Text 2 when I was working on major projects where I would need to work on multiple files or would require syntax highlighting. For those times where I’d only have to make a small edit to a single file or I wanted to use a minimalistic editor, I’d whack open Nano.

But then I started my new job. I very recently started work at a local startup where pair-programming is used a lot. For the uninitiated, pair programming is where two people will work on one problem using one computer. The person writing the code is called the ‘driver’ and the other person in the pair is called a navigator. As I needed to get some familiarity with the codebase, I was the person driving for most of last week and the person who was ‘navigating’ encouraged to give Vim another go. I did not regret it.

After just a few short days, Vim has rapidly became my text editor of choice. In fact, I love it so much I’ve decided to write a blog post about why you should give it a try. So, what’s Vim and why is it so awesome?

Vim was created in 1991 by the Dutch computer scientist Bram Moolenaar. It borrowed heavily from the Vi text editor, but Moolenaar thought there was room for improvement. He created his own text editor and called it Vi Improved, or Vim for short. It goes without saying that vim is one of the most pervasive editors on the market right now, and is included on most Linux distributions and with every copy of Mac OS X. It’s also been ported to Microsoft Windows too.

Fundamentally, Vim is a text editor. With that said, it differs from most text editors in a few ways. Vim has three modes. Input mode, where you insert text into a file. Normal mode, where one can perform commands that perform actions on the text on your screen. Finally, there’s command mode, which handles a miscellany of other functions including writing to disk and temporarily changing the configuration of vim without diving into a configuration file.

This is all well and good, but what’s so compelling about Vim that makes it better than most other text editors?

Primarily, Vim is immensely configurable. Each installation of Vim has its own configuration file. This allows you to set up how it handles things like line numbering, tabbing and autocomplete. For a programmer, this is huge. These configuration files are portable, so whenever you reinstall your OS, you just have copy your ‘.vimconfig’ file over. It also has a wealth of plugins which fundamentally extend its functionality. Right now, I’ve been doing a lot of Coffeescript, so I’ve a plugin installed that has Coffeescript syntax highlighting and linting, as well as a few others, the most notable being Syntastic.

Another way Vim excels is with its built in Turing complete scripting language. Yep. That’s right. Vim is scriptable. This allows the user to create plugins and to have a huge amount of control with regards to its behavior. It’s probably worth noting that there’s an amazing Vimscript tutorial online based upon Zed Shaw’s Learn Code The Hard Way series. The language itself isn’t much of a departure from most scripting languages you’ve probably seen. Syntactically, it resembles a weird hybrid of Bash and Python and if you’ve ever used these languages before, it will feel incredibly familiar.

Since using Vim, I’ve landed upon the conclusion that Vim is simply ergonomically superior to pretty much every other text editor out there. You are encouraged to avoid navigating using the arrow keys; The preferred method is using ‘hjkl’. Whilst this sounds alien to a lot of people, it’s worth noting that your right hand no longer has to move down to touch the arrow keys. The end result is that your hands are moving around far less and both hands are centered on the alphabet keys, where they rarely move from.

If you’ve ever developed in a language where whitespace and indenting matter (Coffeescript and Python, for example), you’ll know how frustrating it is to modify your code and then have to manually fix the indenting just so that it’ll work in the interpreter.

Sorting out indenting in Vim is simply a matter of entering ‘normal mode’ and typing the number of lines you want to indent and then adding ‘>>’. Deleting a line is just a matter of typing ‘dd. To go down to the bottom of your document, just type ‘G’. Vim accommodates for every single piece of formatting you’ll need to do as a programmer, and has evolved to contain a simple way of doing it.

That’s the beautiful thing about Vim. People use it and make it better. There are few use-cases that can’t be resolved by typing just a few characters. It’s simply a matter of knowing how to use your text editor. That takes time, but the end result is totally worth it. You’ll be more productive and less frustrated.

Nothing good ever came easy.

Breakerfaire – 14/05/2013 – Why Embedded Security Matters

Embedded Systems are ubiquitous. From the systems that control our cell phones and aeroplanes to ATMs, they’re everywhere. In this Breakerfaire meeting, Irish security enthusiast and Alastair O’Neil will be talking about security issues in embedded systems with an emphasis on router hacking.

Alastair is an inquisitive chap. From an early age, he’s constantly had a desire to take apart things and see how they worked. Now, he spends his days studying Computer Science at Liverpool Hope University and freelancing as a software developer and security engineer.

Breakerfaire is a semi-regular security meetup that takes place in Liverpool, England. The next meeting will be held on the 14/05/2013 at  7pm in DoesLiverpool.

What Now?

I frequent the Learn Programming subreddit quite a bit. I’ve found it’s helped me out a great deal, and I’m always really, really happy on the rare occasion where I’m able to help someone else out. One question I’ve seen crop up time again is ‘What Now?’. ‘Where do I go from here’?

It’s common for people to go through the Javascript course on Code Academy, or to work through Michael Hartl’s Rails Tutorial and have absolutely no idea where to proceed when they’ve finished them.

The (amazing, albeit sometimes frustrating) thing about programming is that it’s huge. Really huge. Just imagine the most incredibly vast thing you can think of, and then double it. That’s programming. When you’re a programmer, you’ve got to accept as a given that you’re in for a lifelong learning experience.

That in itself is really daunting. The vastness of the field of computer science is almost as great as the vastness of space. So, in this blog post I’d like to talk a bit about where you can go once you’ve completed one of the many introductory programming courses that are floating about online.

Foolish Assumptions

Firstly, I’m going to make a bunch of assumptions about who you are. I’m going to assume that you’ve got the basics of programming down (variables, arrays, flow control, functions) and that you’ve enjoyed learning how to code. I’m also going to assume that you want to progress further, and hopefully start a career as a computer programmer. Seem fair? Okay then.

Learn Some (allegedly) Boring Stuff

A lot of these introductory Python/Javascript/Ruby courses neglect some really important stuff. Stuff that isn’t immediately sexy, but is actually really useful. Things like algorithms and data structures.

It might seem a bit tedious now, but you’ll probably benefit a great deal in the long run. Plus, it’s really for learning how sorting algorithms work, and how you can use mathematics to find the shortest path.

Daniel LaMire blogged about the top five algorithms he knows. That article is worth checking out just for the comments. Also, the University of Auckland in New Zealand has some good lessons on their website, where they give an introductory look at data structures and algorithms. Well worth a look.

Hang Around With Smart People

I live in Liverpool, and my local hackerspace is DoES Liverpool. They regularly have events that are open to the public, and they also offer really affordable hotdesking. What’s great about DoES Liverpool is that the people who go there are always friendly and insightful. I’ve learned a lot just by hanging around with people who are older (and smarter) than I.

If your city has a Starbucks, odds are good it has some variety of tech community or a hackerspace. Show up to one, and strike up a conversation with someone who you’ve never met before or attend a talk. You might learn something!

Attend A Hackathon

Hackathons are great ways to meet cool people, and work on cool projects. The way Hackathons work is you crowd into a room that’s stocked with coffee, fruit and pizza, and separate yourselves into small groups. You then pick a project and start coding. Simple as.

Quite often, the motives behind a hackathon are quite altruistic. People work on projects in order to improve the quality of life of other people. Two examples that immediately spring to mind are the Social Care Hack Day and the NHS Hack Day.

incidentally, the Social Care Hack Day is happening next week. If you’re in Liverpool and want to work on projects that benefit that actually help people, drop the organizer a tweet.

Learn A Framework

So, you’ve learned Javascript and you want to expand on what you know? Learn a framework. I’m not much of a Javascript guy, but I’ve heard great things about Knockout, Backbone and Ember. If PHP is your thing, consider Zend or Symfony. Apprentice rubyists would likely benefit from learning  Rails or Sinatra.

Frameworks are good, because you get exposed to a lot of concepts that you’ve perhaps never come across before, like MVC and (possibly) OOP.

Make Something

If you want to be a programmer, you have to practice that skill. If you don’t, your ability to code atrophies. With that said, it can be hard to think of a project on the fly.

If you’re thinking of getting into web-dev, you might want to write a simple web application. An application to make a to-do list, or a Twitter clone, perhaps. If you want to get into games development, have a play around with SDL and create a simple application where you move a shape around a canvas. Start simple, and build up.


So, you’ve made something cool, or learned something new. Tell the world about it! There’s evidence which suggests that writing about a subject aids the learning process, and guess what? Writing is fun. It’s really gratifying to see solidify on the screen, concepts and ideas that you previously struggled with. It’s also really gratifying to help other people.

What About You? 

I’m really interested in how people learn to code. Seriously. It’s fascinating. If you’ve ever been in the position where you’ve completed an online course on programming and wondered where to go next, I’d love to hear from you. Drop me a comment below and tell me about your experiences.

Enjoy This Article?

You might want to subscribe to this fine blog that you’re currently reading. Leave your email address in the box on the sidebar, and you’ll get an email whenever I write a new one.

A Quick Bit Of Code I Hacked Together

I’m currently working on my MVP for my game, and I’m not focusing on artwork, for the sake of getting game mechanics down. I wanted to have a simple CLI utility that could take in some parameters and produce a bitmap image.

So, I wrote one. In Java. It didn’t take me too long.

You can grab it from my Github page. I also included an autogenerated ANT file in case you want to build it yourself. I’ve never used ANT, so it might not work. If it doesn’t, drop me a comment below.

The way you use it is simple. You run it with the following parameters: Width, height, color and the filename of the outputted image. Width and height are both integer values, and color has to be either ‘red’, ‘blue’ or ‘green’ and in lowercase.

So, if you wanted to create a red, 10×10 box which outputted to hello.png, you’d run the program with the following parameters: 10 10 red hello

It’s nothing too flashy. Just a great example of using programming to do jobs that would otherwise be tedious and mundane. It’ll also save me from having to open up illustrator or paint. Which is welcome, indeed.