Posted by jpb
Tue, 28 Feb 2006 01:43:00 GMT
Apple has a quick introduction to using Ruby on Rails on OS X at http://developer.apple.com/tools/rubyonrails.html.
Covers everything from installation of the toolchain to a nice tutorial that includes using migrations to create and update the database schema.
Overall, a great article for Rails n00bs, even non-Apple using ones.
Posted in OS X, Ruby on Rails | Tags OSX, Rails | 1 comment
Posted by jpb
Fri, 17 Feb 2006 19:52:00 GMT
I was trying to slap a prettier interface onto a bash script for a client a few weeks back. 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 don’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.
Code after the break.
<!-break->
#! /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 the forum
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
Posted in OS X, Applescript | Tags AppleScript, Bash, OSX | no comments
Posted by jpb
Fri, 17 Feb 2006 09:59:00 GMT
CodePoetry.net has an installer for Volker C. Behr’s CUPS-PDF backend module for CUPS (Mac OS X’s printing system) that prints straight to PDF files here.
It’s handy because it generates PDF files in a folder on your desktop, and even gives them useful names.
Posted in OS X | Tags CUPS, OSX, PDF | 1 comment
Posted by jpb
Wed, 15 Feb 2006 01:33:00 GMT
I went to update the mysql extension for Ruby with gem, and got the following error:
[jpb@athena:~/svn/external/typo]$ sudo gem install mysql -- --with-mysql-lib=/sw/lib/mysql --with-mysql-include=/sw/include
Attempting local installation of 'mysql'
Local gem file not found: mysql*.gem
Attempting remote installation of 'mysql'
Building native extensions. This could take a while...
can't find header files for ruby.
ERROR: While executing gem ... (RuntimeError)
ERROR: Failed to build gem native extension.
Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/mysql-2.7 for inspection.
ruby extconf.rb install mysql -- --with-mysql-lib=/sw/lib/mysql --with-mysql-include=/sw/include
I’ve been working on other projects for a while, and it’s been a while since I tinkered with Ruby. I’ve updated my powerbook to 10.4.3 and XCode 2.2 since the last time I did anything with gem that wasn’t pure Ruby, so this was puzzling me since I’d documented how I got it to build the last time, and was using the exact same command that worked a few months back.
Google to rescue though, it turns out that a bunch of header files that used to be searched for in /usr/lib/ruby/1.8/universal-darwin8.0 are now expected to be in /usr/lib/ruby/1.8/powerpc-darwin8.0, and of course, aren’t, so gem can’t build the extension any more.
Fortunately this is easily fixed with
cd /usr/lib/ruby/1.8/powerpc-darwin8.0
sudo ln -s ../universal-darwin8.0/* ./
Anyway, posting it here so Google can find it.
Posted in OS X, Ruby, MySQL | Tags MySQL, OSX, Ruby | 1 comment