TextMate Makefile Bundle

Posted by matt
on Saturday, August 01

Recently, I’ve needed to write and use various Makefiles. I was disappointed to find the TM’s syntax highlighting lacking, and just not colourful enough, so I set about adding a few bits and pieces.

You can find the result on GitHub.

I was pleased to find that most of the official TM bundles are now there, so if you’re making small (or massive) tweaks and improvements, it’s should now be easier than ever to get your changes merged into TM proper.

My Favourite Software

Posted by matt
on Thursday, April 09

After what seems to have been a super-successful macheist, I thought that now was a good time to describe my all time favourite Mac software. So, here’s a list of the best bits: the ones that I probably couldn’t live without:

TextMate

This is probably obvious, but an extensible editor is one very useful way of turbo charging your computing life. Once you’ve learned how to use it, you’ll find that you can automate simple jobs away, leaving you free to focus on getting things right, and done.

I use project plus, and a shed load of bundles. GetBundles is probably the most notable, as it lets you easily stay up to date, and get new ones.

Terminal.app

Apple’s terminal is nice and powerful. I augment this power with Cairan Walsh’s magical plugins Blurminal, and Terminal colours. The first lets you add a nice Guassian blur to your terminal, making it easier to distinguish between your terminal’s text, and whatever you have behind it, and the second lets you use aesthetically pleasing colours. I prefer Tango colours, which you can find in gnome-terminal, and copy to Terminal.app.

In my terminal I have zsh. But then if you’ve been here before, you know that!

I heartily recommend from Bash to Z Shell, hence the following affiliate link:

Firefox

My browser of necessity is Firefox. I’ve seen several posts about Firefox being left behind by newer browsers, like Chrome and Safari. Whilst this is true with regards to many things, look and feel in particular. I’m hoping that Firefox 3.5 will improve the javascript side of things: 3.1b3 is already considerably faster that 3.0.7.

The killer firefox feature is, of course, extensions. The extensions I can’t live without are:

ExpanDrive

I realise that there are free alternatives, but ExpanDrive is awesome. It’s rock solid, and lets you treat SSH servers as disks.

LaunchBar 5

I was late enough to the Mac party that I missed the massive Quicksilver buzz. Now, I find it too unstable to use. LaunchBar on the other hand, is great. It’s like a supercharged spotlight, and once you’re used to search templates, you’ll be addicted forever. LaunchBar 5 is still in beta, but is now available to buy. The price is a bit steep, but worth every penny.

Little Snitch

It pays to be paranoid. Little Snitch lets you set custom blocking rules. The practical upshot is that whenever something wants to access the ‘net, you know about it.

Other Stuff and Conclusions

I snapped my menu bar so you can see other things I use. Menubar-annotated

I used Little Snapper, which was in MacHeist, and appears to be fiarly similar, it is actually pretty damn cool, but not as fluffy as skitch! It can upload to sites via SFTP, which I how I included this.

I got Coversutra in a previous heist, and I’m completely addicted to it, which is why I haven’t let LaunchBar take over.

Twitterrific is another must. It’s unobtrustive, and help make twitter what it should be – there’s no point in reading peoples tweet 9 hours after they happened! EventBox is an interesting alternative, but I still find Twitterrific more slick (for now).

Makerfaire_uk: In a DIY frame of mind

Posted by matt
on Monday, March 23

I was lucky enough to visit Newcastle Upon Tyne for the Makerfaire_uk this March, and since then I’ve been brimming with ideas, and feeling the need to make things. This post is partially here to demonstrate that I am, in fact, still alive, and to show off a couple of little things I’ve made.

First, I got a p8tch. This self proclaimed commando nerd patch is an embroidered QR code, which links to a configurable tinyurl style redirect. My first act of making was to sew this onto my Timbuk2 Hacker bag. Here’s a picture of the result:

Timbuk2 Hacker with p8tch!

Unfortunately, I don’t have QR enabled phone (yet), but I tested it by stealing my mothers :).

Next, whilst in Newcastle, at the Makerfaire (during time which I snapped some pics). I bought a tvbgone kit, which I built. This is a subversive little thing which switches of TVs. Lots of them. It also has a range of about 45 metres, and knows 46 different IR remote control codes. I intend to have a lot of fun switching off TVs in shops with this. Here’s a macro shot I took using a screw on +10 filter, and my 50 mm lens:

completed tvbgone

In other news, I hope to start posting content to zshbits.com once I’ve finished my thesis, and had time to create some more screencasts. If anyone’s interested in contributing, mail me, or comment with disqus.

Learning Perl (and Perlcritic for TextMate)

Posted by matt
on Thursday, February 19

Now, just just leave straight away, but I’m learning perl. I know I’ve only just started waxing lyrical about python, but bear with me, I’ve not got any plans to dump anything else: I just need to learn perl for work. (If you read on in this post, you’ll find some ruby code, too!)

So, armed with some of the ideas from comments on my last post, I’ve tried to build make use of some of the most trendy web resources to help me on my way. Ideally, I’d like to pick up on best practices as I go along.

information overload

