24/11/2008

The odds are good that you have to keep track on how much time you spend on any individual project for billing reasons or what have you. If you’re anything like me (and why wouldn’t you be) your fantastic right hemisphere of the brain makes you profoundly sucky at performing this dreary task.
Enter On the job, a quite wonderful little app that’ll do the job for you. However; If you are afflicted to the degree I am with this complete and utter incompetence at important but boring chores, you have difficulties even remembering to open the app to let it do it’s thing. ‘Why Martin, it’s simple’, I hear you exclaim, ‘you just put it in your start-up items, so that every time you start up your work computer it’ll launch the app!’ Well, no. You see, I use a MacBook which I carry between the office and home, and my innate loathing of shit starting up each time I start up my Mac would annoy me to no end. Besides, a more than likely scenario would be me quitting the app when going home and then forgetting to start it up again when I’m back at the office. Yes; I’m that terrible.
I considered this while in the shower, as these things are wont to happen, and came up with the idea of trying to make my laptop sniff out which wi-fi I was connected to and thusly be able to perform certain tasks based on that information. I started trying to work out whether it’d be possible to AppleScript a solution, or whether I’d have to try and apply my nigh-non existing Cocoa skills to pull this off.

Ask and ye shall receive. Of course, if there’s a good idea to be had, most likely someone beat me to it. Enter Marco Polo.
This absolute gem of an app promises (and in the 30 mins I’ve used it; Delivers) context awareness for your Mac based on a whole load of criteria. For my purposes all I had to do was to make it sniff out the SSID of my office Wi-Fi and launch On the Job whenever the rule matched. I’ll also be setting it up to launch MediaLink when at home so that I’ll instantly start streaming media to my PlayStation. Yet these examples are just the tip of the proverbial iceberg. The possibilities are, perhaps, not endless but certainly numerous. I highly recommend checking out this killer combo, or just Marco Polo if your short term memory is better than mine (not hard) but context awareness might be interesting for you anyway.
On the job is shareware ($25) and Marco Polo is free as in speech and beer.
24/09/2008
I realize that I’m late to the party with this, but so far all the examples I’ve seen have been a bit overkill for my needs, so I’m putting this out there in case someone else might have some use for it.
Of course,
is a Flash developers best friend. Hell, I sometimes feel I’d be happier if I never had to go beyond the output panel, but that’s neither here nor there. The trace statement however, as beautiful as it may be, doesn’t help you a lot when you’re debugging the project in the browser, and therefore Adobe created
to let you output the traces to Firebug. But calling
1
| ExternalInterface.call("console.log", args); |
every time you want to output something is a pain in the ass, and going through your code to change all your trace calls to ExternalInterface calls is an even bigger pain in the ass, and therefore developers created various methods to ease the pain. Here is the very lightweight solution I use myself.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| package no .martinjacobsen .utils {
import flash.external.ExternalInterface;
public class XTrace {
public static var enabled:Boolean = true;
public function XTrace (){ /*...*/ }
public static function log(...args :*) : void {
if(enabled == true) {
if(ExternalInterface.available){
trace("ExternalInterface is available")
for (var i :uint = 0; i < args .length; i ++){
ExternalInterface.call("console.log", args [i ]);
trace(args [i ]);
}
} else {
trace("ExternalInterface is not available")
for (var j :uint = 0; j < args .length; j ++){
trace(args [j ]);
}
}
} else {
trace("Set 'XTRace.enabled = true;' to enable traces.");
}
}
}
} |
As you see this class simply checks whether ExternalInterface is available, and if so traces the output to the console. If ExternalInterface is not available the statement will just be traced. As a bonus you can also set
to disable all traces if you don’t want to go through your code to remove traces, or go into the publish settings to strip them out.
Usage is extremely simplistic:
1 2 3 4 5
| import no.martinjacobsen.utils.XTrace;
XTrace.log("Hello World", 42, false, myObject);
XTrace.enabled = false; //Disable all traces |
10/09/2008
Summary: In which Martin ponders solutions on how to quickly switch themes in TextMate and comes up with a half-assed AppleScript / TM Command solution. Jump to the half-assed solution.
Edit: As these things usually go I had a bit of a revelation just minutes after posting this post. Completely by accident I typed the keystroke ⇧-⌃-⌥-T, which of course is mapped to the “Select Theme” – command in the Experimental Bundle and which I had completely and utterly purged from my mind. I’m pretty sure you want to use that solution rather than the one I outline in this post, but I’ll keep this around for posterity’s sake anyway. Original post follows.
I’m about to start teaching a 5 week class in ActionScript 3 and if there’s any possible way to avoid it, I won’t spend much time in the IDE code editor, because frankly; It sucks. So in order to make the differences between what the students will see on the screen (You guessed it. TextMate.) and what they’ll be working in themselves, at least initially, I played around with one of the themes in TextMate to make it look more like the Flash IDE editor.
From my beloved Twilight theme:

