2007-02-28
MacFUSE 0.2.2
Another MacFUSE release, with bugfixes and sample filesystem source code. Get it here.
Replace AppleScript with Ruby
There's a great article on replacing AppleScript with Ruby at O'Reilly's MacDevcenter here.
2007-02-21
Ugly hack to use AppleScript to present a dialog from a bash script, and get their choice.
I am reposting this from my old blog because a coworker ended up needing this. This has only been tested on 10.4, though nothing in it is all that special.
I was trying to slap a prettier interface onto a bash script for a client. I only bothered to use an AppleScript instead of just sending it to Growl because I needed them to be able to make a choice that I’m going to act on in my script. Even if it was just for display, I didn’t particularly want them to have to install Growl just for my little script.
This is ugly because I had to use a temporary file to store the AppleScript to display the dialog. It is also ugly because we can’t just display the dialog – we get an error message if we try – but we can tell another application to display the dialog. I picked System Events because it’s always running anyway.
This method also allows us to use a program-generated message instead of something static.
And just for the heck of it, I stuff the name of the button the user clicks into a variable, in case you want to use this snippet to display choices for the user.
I was trying to slap a prettier interface onto a bash script for a client. I only bothered to use an AppleScript instead of just sending it to Growl because I needed them to be able to make a choice that I’m going to act on in my script. Even if it was just for display, I didn’t particularly want them to have to install Growl just for my little script.
This is ugly because I had to use a temporary file to store the AppleScript to display the dialog. It is also ugly because we can’t just display the dialog – we get an error message if we try – but we can tell another application to display the dialog. I picked System Events because it’s always running anyway.
This method also allows us to use a program-generated message instead of something static.
And just for the heck of it, I stuff the name of the button the user clicks into a variable, in case you want to use this snippet to display choices for the user.
#! /bin/bash
msg="Giant cracks appeared in the earth’s surface!"
# use $$ here so that the process ID of this script is part of the file name.
# this makes it a lot harder to accidentally step on another instance
# of the script that’s trying to also display something to the user.
tf=/tmp/ziggurat$$
# note that there should be 3 lines between EOF and EOF, in
# in case this is mangled by blogger
cat>$tf <<EOF
tell application "System Events"
display dialog "$msg" with icon stop buttons {"Foo", "Bar", "OK"} default button "OK"
end tell
EOF
foo=`osascript $tf | awk -F":" ’{print $2}’`
echo "foo: $foo"
# don’t forget to trash the temporary file when we’re done with it.
rm $tf
2007-02-20
2007-01-26
MacFuse
Amit released the Macintosh port of FUSE at MacWorld, which lets people write filesystems that don't require kernel code. Greg Miller has written a great sample filesystem for it, SpotlightFS.
2007-01-25
Easy way to create services on OS X
ThisService is an extremely handy tool for creating services on OS X. Any script you have that reads from STDIN and writes (if appropriate) to STDOUT can be easily turned into a service.
2007-01-16
Google hosting the blog now
Switched to having blogger host my blog under my domain and it has been painless. I don't have Google control my dns, so I can have other hosts on this domain, but after a single CNAME in my domain, I get to have Google still host the blog while it's visible as somewhere in my domain.
2007-01-05
Coolest. Lego. Ever.
This has got to be the coolest Lego gadget I've ever seen.
I wonder how many mindstorms bricks it took to make - I think I counted 6 in the video, but I'm sure I could have missed some more.
I wonder how many mindstorms bricks it took to make - I think I counted 6 in the video, but I'm sure I could have missed some more.
2006-12-31
Tab completion and syntax hilighting for irb
Frank Spychalski posted how to use wirble to get syntax hiliting and tab completion in irb here.
Subscribe to:
Posts (Atom)
Creative Commons License
This work is licensed under a Creative Commons License.
Copyright 2007-2010, Joseph P. Block, Some Rights Reserved.
