Archive for the ‘geek’ Category

Using awk to format strings

Awk is a programming language, which I only use in it’s most basic form. Quite often I need to format a few lines of text, as is the case with an OD password reset script I’m working on. (more…)

New Terminal tab with pwd

Just a quick snippet I’m using to open a new tab in Terminal. It accepts a single, optional argument which will override cd’ing to the working directory.

#!/usr/bin/env bash
 
if [[ $# -eq 0 ]]; then
	dir=`pwd`
else
	dir=$1
fi
 
/usr/bin/osascript \
-e "tell app \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down" \
-e "tell app \"Terminal\" to do script \"cd $dir\" in front window" \
-e "tell app \"System Events\" to tell process \"Terminal\" to keystroke \"l\" using control down"

I’ve put the shell script in “/usr/local/bin” as this is in my $PATH. I’ve named the script “tab” so whenever in Terminal I can enter “tab” to open a new tab with the current working directory ready and waiting. Very useful when working with Rails and multiple shells.

Plists in Ruby

I’m currently working on tweaking Apple’s lazy GUI design by alphabetising VPN connections in both System Preferences and the VPN Connection menu. This is definitely only intended for Leopard and I wont be testing it in Tiger or supporting it. It’s just for my own personal use as I have 40 odd VPN connections. The initial proof of concept code is below. I still need to work on getting things to work reliably and smoothly. (more…)

Installing yum and git on a MediaTemple (dv) 3.5

I recently decided to install Git on my (dv) 3.5 and found an article written by the guys at MediaTemple, my hosts, with instructions on how to do it (isn’t it nice when someone else does the hard graft for you?!) Unfortunately, the article was old and inaccurate. Luckily, with a bit of digging around I managed to get yum installed, updated and ready for Git. (more…)

Modified CSS Bundle for TextMate

If you use TextMate when you’re coding for the web you’ll probably have at least tried out Jim Jeffer’s CSS Bundle, which was inspired by an article by Jina Bolton. If not check it out!

When I first downloaded it I was impressed but not exactly blown away as the snippets don’t really leverage the true power of TextMate’s bundle system. I had to get to work to make things a lot smoother. (more…)

My must have iPhone apps

Since the release of the iPhone 2.0 firmware I’ve become a stubble covered hobo with a taste for £1.99 tipples. After having an iPhone for several months the initial lust started to turn in to more of a comfortable facet of every day life. But thanks to the App Store, my relationship with my darling iPhone has been revitalised. And now, the sex has never been better! (more…)

puts Ruby.in_colour!

When I’m making a script for someone I always think it’s nice to add a bit of colour to anything output by Ruby. Not to be garish… We don’t want command line filth reminiscent of Geocities after all! But if there’s an obvious exception that ends our fun it’s good to highlight that. (more…)

Repair permissions on network home folders

I had a problem to fix a few months back where by something like 1000 users had totally bricked their home folder permissions. Trying to propagate permissions from Workgroup Manager (it was a 10.4.11 server) kept hanging and would only fix home folders up to the letter “d.” It was at this point I was called in to write a script so a colleague could repair the permissions without running the risk of annihilating the home folders from the command line. (more…)