Skip to main content

Stupid programming mistake

So I was coding the other day and had some strange behaviour from one of my Python scripts. I was running two boolean checks which update a variable. Both should be |= types, but it turns out a ! character looks incredibly similar (to my tired eyes at least) to the | character which of course is a completely different boolean operator.

  • Before

![wrong]({{ site.url }}/assets/images/wrong.png)

  • After

![correct]({{ site.url }}/assets/images/correct.png)

(node) development on OSX

I love my Macbook Pro, for development and general computing use. Before I purchased it I was a die hard linux user (apart from gaming which is still dominated by windows unfortunately.) My work involves linux1 and I am a committed vim user.

My work colleagues tend to laugh when I say that I want to use my mouse as little as possible, and that I am quite experienced in command line use. It pains me every time I see my office mates reach over to the mouse to click the save button.

This workflow does not translate too well to the Mac; as far as I understand it Apple2 were one of the first companies to introduce guis for their operating systems.

LuaLaTex

Using LuaLaTeX seems like a great idea, inserting the excellent embedded programming language Lua into LaTeX1 code (not really code, a very good mathematical markup language) to help with some of the inconveniences of the language.

For those of you who’ve never worked with LaTeX, imagine a simple markup language like markdown for example. The text looks clean and simple, font style changing and the like is handled pretty seamlessly and does not distract from the experience of writing the text itself.

LaTeX is not like this.

Embedding Python in LaTeX

Combining Python with LaTeX is a powerful combination. It allows for arbitrary code to be executed which either gives the results of expressions, or can be used to embed programatically certain things e.g. the paths of files or images.

By downloading python.sty and including it in a usepackage block, python code can be run.

I was having trouble getting this to work as it seems I was using an invalid version of python.sty. The version linked above works as of the date of this post

Mac keyboard keys with Synergy

Synergy is a great program to control multiple computers from a single keyboard or mouse even without them being plugged in. The only requirement is that theyre on the same local network.

Im sharing my configuration which has my windows desktop as the server, and my macbook as the client. Using a windows keyboard creates some issues with the macbook, so here are the settings I use to map the keys correctly:

Vim is even more amazing than I first thought!

Just today thanks to this answer on SO, I realised that vim can automatically pipe text through a shell command. Just think about that for a second For a simple example you can write python code into a text file, and execute it which replaces the code with the result.

for i in xrange(10):
    print i

Selecting this text with in visual mode (you should all know how to do this) and typing

OS X 10.7 Lion: my thoughts

My first OSX upgrade went well I think. My MacBook Pro is a Mid 2009 model, as the nice new About This Mac (not sure why this is capitalised but never mind) tells me.

New about this mac window

Ive never upgraded a Mac before since my pride and joy came with Snow Leopard installed, the as-of-then most up to date operating system so I had no idea what to expect. Ive been using my Mac for nearly two years now but before that I was a pretty heavy Windows user. My other tipple is Linux, so whatever it was like I was going to be tense and anxious.