signal0

VIM Crosshairs

VIM is my editor of choice. I’ve tried a few others, but I’m too used to using vi keybindings (I even use them for command line editing in bash) and so I have a really hard time walking away from it.

Since I write python code, indent levels become very important. I try to keep my functions nice and short, but sometimes when looking at other people’s code I’ll find long functions and it becomes increasingly hard to tell which indent level I am at or should be at.

A useful way I’ve found for dealing with this is by having crosshairs that cross over where my cursor is. The best way to expalin this is by an example, so here it is:

../../../_images/vim_crosshairs.jpg

Setting this up is actually pretty easy. The full explanation of it can be found on the vim wikia site. The way I have it setup is almost exactly like the example they give - when you hit ‘c’ the crosshairs are toggled on or off. To get that going, put the following in your .vimrc or your custom colors file:

hi CursorLine   cterm=NONE ctermbg=235
hi CursorColumn cterm=NONE ctermbg=235
nnoremap <Leader>c :set cursorline! cursorcolumn!<CR>

Checking git commit message format before commit’ing

UPDATE: You can’t actually use the python script directly as your commit hook due to the need for a TTY. Instead I’ve updated these instructions with a way to call it from a simple shell script which provides a TTY. Sorry for the misinformation!

Seems like I’ve been on a ‘style guide’ tear lately. Once I got git yelling at me when I tried to check in non-pep8 compliant code a coworker of mine pointed out that git commit messages have a ‘style guide’ of sorts. Of course now I needed to make sure that my git commit messages were good as well.

Fortunately the style guide for git commit messages is pretty simple, so I wrote my own really basic checker. If you’re interested, keep reading.

Read more...

Keeping bash history forever

I spend a lot of time in a terminal. More specifically, I spend a lot of time in bash - being a sysadmin/developer type guy kind of necessitates it. One of my favorite features of most modern shells is the fact that they record the commands you run, allowing you to easily repeat commands or to go back and look at how you did something.

What’s even better is that bash saves your history to a file whenever you logout of your shell. While that’s awesome, it’s little less awesome that the size of your history file is limited (dictated by the HISTFILESIZE environment variable, by default to 500 lines, at least on Mountain Lion). There are tons of times when I go to look back through my history and the command I needed was missing because of this.

The problem becomes even worse when you have multiple terminals open.

Wouldn’t it be awesome if after every command that command was dropped in a file? What if there was no limit to the # of history lines you could record? What if you could record other useful data, like say what directory you were in when you executed the command, the time you executed it, and what its return code was? Finally, wouldn’t it be sweet if you could easily add notes to that history file?

If you answered yes to any of the above, then look no further!

Read more...

Comments now work!

Thanks to Vlad Riscutia for putting out a hotpatch (and new release) of Tinkerer that fixes the Disqus bug issue signal0 now has comments. This may actually end up being a bad thing, but I still want to thank Vlad for being so responsive on this awesome piece of code!

Calibrating i(phone|pad|pod) home button

I’ve had an iPhone for a long time, and this year got the iPad. I love my Apple toys, but one thing that’s been driving me nuts about my iPhone for the past few months is that the ‘home’ button seems to have become less responsive. It’s really frustrating, and I thought at first that my poor iPhone 4 was on its last legs. I figured I’d be stuck dealing with this till Apple FINALLY released the iPhone 5.

When it started happening on my new iPad I was livid, so I went ahead and looked around online. Sure enough there’s a way to fix it, and it worked perfectly for both my iPad and iPhone.

Check it out: http://www.redmondpie.com/how-to-recalibrate-iphone-home-button-to-make-it-more-responsive/