To this IDE clone based on IDLE:

So since I’ll keep using my main theme for all my professional work I wanted a fast way of switching between the two themes (I’ll do a lot of work to save myself from dealing with a drop down menu). A bit of googling (actually a fair bit of googling) turned up this gem from a spanish speaking TextMate google group. Now, before you even start; Yes I feel slightly dirty about GUI-scripting as well. Making a script that simulates clicks rather than one that just tells the OS to perform whatever task associated with said click just feels wrong. But since not even a journeyman when it comes to the arcane arts of programming TextMate I’m just going to bite the bullet until someone (you?) comes up with a better solution.
Read the rest of this article »
6/08/2008
I’ve been using Yojimbo, for a long while now but Eystein has been pestering me to give Evernote a shot. Common for both of these is that you don’t want to spend any time when you’re dropping stuff into them. I want one key that’ll toggle the visibility of the app. I want to hit my hotkey, dump stuff in, hit my hotkey again and continue what I was doing. Of course, neither of these apps come with that functionality (Well. Yojimbo does come with a “Quick input”-window, but for some reason I never got to loving it.) so here’s an AppleScript to fix that.
Just change the name in the script to whatever app you want to target, create a Quicksilver trigger for it and Bob’s your uncle.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| on run
tell application "Finder" to set en to name of first ¬
process whose frontmost is true
if en = "Evernote" then
tell application "System Events" to set visible ¬
of process "Evernote" to false
set notHidden to false
else
tell application "System Events" to set visible ¬
of process "Evernote" to true
activate application "Evernote"
set notHidden to true
end if
end run |
I’m really enjoying messing around with AppleScript these last few days. For such a light-weight language the benefits of it commanding the OS are huge.
1/08/2008
Summary: In which Martin has created an AppleScript to remedy Firefox’ poor support for
OmniFocus‘ “Send to inbox” hotkey. This is a lengthy post with lots of dreary explanations, so you might want to
jump to the finished script if you don’t care about how stuff works.
Edit: An alternative version brings up your Quick-add dialog and populates it. Check this comment if that sounds more appealing.

To get this to work you’ll need Quicksilver. But you’ve got that haven’t you? Sure you do.
I’m trying out OmniFocus nowadays for my obsessive-but-not-GTD-level organizing needs. It’s still a tad overkill for what I need, but they have the best iPhone sync so far, and I assume I’ll just be assimilated into the cult of David Allen sooner or later so what the hell.
One of the things I like about OmniFocus is the “Create Clipping” functionality. OmniFocus allows you to at a keystroke (♥) send whatever text is currently selected to your Inbox as a clipping.
However this isn’t working in Firefox 3. Mozilla practically stripped all the scripting abilities in v2 and i suppose that’s what goes for a “feature” nowadays. This needs some serious fixing. Let’s get our hands not-really-dirty-but-maybe-a-bit-smudged.
Edit: I’ve updated the script with a new version that also grabs the URL of the clippings origin.
Read the rest of this article »