So far though, I’m not having a huge amount of luck. I’ve worked through learning perl, and I’ve finished reading it feeling like I don’t know anything like the whole story. To be perfectly honest, I’m quite surprised at the complexity of what seems like a small language!

I’ve got a huge pile of books to help though, so I’m going to start digging through programming perl, and setting myself programming goals. My aim is to work out how to write simple modules and unit tests by the end of next week. I’d also like to find some rake/paver equivalent, and work out how to effectively use Devel::REPL (which stackoverflow helped me find.) Soon I’ll have my automation / test safety net at the ready, so things can proceed a little faster.

Whilst casting around, I found Perl::Critic, a module (and front-end) for checking your code’s adherence to best practices (incidentally, there’s a great book called perl best practices – another one on the pile!).

I decided to write a TextMate command for the perl bundle to run code through perlcritic, since there isn’t one. After a little help from the bundle developers mailing list, I came up with the following:

To run this, you will need a new copy of the TextMate Support directory. I’d suggest using GetBundles. I’ve sent a patch to the perl bundle to the ML, but in the mean time, if you paste the above code into a bundle command, set the scope to source.perl, and trigger to ⇧⌘C, you should get it working fine.

Update: I’ve just started reading programming perl, and I wish I’d started with it! I’m already feeling like I’m learning more useful stuff than was contained in learning perl. I guess I’m not the target audience of that, but I wish I’d known last week!

Best Practices and Patterns

Posted by matt
on Sunday, February 15

Listen to this post

One of the things I’ve noticed during the course of my studying for my PhD is that there’s is a gulf between knowing how to do something, and knowing how to do in a way that’s acceptable to others. I think that this gulf is one of best practices.

If that’s not clear, then let me illustrate it with an example. I believe that almost anyone can do research which is suitable for publication (honestly, anyone!), but the actual process of publication is far more difficult (I’m speaking as someone who without a huge amount of experience in this area).

To have work published, you must follow a complex sequence of both explicit and implicit rules. These rules represent the best practices of scientific writing, and without knowing how to follow them, even if you don’t know what they are, you will have a hard time getting things published.

This process boils down to ‘learning how to play the game’ or pick up the idioms, and seems to generalise to almost every other problem domain – at least those that I’ve come across.

Does my description above sound familiar to you? I thought so. Maybe you’ve tried to commit to a well established open-source project; you probably had to study the coding style, look at how tests were implemented, maybe even learn how they use source code management.

In my experience, a normal part of any learning process, perhaps even more important that the initial, and traditional learning stage, is finding out how things actually get done. I’m hoping that by building finding out about this kind of issue into my learning processes, I’ll be able to get to a useful state, one where my output is usable by others, quicker, and perhaps not have to unlearn bad habits which I picked up when I started out.

How do you find out about best practices? How do you build them into your learning processes? Let me know in the comments below.

Adverb Detection in TextMate

Posted by matt
on Tuesday, February 10

After seeing lifehacker, I was inspired to add an adverb detector to TextMate’s markdown grammar, since that’s the format I use to write blog posts.

Far from being a couple of hours work, this was dead simple, and involved adding a couple of tiny bits to the grammar, here’s how to do it:

First, fire up TextMate’s Bundle Editor, press ⌃⌥⌘B. Then scroll to markdown, expand it, and find the Markdown Language grammar. This will be marked with a small grey L. Add the following to the repository section:

    adverb-detector = {
        name = 'invalid.adverb';
        match = '(?!\b(supply|apply|family|only|prolly|folly|sully|rally|waverly|reply|early|probably)\b)\b(\w+ly)\b';
    };

Now scroll to the section headed inline, and add:

    {   include = '#adverb-detector'; },

To the patterns part. Finally, check you have a rule called Invalid in your TextMate theme, with the scope selector invalid. This rule is used to highlight a multitude of sins, so it’s probably already in your theme. Mine looks like this:

invalid_selector
Uploaded with plasq’s Skitch!

adverb_detection.mdown

Static Site Generation

Posted by matt
on Tuesday, February 10

There seems to have been a recent glut in static site generators. It looks like you can pick your templating language, and find a generator to go with it. Recently, I discovered hyde via the github blog, and decided it was worth trying out on a project I’m working on. That project is zshbits, a tutorial/screencast site for ZSH. I’ll be unveiling some zshbits content soon (for now I’m waiting for a cold to let up, so I don’t sound quite so nasal, and a new microphone) and readers here will be the first to know.

Recent versions of hyde, which is a fork of any-cms, have support for typogrify, a must for pretty posts, a sitemap generator, and other goodness. If, like me, you’re looking for something lightweight, which supports markdown, it’s probably worth taking a look. It’s probably also a good way of learning about django templates.

Comment Strangeness

Posted by matt
on Friday, February 06

As my blog still has a slightly dual personality, you might not see your comments listed in under the article in which you commented. This is because disqus uses the referrer to link comments to the articles, which means it things my-mili.eu and hackerific.net are different. Well, they aren’t, but please note that they’ll only be listed if the url begins with hackerific… sorry for any inconvenience!

My MacHeist Release Estimate

