splee.blog

bring out the geek

The Soda Algorithm

I think the code speaks for itself.

Like any piece of code open to the world, people are at liberty to make forks. Harley did just that, and I prefer his version.

Window Messaging

The building where I work is in an area of new development and Amazon are our neighbours. A lot of the buildings in the area are unfinished but they’re slowly becoming populated; People appeared next door a few weeks ago and they started writing a message in Post-It notes.

post-it-message

Not to be outdone, I decided that Post-Its weren’t a reasonable response from a tech company. Enter the giant QR code.

bigdoor-qr

This QR code points to BigDoor’s website and it works pretty well. I hope the QR code is the reason for the truncation of “are” and the addition of “hi!” in their message; there’s always the possibility they happen to be talking to the floor above.

Using Marks in Vim

I use Vim every day and have been doing so for about 2 years now. I’m nowhere near as efficient as I should be, but the speed at which I can now edit files in comparison to my previous text editor (TextMate, naturally) is pretty astounding to me.

One feature that I use a lot, especially with Python files, is marks.

How to make your life easier

While I’m writing my Python, the number one naviation action I take is when adding imports; moving from the portion of code I’m writing up to the top of the file and back again. Until I found marks, the process was:

  • Remember my current line number
  • Use C-b to page all the way back through the file
  • Add my import at the top
  • Forget my previous line number
  • Search the file for my previous position

Clearly this is a function of my poor short-term memory, but even if I remembered the line number correctly, that’s still a lot of steps; My thought was “there must be an easier way”.

There is.

Now when I open any Python file, the first thing I do is hit m then i. This sets a mark assigned to i at the top of the file, where i stands for “imports”. Now, when I realise I need to add or remove imports my flow is this:

  • Hit m then a. This assigns my current line to the mark at a
  • Hit ’ then i. This moves me to the mark at i (i.e. the top of the file)
  • Do the import thing
  • Hit ’ then a. This jumps me back to my previous position

This seems like the same amount of work, but since there’s no reliance on short-term memory to remember your line number you can learn these keystrokes so they’re assigned to muscle memory; It ends up being a lot quicker.

This trick isn’t just good for Python but for any file where you need to jump around to specific locations regularly.

Despite Vim’s tenure on my system I still feel like I haven’t begun to scratch the surface with this editor. Let me know in the comments if you’ve found any other ways to use marks.

A Fresh Start

My writing has been almost non-existant for the past couple of years and I’m yet to find a real reason why. Maybe I just haven’t had anything interesting to write about. Maybe it’s all Twitter’s fault. It’s probably just a preference for relaxing after a long day at work; work that I pour all my creativity into, leaving little for my own projects.

Whatever the reason, it’s going to change.

I’m setting up a new blog purely for my technical writing here. This blog is powered by Github and the Jekyll engine they provide; simply set up the correct directory structure, push with Git and presto: new blog.

Expect more here in the near future.

Update (2011-02-15): I should mention that my old content is still available on Posterous.