Liven up Livedocs: Search from Quicksilver

Several months ago I jumped back into AS3 development for flash and I once again, therefore, jumped back into using the actionscript livedocs. LiveDocs are great, but I’ve always found navigating to them to be a big chore, even from a bookmark in a browser. In addition, the search functionality for LiveDocs to often be frustrating. The other day it occurred to me, however, that the same search capability used to trigger yubnub commands from Quicksilver could be implemented to search LiveDocs as well. Check out this tutorial at lifeclever to find out how to access yubnub from Quicksilver. The same principle can be used for searching live docs (and for searching the adobe help docs for flash 10 player AS3. Instead of using using the search URL "qss-http://www.yubnub.org/parser/parse?command=***", use the following query URLs in a quicksilver web search trigger:

Flash 9 LiveDocs:  qss-http://www.google.com/search?&btnI&q=site%3Ahttp%3A%2F%2Flivedocs.adobe.com%2Fflash%2F9.0%2FActionScriptLangRefV3%2F+***

Flash 10 Help Docs:  qss-http://www.google.com/search?&btnI&q=site%3Ahttp%3A%2F%2Fhelp.adobe.com%2Fen_US%2FAS3LCR%2FFlash_10.0%2F+***

Basically, since there is no convenient way I found to use the search mechanisms on the Adobe site, these queries are running a google lucky search on the wildcard applied search term, while restricting the search to the site pertinent to the docs of interest. Running the assigned key command will trigger the Quicksilver text entry box; simply enter the term, such as “vector” for Flash 10, and the google lucky search will be performed. Since the lucky search is restricted to the livedocs and the help docs, the first search result returned will be the frameless html page in the docs for the search term. When searching for the docs for a specific actionscript term, this cuts the search time for a term down to a couple of seconds, which is highly convenient…

Quicksilver Adium Message Script

The Adium plug-in for Quicksilver has been kaput for quite a while now, and I have found myself as of late with folks at work I need to contact who keep themselves in the invisible state in their messenger (like my manager ;-) . I have come to loath having to go to Adium and go to the menu bar with the mouse and select “show offline contacts” and then find the person I want to IM and click their name, then “hide offline contacts” again. I also don’t care about having to use the contact list interface anyway, really, if I didn’t have to, so I wrote this applescript to use in Quicksilver.

To install, uncompress this script and put it in your ~/Library/Application Support/Quicksilver/Actions directory, and restart Quicksilver.

To use, invoke Quicksilver and type “.” to enter text mode. Type all or part of the name of the person you wish to IM. Hit and type “Adium” (or “Ad” or “Adi”) and select “AdiumContactor” with the arrow keys and hit .

The script will search for any instance of the text you enter in your contacts, both in their IM names, as well as their display names. If one match is found, it will open an IM window for that contact. If multiple contacts are found, a window will open allowing you to select the one you want, using whatever account it belongs to. (in other words, if you search “bil”, you will be able to choose from “Bill Todd”, bileInMyStomach@gmail.com, actionscriptAbility@hotmail.com, etc.) Careful using some search terms, such as “com”, as it will return all your MSN messenger accounts (whose screennames are defined by the contact’s email address)

PlasticWare Downloadable ::
AdiumContactor for Quicksilver (Aug. 07, 2008)
Download (~10,000 bytes) :: AdiumContactor.zip

quicksilver, curl, applescript, proxy-config, twitter

This explains how to use Quicksilver to send posts to Twitter from within a firewall. I made this my little lunch project today. First, let's start with the basics. If you set up your work proxy server in your network config, there is not really any way to easily retrieve those settings. Let's say you are using http://proxy.myco.com:3128 for your http proxy settings. In the Terminal, you have not actually set your http_proxy environment variable. Mark Assad has proxy-config available for download. You can grab that, put it in one of your path directories, and then in your .bashrc or .zshrc file the following:

export http_proxy=`proxy-config -h`
export https_proxy=`proxy-config -s`
export ftp_proxy=`proxy-config -f`

This will set your environment proxy variables to whatever they are currently set to in your Network Preferences. I got part of this also from Ryan Tomayko's blog.This is important if you are inside a firewall at work.

The simplest way to post a tweet to twitter from the command line would be to do so using cURL. If you don't have cURL installed, you will need to install it. If you aren't familiar with cURL, it is basically a command-line tool for grabbing html documents (or whatever else). See this post for another use. I got this idea, as well as the applescript for using it with Quicksilver, from Coda Hale's blog. Read that post for a full explanation of using Quicksilver and an applescript for posting to twitter from Quicksilver -- it has a pretty thorough explanation.

If you are inside a firewall, however, this will likely fail because the cURL command requires that the proxy settings be provided. So, I took the script from Coda's post, combined it with the comment on his post from Daan Kortenbach, and then enabled that for use with the system's proxy settings. The new script follows:

using terms from application "GrowlHelperApp"
	-- Register Growl
	on growlRegister()
		tell application "GrowlHelperApp"
			register as application "Tweet" all notifications {"Alert"} default notifications {"Alert"} icon of application "Quicksilver.app"
		end tell
	end growlRegister

	-- Notify using Growl
	-- Example: growlNotify("This is an Alert","This is a test of the Growl Alert System")
	on growlNotify(grrTitle, grrDescription)
		tell application "GrowlHelperApp"
			notify with name "Alert" title grrTitle description grrDescription application name "Tweet"
		end tell
	end growlNotify
end using terms from

using terms from application "Quicksilver"
	on process text tweet
		tell application "Keychain Scripting"
			set twitter_key to first Internet key of current keychain whose server is "twitter.com"
			set twitter_login to quoted form of (account of twitter_key & ":" & password of twitter_key)
		end tell
		set twitter_status to quoted form of ("status=" & tweet)

                -- I have proxy-config in a directory "~/bin"
		set the_proxy to do shell script "~/bin/proxy-config -h"

		try
			if (the_proxy = "") then
				set results to do shell script "curl --user " & twitter_login & " --data-binary " & twitter_status & " http://twitter.com/statuses/update.json"
			else
				set results to do shell script "curl --proxy " & the_proxy & " --user " & twitter_login & " --data-binary " & twitter_status & " http://twitter.com/statuses/update.json"
			end if
			growlRegister()
			growlNotify("Tweet Sent", tweet)
		on error
			(* In case curl fails for some reason,  alert us *)
			growlRegister()
			growlNotify("Error", "There was an error sending your tweet.")
		end try

	end process text
end using terms from