Posted by matt
on Friday, February 06

Like a lot of mac users, I get excited about MacHeist, and why not, it’s fun and a good bargain.

Since we’re snowed out of work, and a MacHeist Bundle release seems imminent, I decided to hack up a quick script to find out how wide the progress bar thing is, and use that to estimate the release time. Here’s what I’ve been up to for the last half hour or so:

MacHeist: Mainframe
Uploaded with plasq’s Skitch!

I used BeautifulSoup with urllib2 and a tiny regular expression, and here’s the result:

I’m running it in a simple shell loop:

  while true; do sleep 60; python heist_parse.py >> heist_countdown; done

Which is collecting the width every minute (that doesn’t seem too often).

Now that I’ve had this loop running for a while I’ve got 34 data points, so I can do a bit of simple linear regression, with scipy. Here’s a graph:

macheist_release_estimate
Uploaded with plasq’s Skitch!

And here’s the code used to do the regression, and generate the plot.

It’s important to remember that this is based on the assumption that the bar is full up at 500 pixels wide. This may or may not be reasonable.

If it is though, I’d tentatively estimate that the bundle will be release at 3AM (GMT) on the 7th Feb 2009. You read it here first!

Update: Well, it looks like they cheated! Here’s a graph of the bar’s length with time:

Rounded up!
Uploaded with plasq’s Skitch!

As you can probably see, it was rounded up. Ahh well. So much for the estimate!

Paramiko: Scripting SSH with Python

Posted by matt
on Friday, February 06

Python Scriptable SSH

For a simple way of remotely administering machines, over SSH, with Python, have a look at paramiko. You can grab it using easy_install, which can itself be grabbed from PyPi, and installed using sudo sh easy_install_filename.egg.

Here’s a simple script I rustled up, based on the tutorial. It fires up mediatomb, on my server microwave:

If you don’t like using password-less sudo, don’t worry, it can cope with that too. That’s what the second half of the gist above does.

So, if you use SSH for any kind of repetitive system administration, give the article a read, and give paramiko a try.

Screencast: LaunchBar, BibDesk and Google Scholar

Posted by matt
on Tuesday, February 03

I spend quite a bit of time looking for references on Google Scholar, and decided to see what I could do with LaunchBar 5 to make my life easier. Here’s a quick screencast to show what I’ve got going on:


LaunchBar, BibDesk and Google Scholar from Matt Foster on Vimeo.

If you view this video on vimeo you can see it in HD goodness.

Git Ready and the ZSH Prompt

Posted by matt
on Friday, January 30

Git is one of those programs, like, say vim, which contains more functionality than it seems humanly possible to grasp. Thankfully, there are sites like gitready, which are designed to help us mere mortals to grasp the awesomeness.

I’m very pleased to be able to report that a bit of awesomeness that I’ve been involved in has been listed. Have a look at the ZSH Git Status page and you might see what I mean. That’s right: zshkit is mentioned.

If you’ve not read any of my other posts on it, zshkit is a project, started by Bryce “BonzoESC” Kerley, and forked by various people (I think I just had the honour of being the furthest up the network graph).

Over the next few days, I’m hoping to implement the vcs_info stuff mentioned in the git-ready comments.

Hackerific is now Disqus enabled

Posted by matt
on Friday, January 30

I’ve just enabled disqus support in the blog template. Now, instead of the mephisto form, you should see a disqus one.

I’m hoping this should speed up the commenting process, and make it easier for discussions to happen. So please, comment away!

Migrated RSS Feeds

Posted by matt
on Sunday, January 25

I just discovered that it was time to migrate my feedburner RSS feeds to google, so I did. Hopefully nobody will notice, anything different, but please drop me a line if you do!

If you aren’t subscribed to hackerific’s RSS feeds, then why not subscribe now? You won’t regret it :)

ZSH Abbreviations

Posted by matt
on Friday, January 23

Abbreviations are ZSH feature I just stumbled across, whilst proselytising about GRML, a cool linux distro.

Here’s a snippet to show you the ultimate power they offer:

OK, so it may not make much sense as it stands, but bear with me. Suppose you want to get some information about the size of the directory tree you’re in. Now, you want to use something like du -sch, traditionally, you might have alias da='du -sch' in a config. file, but what if you want to edit it at the last minute. The abbreviation lets you do just that. If you type da,., the ,. trigger expands the abbreviation to give you du -sch on the command line, and then you can further edit the command, to add that extra x, or whatever, afterwards. This is obviously a somewhat contrived example, but the effort saving, productivity enhancing idea is still there, and it fits in well with the ZSH philosophy, or my version of it at least.

To see what I mean, look at the magic-space command. If you use:

    bindkey ' ' magic-space

Then use history, or some other shell expansion, it will be fully expanded when you hit space. Did you miss the colon on the end of that scp command three lines ago? No problem, hit !-3␣, add it, and hit return. It feels similar to the abbreviation mechanism above, and is very powerful too.

It’s worth noting that the original sighting of this trick doesn’t seem to be compatible with the ‘magic-space’, since it rebinds space.

You can find all of this, and more, in my zshkit.