Entries in mac (3)

Tuesday
02Feb2010

LaunchBar Script: Create bit.ly

I recently created and published a LaunchBar Action to create and copy a bit.ly URL to the clipboard and today I wanted to use the URL in a SMS, a new script would be needed to display the new shortened URL.

Not a big change from my first script but still worth publishing, in this version I display and copy the URL to the clipboard, download here.

on handle_string(theURL)

-- add scheme prefix if missing
set _firstColon to offset of ":" in theURL
set _firstSlash to offset of "/" in theURL
if (_firstColon = 0 or _firstSlash < _firstColon) then
set theURL to "http://" & theURL
end if
-- Process and encode URL
set theURL to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of theURL
-- Create bit.ly
set login to "YOOURUSERNAME"
set apiKey to "YOURAPIKEY"
set bitlyURL to "http://api.bit.ly/shorten?version=2.0.1&longUrl=" & theURL & "&login=" & login & "&apiKey=" & apiKey & ""
set results to do shell script "curl " & quoted form of bitlyURL & " | grep shortUrl | awk '{print $2}' | sed 's/[\",]//g'"
-- Copy to clipboard and display
tell application "LaunchBar"
perform action "Copy" with string results
display in large type results
end tell

end handle_string

Again replace "YOURUSERNAME" and "YOURAPIKEY" with your own details and install the action by placing the file in ~/Library/Application Support/LaunchBar/Actions. 

If you do not want to copy the URL as well remove the line "perform action "Copy" with string results".

Sunday
31Jan2010

LaunchBar Script: Copy as bit.ly

I recently started using LaunchBar which comes with a Copy as TinyURL action built in however I use bit.ly. After searching around for a little while I found a script that posts to Twitter with bit.ly URL shorting but that was it.

I decided to take parts of both of these scripts to make my own and here is the code (download):

on handle_string(theURL)

-- add scheme prefix if missing
set _firstColon to offset of ":" in theURL
set _firstSlash to offset of "/" in theURL
if (_firstColon = 0 or _firstSlash < _firstColon) then
set theURL to "http://" & theURL
end if
-- Process and encode URL
set theURL to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & quoted form of theURL
-- Create bit.ly
set login to "YOOURUSERNAME"
set apiKey to "YOURAPIKEY"
set bitlyURL to "http://api.bit.ly/shorten?version=2.0.1&longUrl=" & theURL & "&login=" & login & "&apiKey=" & apiKey & ""
set results to do shell script "curl " & quoted form of bitlyURL & " | grep shortUrl | awk '{print $2}' | sed 's/[\",]//g'"
-- Copy to clipboard
tell application "LaunchBar"
perform action "Copy" with string results
end tell
end handle_string

Replace "YOURUSERNAME" and "YOURAPIKEY" with your own details.

To install the action place the file in ~/Library/Application Support/LaunchBar/Actions.

I have never written any AppleScript before and now I understand just how powerful it is I'm going to start learning the language.

Friday
22Jan2010

Things for Mac and iPhone

OK so not a few weeks later as I said but it's still here. A few month's ago I started to follow the Getting Things Done program using Things as my tool of choice to manage my tasks.

Well since then I've still been following the program and now find I'm getting a lot more done in a day.

Things is simple yet powerful and most importantly easy to use. The simple power of the little application is prefect for me, I put every little thing I have to do in to it ranging from full projects with hundreds of tasks to little things like post some of the drafts on the site.

However I do start to build up a lot of tasks that never seem to get done like the posting of the drafts, and every so often I set aside a day to get through as many of them as possible.

Things can help a lot with tasks and projects that have a start and due date by not showing them until you can start them and turning the check box red when over due and yellow on the day their due, making them stand out a little from the other tasks.

The iPhone is the perfect companion to the desktop version although both can stand alone they work better together with the ability to quickly add tasks on the road and mark them as done the second I do them and have it all in sync is wonderful. The only nag I have is the need to be on the same WI-FI network to sync, Cultured Code, the developer, has said an over the air sync is coming in a future release.

So is Things worth the $50 (Mac) and $10 (iPhone) yes most defiantly if you are going to be using to do lists.