Saturday, April 26, 2008

Mac OS X Leopard and MySQL 5 Preference Pane

If you have to use MySQL within a Leopard, and you've tried to install the preference pane (that allows you to start and stop the daemon without typing long path names on a terminal), you may have also discovered that it can't work. But that's old news, as some nice guy fixed this, and posted a working preference pane for your downloading pleasure right here. Fetch it while it's still hot! :)

Friday, April 25, 2008

AppleScript and Asus WL500g Premium

Greetings! Today I'm sharing a small script to add to those amazing folder actions your mac supports. Let's say you have an Asus WL500g Premium wireless router. Goo choice, btw! :). Let's say you've made the jump from original firmwares to oleg's precious replacements. (Yet another great choice!). Let's also assume you've connected an USB external drive to the router, and configured it to serve torrent files it receives by sftp automatically, placing the result in a specified drive path (as explained here). Finally, and specially since you're still reading, it's fair to assume you have a Mac OS X :).

So jump in. Start Script Editor, create a file and type in the following:

on adding folder items to this_folder after receiving added_items

tell application "System Events"

set torrent_files to every file of folder (this_folder as string) whose name extension is "torrent"

set torrent_files_names to the name of every file of folder (this_folder as string) whose name extension is "torrent"

end tell

if length of torrent_files > 0 then

set theServer to "<your-server-address>"

set theUser to "<your-username>"

set theProtocol to "sftp"

set theUploadFolder to "/tmp/harddisk/torrents/source/"

with timeout of 300 seconds

tell application "Cyberduck"

set theBrowser to (make new browser)

tell (theBrowser)

set encoding to "UTF-8"

connect to theServer with protocol theProtocol as user theUser with initial folder theUploadFolder

repeat with theFile in torrent_files

upload item (theFile as alias)

end repeat

disconnect

end tell

quit

end tell

end timeout


tell application "System Events"

delete (every file of folder (this_folder as string) whose name extension is "torrent")

end tell

tell application "GrowlHelperApp"

register as application "Wl500gPremium" all notifications ["Torrent Upload"] default notifications ¬

["Torrent Upload"]

end tell

tell application "GrowlHelperApp"

repeat with i from 1 to number of items in torrent_files

set torrent to item i of torrent_files_names

notify title "Torrent " & i & " of " & (length of torrent_files) & " was sent to Asus:" description ¬

torrent icon of application "Transmission" with name ¬

"Torrent Upload" application name "Wl500gPremium"

end repeat

end tell

end if

end adding folder items to


Take a look, configure theServer, theUser and theUploadFolder, and save the script. then go to your download folder, right click it, attach a folder action and choose the script file you've just saved. Now go ahead, look for your favorite freeware torrent (like this). And have fun! Feel free to comment out any kind of notifications (I enjoy Growl very much), and to replace CyberDuck with your AppleScript-enabled sftp uploader of choice (beware of their syntactic intricacies). As a free tip, I'll tell you it's great to have firefox open up the save dialog for each torrent. You can save it to the download folder (sending it to your router no matter where you may be), or you can open it locally, with Transmission, for instance. I've benn using this almost over 6 months, and I'm loving it!

Cheers!