The guys over at Toxic Software have released a freeware Spotlight plugin to handle Python source code.
Very sweet, lets you search for stuff in comment strings, function names, all sorts of goodness.
2005-05-26
2005-05-25
Ruby on Rails & MySQL on Tiger
First, see the previous blog entry to fix your Ruby install to be able to make proper binary extensions. You're going to need to build a mysql extension for Ruby later.
If you haven't already done so, install XCode (it's on the Tiger DVD), and fink. If you've only just installed fink, make sure you do a
Those will take a considerable amount of time if you haven't run them before.
Now you need to install MySQL. You can either do it from the bare tarball, or use a package manager like fink or darwinports. I like fink, so do:
and let fink grind away at all the assorted dependencies mysql needs. This will take a while, MySQL is big.
Now that MySQL is installed, we can install rails -
Rails doesn't ship with an adapter for MySQL. We install it like so (this should be one line)
so that it can find the mysql libraries fink installed earlier. Note that the -- --with-mysql-include is supposed to be there, that isn't a typo.
You can now go find one of the Rails tutorials like the one Vincent Foley has at http://darkhost.mine.nu:81/~vince/rails/tutorial.html and get started with Rails.
If you haven't already done so, install XCode (it's on the Tiger DVD), and fink. If you've only just installed fink, make sure you do a
fink selfupdate
fink update-all
Those will take a considerable amount of time if you haven't run them before.
Now you need to install MySQL. You can either do it from the bare tarball, or use a package manager like fink or darwinports. I like fink, so do:
fink install mysql mysql-client
and let fink grind away at all the assorted dependencies mysql needs. This will take a while, MySQL is big.
Now that MySQL is installed, we can install rails -
sudo gem install rails
Rails doesn't ship with an adapter for MySQL. We install it like so (this should be one line)
sudo gem install mysql -- --with-mysql-lib=/sw/lib/mysql --with-mysql-include=/sw/include
so that it can find the mysql libraries fink installed earlier. Note that the -- --with-mysql-include is supposed to be there, that isn't a typo.
You can now go find one of the Rails tutorials like the one Vincent Foley has at http://darkhost.mine.nu:81/~vince/rails/tutorial.html and get started with Rails.
Fix Ruby problem on 10.4
I've wanted to experiment with Ruby on Rails (the same technology behind Backpack) for a while now, but ran into a problem when I tried to install it on my 10.4 machine. Rails installs with gem, no problem, but I couldn't get gem to build the external libraries Ruby needs to interact with MySQL.
Fortunately, the kind folks at technoblog made a script that does all the fixes you need to get your Tiger Ruby to properly make binary libraries.
Fortunately, the kind folks at technoblog made a script that does all the fixes you need to get your Tiger Ruby to properly make binary libraries.
2005-05-24
Tiger Mail cleanup
When you upgrade from Panther to Tiger, Mail converts the old format mbox files & indexes to .elmx files and spotlight indexing. To be safe, it doesn't delete the old files in case you want to roll back. It also doesn't update them though, so they're kind of worthless spacewasters.
Here's a list of commands to clear out the Panther grime. Make sure you have a backup of ~/Library/Mail, of course. Each line starting with find should be a separate command in a Terminal window.
Running this saved me 3G of disk space.
If you don't make a backup before running this and this nukes your email, it's your fault.
Here's a list of commands to clear out the Panther grime. Make sure you have a backup of ~/Library/Mail, of course. Each line starting with find should be a separate command in a Terminal window.
find ~/Library/Mail -path "*.imapmbox/Cached*" -exec rm -v '{}' ';'
find ~/Library/Mail -path "*.mbox/mbox" -exec rm -frv '{}' ';'
find ~/Library/Mail -path "*.*mbox/content_index" -exec rm -frv '{}' ';'
find ~/Library/Mail -path "*.mbox/table_of_contents" -exec rm -frv '{}' ';'
Running this saved me 3G of disk space.
If you don't make a backup before running this and this nukes your email, it's your fault.
2005-05-23
Nice Advanced Spotlight Tutorial
ScribeNT has a nice tutorial up on how to use the advanced query features in Spotlight at http://www.scribent.com/osx/xtip/comments/tiger_spotlight1/.
He covers stuff like using the Raw Query option to do boolean searches like "files with X but not Y" that you can't do easily from the simple query window.
He covers stuff like using the Raw Query option to do boolean searches like "files with X but not Y" that you can't do easily from the simple query window.
2005-05-22
Broadcast Flag Redux
Hollywood is trying to get legislation passed to reduce the functionality of HDTV. They want to be able to mark shows as unrecordable so we can't timeshift them any more.
The EFF has more information about this, and a form to automatically fax your congressman here.
The EFF has more information about this, and a form to automatically fax your congressman here.
2005-05-19
Fun with fingerprints
Someone's written a howto on creating false fingerprints, suitable for fooling commercial grade fingerprint sensors here.
Defeat a Kensington laptop lock
Joy. So much for leaving my laptop unattended at Borders when I want to use the restroom.
See the pathetically easy details on unlocking a Kensington laptop lock here.
See the pathetically easy details on unlocking a Kensington laptop lock here.
2005-05-17
Automator and shell scripts
So I was writing my first Automator workflow, and found a bug in the "Do shell script" action. I was trying to write a workflow to iterate over the selection in the finder (and any files in subfolders of the selected files) and use SetFile to change the type and creator. This seemed easy enough, except that it turns out when Automator converts a list of files to strings to hand off to the shell script action, it doesn't properly quote them.
Thanks to Mike Ashley from the Automator-users mailing list for the following code snippet that works around this:
Just put a "do applescript" stage ahead of the "do shell script" stage, and put the above code in. It'll take the list of file aliases and convert them to properly quoted paths for the shell script to act on.
Thanks to Mike Ashley from the Automator-users mailing list for the following code snippet that works around this:
on run {input, parameters}
set output to {}
repeat with i from 1 to length of input
set x to item i of input
set output to output & {quoted form of POSIX path of x}
end repeat
return output
end run
Just put a "do applescript" stage ahead of the "do shell script" stage, and put the above code in. It'll take the list of file aliases and convert them to properly quoted paths for the shell script to act on.
Fixing 10.4.1's issues with GPGMail
10.4.1 semi-breaks the GPGMail plugin. To fix it,
The plugin should work again. Note that we're using 1 and not YES (like the plugin docs for 10.4.0 said).
According to the mailing list, if you follow the previous directions from the dmg, and set BundleCompatibilityVersion to 1, that triggers the new Mail in 10.4.1 to complain and disable the bundle.
- run Mail, let it disable the plugin
- quit Mail
- rename the Bundles-disabled back to Bundles
- Open Terminal
defaults write com.apple.mail EnableBundles 1
- restart Mail
The plugin should work again. Note that we're using 1 and not YES (like the plugin docs for 10.4.0 said).
According to the mailing list, if you follow the previous directions from the dmg, and set BundleCompatibilityVersion to 1, that triggers the new Mail in 10.4.1 to complain and disable the bundle.
2005-05-16
Cool web service of the day
I've been tinkering with Backpack, lately. Backpack allows you to dynamically create web pages, which can contain notes, todo lists, text, images and/or files. You can embed HTML markup. Now, while this doesn't seem all that special (why not just use mediawiki?) to the hardcore geeks, what makes it cool is that it has a nice clean web interface to everything - and you can email items to your pages. This is something I'd have no problem recommending to my non-techie friends.
I'm not really doing it justice in this summary - go sign up for a freebie account (they won't host images or files for freebie accounts, and you have a limited number of pages) and try it for yourself.
This is another service from the same guys who did BaseCamp and TaDa Lists, so you know it's going to work well.
I'm not really doing it justice in this summary - go sign up for a freebie account (they won't host images or files for freebie accounts, and you have a limited number of pages) and try it for yourself.
This is another service from the same guys who did BaseCamp and TaDa Lists, so you know it's going to work well.
2005-05-15
Foreign Spam
I've been seeing a lot more foreign language spam the last few months, and have created a mail rule to nuke it all before applying any of my other couple of hundred rules.
Basically, the rule is set to delete any messages when the Content-Type header contains any of the following strings:
charset="koi8-r"
charset="gb2312"
charset="GB2312"
charset="ks_c_5601-1987"
charset=iso-2022-jp
charset="iso-2022-jp"
I don't speak any of those languages, so all messages encoded in them are spam, as far as I'm concerned. If you know of more charsets to nuke, please leave a comment.
Basically, the rule is set to delete any messages when the Content-Type header contains any of the following strings:
charset="koi8-r"
charset="gb2312"
charset="GB2312"
charset="ks_c_5601-1987"
charset=iso-2022-jp
charset="iso-2022-jp"
I don't speak any of those languages, so all messages encoded in them are spam, as far as I'm concerned. If you know of more charsets to nuke, please leave a comment.
Simple automator plugin to add spotlight tags
Adam Rice has a nice howto for creating an automator plugin to add spotlight tags to a file at http://www.adamrice.org/eponymous/2005/05/add_spotlight_t.html.
2005-05-11
DMCA update
Our congresscritters are looking at reforming the DMCA and formally legalizing circumventing copy protection as long as your use of the copy is legal. The EFF has set up a page that will allow you to fax & mail your congresscritter to support this, at http://action.eff.org/site/Advocacy?id=115.
Go let your congresscritter know you support this.
Go let your congresscritter know you support this.
2005-05-08
Launchd and anacron Howto
I used to run anacron on my laptop in 10.3 so that I could run the daily/weekly/monthly maintenance tasks at appropriate intervals, but without having to have the laptop awake at any specific time. Anacron allows you to specify that specific tasks run every N days, and every time it runs, it checks each job to see if it's been long enough since the last run, and runs it if appropriate. This worked out quite well - I had anacron tasks set up to run the daily script every day, the weekly every 7 days, and the monthly every 30 days. I had cron set to fire up anacron every 15 minutes, and all was well.
Until 10.4, anyway. 10.4 introduced launchd, which replaces cron, and Apple no longer started cron as part of the boot process. I had a lot of maintenance tasks that I was running with anacron via cron though, and while it was easy enough to make an old-style StartupItem to launch cron, I wanted to do the right thing.
Anyway, after experimenting with plutil and launchctl a bit, I figured out how to get launchd to run anacron every 15 minutes. It isn't all that complicated, if you're familiar with XML, but in the interest of sparing other people the hassle, I'm documenting it here.
Presuming you've used fink to install anacron, you can cause launchd to run anacron every 15 minutes by creating a file called /Library/LaunchDaemons/net.sourceforge.fink.anacron.plist with the following contents:
Once you've created the file, all you need to do is use launchctl to load it, by typing sudo launchctl load /Library/LaunchDaemons/net.sourceforge.fink.anacron.plist in a Terminal window. Or reboot.
To change the interval, change the 900 above to whatever number of seconds you want launchd to wait between invocations.
If you don't want it automatically running as soon as you boot up in addition to every 300 seconds, delete the RunAtLoad key, and don't forget to delete the <true/> argument as well.
If you didn't use fink, change the /sw/sbin/anacron to the path you installed anacron on.
If you get an error message when you try to load the file with launchctl, you can use plutil to check the syntax by typing plutil lint org.debian.anacron.plist - if it isn't exactly correct, launchd will complain and refuse load your job.
And if you're using anacron to run the periodic tasks like I am, you can keep them from getting re-run at the regular time by doing the following commands:
Until 10.4, anyway. 10.4 introduced launchd, which replaces cron, and Apple no longer started cron as part of the boot process. I had a lot of maintenance tasks that I was running with anacron via cron though, and while it was easy enough to make an old-style StartupItem to launch cron, I wanted to do the right thing.
Anyway, after experimenting with plutil and launchctl a bit, I figured out how to get launchd to run anacron every 15 minutes. It isn't all that complicated, if you're familiar with XML, but in the interest of sparing other people the hassle, I'm documenting it here.
Presuming you've used fink to install anacron, you can cause launchd to run anacron every 15 minutes by creating a file called /Library/LaunchDaemons/net.sourceforge.fink.anacron.plist with the following contents:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.debian.anacron</string>
<key>ProgramArguments</key>
<array>
<string>/sw/sbin/anacron</string>
<string>-s</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>LowPriorityIO</key>
<true/>
<key>Nice</key>
<integer>1</integer>
<key>StartInterval</key>
<integer>900</integer>
<key>WatchPaths</key>
<array>
<string>/sw/etc/anacrontab</string>
</array>
<key>ServiceDescription</key>
<string>anacron service</string>
</dict>
</plist>
Once you've created the file, all you need to do is use launchctl to load it, by typing sudo launchctl load /Library/LaunchDaemons/net.sourceforge.fink.anacron.plist in a Terminal window. Or reboot.
To change the interval, change the 900 above to whatever number of seconds you want launchd to wait between invocations.
If you don't want it automatically running as soon as you boot up in addition to every 300 seconds, delete the RunAtLoad key, and don't forget to delete the <true/> argument as well.
If you didn't use fink, change the /sw/sbin/anacron to the path you installed anacron on.
If you get an error message when you try to load the file with launchctl, you can use plutil to check the syntax by typing plutil lint org.debian.anacron.plist - if it isn't exactly correct, launchd will complain and refuse load your job.
And if you're using anacron to run the periodic tasks like I am, you can keep them from getting re-run at the regular time by doing the following commands:
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.periodic-daily.plist
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.periodic-weekly.plist
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.periodic-monthly.plist
Then do sudo launchctl list to make sure they aren't showing up.
The plist file is available 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.