15 · 10

Share Large Files Using Snow Leopard Services

Background

For a while, I've been using various things like Forklift Droplets, Dropzone and various other options as a place to quickly upload files to one of my web hosting accounts for sharing. I've also used the Dropbox public folder for this purpose, but never really got used to that method. This includes files that are too large to email, as well as images that I want to share on Twitter or a forum post somewhere.

The things I tried all worked with varying degrees of success, but after Snow Leopard came out I wanted the ability to accomplish the same thing with just a right-click. I've gone through several iterations of the script, and finally have something that I think is worthy of sharing.

There are a couple of things I wanted to accomplish:

  1. Right-click on a file anywhere in the finder to upload the file.
  2. Have the resulting URL automagically copied to my clipboard

Initially, I had issues with the second requirement, because Automator doesn't make it easy to get the filename for some unknown reason. There are all kinds of things to deal with the file itself, or the path, but it doesn't seem possible to easily get the name of the file. I ended up using a little Python tidbit to accomplish what was needed here.

Prerequisites

You need a web server setup that allows SSH access. If you're using a web host that doesn't allow SSH access, you're doing it wrong.

In order for the service we're going to build to work, you first need to have passwordless authentication set up between your computer and your webserver via SSH keys. This article looks like a fairly easy to follow set of instructions. There are myriad other tutorials for this, so just chug through some Google results until you find one that works for you.

Of course I anticipate that the target audience will already have this set up, so lets move on to the good stuff.

Instructions

You'll need to launch Automator, and choose Service as the starting point for your workflow.

The first step is to change the settings for what the service is used for to receive files or folders from the Finder, like this:

The first action you'll need to add is the "Get UNIX Paths of Files" action. Uncheck the one configuration box, like this. *Update:* This action isn't included by default. Check addendum 2 below for the AppleScript method.

You'll then add a Run Shell Script action. This is where the heavy lifting of file uploading is going to happen. Here's a screenshot, including the things you'll have to change from the default action settings:

  1. By default, the Pass input: dropdown will be set to stdin. You need to change this to "as arguments."
  2. Fill out the shell script to match the image, replacing the info with your user, domain name, and server path (of course). Some of this will already be filled in for you when you change the dropdown menu.

You then need to add a second Run Shell Script action. This is where we'll add a little Python magic:

  1. First, you need to change the Shell dropdown to /usr/bin/python instead of the default /bin/bash.
  2. Then, you'll change the Pass input: dropdown to "as arguments" like in the previous script.
  3. Then you'll need to enter the script as shown. Obviously you'll use your domain name between the quotes after filepath.

Finish it off with the Copy to Clipboard action, and you're all set. The resulting script will look something like this:

Now all you have to do is hit save, and give it a name like "share file" or whatever. It will then show up in the contextual Finder menu for any file in any location. A simple right click and you get a file that's uploaded and the URL gets put in your clipboard ready for easy sharing.

Addendum

I think I've figured out the Growl notification. If you want a growl notification when the process is complete, you can add something like this at the end of your workflow. I right-clicked on the "Run Shell Script" header and selected "ignore input." This requires that you installed growlnotify from the Extras folder on the Growl disk image.

Addendum 2

I realized that the Get Unix Paths step in here requires a plugin to be installed for Automator. The same thing can be accomplished without a plugin using the "Run AppleScript" action as shown below (to get the pretty colors, hit the little hammer icon after entering the text). Replace the first step with this one.

I've also uploaded an action that you can download and modify with your server information to make this all easier for you.

13 · 10

LESSN URL Shortening for LaunchBar

Update

The script and readme are now located over at github, so if you want to improve on it just fork it and get to work.

Background

LESSN is a URL shortening system (think tinyurl) that you can install and use on your own servers with your own domain name instead of relying on third party services that may or may not retain your URLs forever.

It includes a very handy bookmarklet, and that's probably how most people will use it, and most people won't have a need for any other method. I don't really have a need for other methods, either, but I can't resist turning things into LaunchBar scripts, either.

Recent updates to LESSN include an API to allow creating URLs from other apps instead of the web interface. I've created an AppleScript that can be used with LaunchBar to create a LESSNed URL and copy the finished URL to your clipboard.

Setup Instructions

To use, download the lessn url script. You'll need to unzip the script, and open the AppleScript file by double clicking it.

There are two variables that you'll need to replace:

  1. api_key: When you log into your LESSN install at http://yourdomain/-/ or however you set it up, you'll see an API key listed bellow the bookmarklets. Replace the contents of the api_key variable with this API key.
  2. domain: Set this to whatever domain you used for LESSN. If you installed LESSN in a subfolder, you'll also have to include that. For example, mine is set to shrnk.me. If I had a subfolder, it would be shrnk.me/subfolder.

Once you've set these variables, you can save the script in ~/Library/Application Support/LaunchBar/Actions/ with whatever name you want to show up in LaunchBar.

You'll then need to relaunch LaunchBar.

Usage

  1. Copy long URL to clipboard.
  2. Call up LaunchBar
  3. Type enough characters to bring up the script in LaunchBar, and then hit space.
  4. Paste your URL into the resulting text field and hit enter.

The LESSNed URL is now in your clipboard waiting to be pasted wherever you need it.

Enjoy.

25 · 02

Backpack Scripts for LaunchBar

Update

These scripts are now hosted at github, with more concise instructions and the ability to fork and modify the scripts all you want. You can still download them directly, of course.

A while ago, I wrote some scripts for posting items to Backpack accounts from Quicksilver. Since then, Quicksilver has fallen out of favor with me, so I tweaked the scripts for use in the fantastic LaunchBar instead.

The scripts will allow you to add task items to specific Backpack lists, or add notes to specific Backpack pages, all from the comfort of LaunchBar. Read on for instructions on how to get them set up and use them.

When you download the scripts, you will need to open them in Script Editor and make some changes to the variables at the top of each script.

  1. For YOUR_API_KEY, enter your API key which can be located by clicking on My Info in the top right section of your Backpack header. At the bottom of this page is a link to "show your API key."
  2. For YOUR_ACCOUNT_NAME, replace the place holder variable with the name of your backpack account, the portion of the URL that shows up before backpackit.com when you visit your account.
  3. For BACKPACK_PAGE_ID, enter the number that shows up at the end of the URL in your address bar when you visit that page.
  4. For BACKPACK_LIST_ID in the list item script, you'll have to dig a little deeper. The only way I know of to find this is to view the source of the page on which the list resides in your browser, then search the source for the name of the list you're looking for. The number will show up directly before that and will look something like span id="name_list_1509503". You only need the numeric portion.
  5. If your account is high enough up the chain to have SSL, enter yes for that variable. If not, enter no.

Save your script with a title that makes sense to you and that will be easy enough to call up in Launchbar. For example, the list script that I have to add items to my Blog Ideas list is called, appropriately enough, Blog Idea.

You will need to save this in the ~/Library/Application Support/LaunchBar/Actions folder (the ~ means that this is the Library inside your home folder). If the Actions folder doesn't exist, create it.

After saving the script, you'll need to relaunch LaunchBar, so you may want to do them all at once. As you probably figured out, you'll need separate scripts for each page (for notes) or list that you want to use.

To use the task script, call up the script in LaunchBar by typing part of the name, and then hit the space bar instead of hitting enter. This will put you in text entry mode, where you can enter the name of the task to be added to that list. After typing it in, hit enter. This will immediately enter the task on the list.

The note script works the same but it has one advanced option. If you would like your note to have a title, type the title before the rest of the note and separate it from the note with a colon. This also means your note cannot have a colon in the text, or this will fail. You can edit the AppleScript to use a different separator if you would like. Just change the colon character in the line that says

set text item delimiters to ":"

and make it whatever you'd like that's not likely to be in the body of the note.

26 · 09

TextExpander instead of Shell Scripts

Lately I've been using TextExpander to make my workflow a little easier when dealing with things like Django development.

I've owned TextExpander for a while, but never really came up with something useful to do with it until recently. I found myself typing the same thing over and over when dealing with the web app that I'm working on in Django, and came up with some tidbits that help ease this process.

Some of the things I'm doing here would normally be the domain of shell scripts. However, to actually run a shell script in a typical manner I'd be typing practically as much stuff as I am to actually type some of the commands. Most of them aren't actually all that long.

So I got the idea to enter some shell commands in TextExpander and see where that took me. According to the TextExpander stats, I've now expanded 102 snippets, saving myself the need to type 3,148 characters.

This first example goes into my Django source code folder, checks out the latest version from subversion, and installs it. Because it's just running the commands in the terminal, it does everything perfectly and asks for my password when necessary.

cd ~/Source/Django/
svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk
cd django-trunk
sudo python setup.py install
So instead of going to the Django site, finding the link (because I always forget it), pasting it in Terminal, and running the install command I just type "dco" at the command line and type in my password when it asks for it. This same basic idea could be applied to anything you check out frequently. Since I'm just downloading the source code and not actually contributing anything to the Django project, I don't need any of the more advanced elements of subversion. Just the ability to check out a read-only copy of the latest version of the source code.

I also have some simpler snippets that also save some time. Like, instead of typing:

python manage.py runserver
every time I want to start up the development version of a Django app, I just type "rrs" and it runs. I include a carriage return at the end of that line in the snippet so that it automagically hits return for me in Terminal.

That snippet is obviously not project specific, so I can run it in any Django project folder to run that app. In addition to that, then, I enter shortcuts for the actual project directories as separate snippets. So typing "ddt" enters

cd ~/Dropbox/Django/django_tutorial/cms/
and follows it up with a return to take me right into that directory. Then I can hit "rrs" to run the app or "sdb" to run
python manage.py syncdb
if I've made any changes that require the database to be updated.

If I need to install any python modules I've downloaded, I can usually just cd into the directory and then type "iinst" which gives me

sudo python setup.py install
followed by a return, and then type my password.

Obviously these things can be applied to any programming language or other frequent commands you type. It's made my command-line life a lot easier.

29 · 02

Backpack Calendar and Reminder scripts for Quicksilver

I decided to take the backpack calendar and reminder scripts and make them a bit easier to set up. The functionality is essentially the same as the old ones, and there isn't really a reason to upgrade if you have them set up already (as far as I recall).

I did learn some new information about the reminder scripts, though. The information I had before allowed for setting reminders by setting the number of minutes in the future you wanted the reminder to be. I've since learned that you can also set a specific time, as long as it's on the same day. You can't use this to set reminders for future dates, so the calendar script is better for that. The syntax for the reminder script is either "+120 Reminder Text" or "5pm Reminder Text."

The syntax for the calendar isn't much different. "5pm tomorrow Do something" or "5pm 3/1 Do something else." You can also do all-day or multi-day events by leaving off the time, as in "3/1 Do something" or "3/3-3/12 Do something."

Unlike the previous scripts, I've broken out the user specific information into the beginning of the script to make it easier to set up. You'll need to replace the values YOURAPIKEY, YOURACCOUNT, and for the calendar YOURCALENDARID. To find the calendar ID, you'll have to view the source of the Calendar page and look for something like this:

/calendars/9999/edit',

The number in that link is your Calendar ID. If you have more than one calendar, there will be multiple. They are followed closely in the same line of code by the calendar name so you can tell them apart.

You can download these scripts here.

28 · 02

Advanced Backpack Quicksilver Scripts

Update March 4, 2008:I've updated the scripts so that they no longer cause Quicksilver to reactivate after finishing the task. If you'd like this functionality, you can re-download the scripts bellow, or you can just add the line "return null" (without the quotes) before the line "end process text" towards the end of the script.

After updating my backpack task script the other day, I got to work on the script for adding notes to a page. While doing this, I had some more ideas to make both scripts more powerful. I have a link here to the latest scripts.

Here is the general idea. The notes script allows you to add a note to a backpack page, obviously. You can either type just a line of text, which will create a note with no title, or you can type a title followed by a colon and then the body of the note and the script will create a note with a title and body.

The task script is even more exciting. If you just type a line of text, it will add an item to the list that you have specified in the script. If you type text followed by a colon and then more text, it will create the item in the list and then it will also create a note with that same text as the title, and the text following the colon as the body. So this:

Will result in this:

And this:

Will result in this:

So if you are the kind who likes to add notes to your list items, this is as close as you get with Backpack.

As usual, replace the variables at the top of the script with the ones from your account. This article gives the instructions for finding the information you need.

26 · 02

Backpack Quicksilver task script for new Backpack

Update March 4, 2008:I've updated the scripts so that they no longer cause Quicksilver to reactivate after finishing the task. If you'd like this functionality, you can re-download the scripts bellow, or you can just add the line "return null" (without the quotes) before the line "end process text" towards the end of the script.

Backpack was recently updated, and I'm not sure if there are going to be additional API changes. For now, though, I've updated the task script to go beyond what it did before and post to specific lists on a page, since you now have the ability to have more than one list on a page.

  1. Download the script here and unzip it.
  2. Double click the AppleScript to open it in Script Editor.
  3. Change the variable information at the top, replacing APIKEY, USER, PAGEID, and LISTID with your information.
  4. If you are on an account that uses SSL, find where it says "http://" in the code and change it to "https://".
  5. Save the file to ~/Library/Application Support/Quicksilver/Actions/ using whatever name you want.
  6. Relaunch Quicksilver.

You will activate this the same way as the other scripts:

  1. Activate Quiksilver with whatever your keyboard shortcut is.
  2. Type period to enter text entry mode and type your text to add as a list item.
  3. Hit tab to allow you to select the action to be performed.
  4. Type a few letters to bring up the script you just created and hit return.

I don't know how to make it not return the result that makes Quicksilver pop back up. If anyone knows, let me know in the comments. At least it lets you know that it worked.

Now, if you don't know how to get the information for the variables, here it is:

  • For the APIKEY, click on My info on the right side of the Backpack header menu bar. There is a link to display your API key at the bottom of the main section.
  • For USER, enter the name of your main account, the same thing that you enter before backpackit.com to get to backpack.
  • For PAGEID, enter the number that shows up in the URL field when you visit that page.
  • For LISTID, the only way I know to find this is to view the page source, search for the name of the list, and find the number that shows up right before that. It will look something like span id="name_list_1509503", but you only need the numeric portion.
5 · 07

Highrise Note Script for Quicksilver

I don’t know why I didn’t think of this earlier, but I took the basic elements of the Highrise task script that posts tasks to specific cases, and created a script that posts notes to specific cases.

You’ll need to change the variables in all caps at the top of the script to your information, and then save the script in ~/Library/Application Support/Quicksilver/Actions and restart Quicksilver. The script is set up so you will need to create one for each case that you would like to send notes to from Quicksilver.

If you want, you could set up a case as a sort of Inbox, and then move the notes to other cases from there. If you want to use the Inbox method, you may find it helpful to bypass the task scripts altogether. You can then send notes to the Inbox and create tasks related to those notes when you process your Inbox from the web interface, and move the notes to their “project” cases.

The values you will need to change in the script are:

  • YOUR_API_CODE
  • CASE_ID
  • MAIN_ACCOUNT_NAME

Here is the link to the script.

This is related to the Highrise Task Quicksilver scripts I have over here. Make sure you look down in the comments for version two if you’re going to use the task script.

9 · 05

Highrise Task Quicksilver Scripts

Update:The latest scripts are available here.

I've been waiting for some time for an API for Highrise from 37 Signals so that I could integrate it with Quicksilver better than using emails to create tasks.

The email functionality is great when you're creating a task or adding a note from an email, but it's rather cumbersome for creating tasks.

Now that the API is released, I've created some scripts. These are a little more flexible than the ones I've had before for other apps, as I got my AppleScript guru friend at work to help with some text processing functionality in the script.

I have two main scripts. One of them gives you the ability to create tasks with various timeframes all in one script. The second gives you the ability to attach tasks directly to Cases, and allows you to set timeframes, but it requires a separate script for each Case. This second one provides functionality that isn't available via email. You can download both scripts here.

To set up these scripts, you need to open each one and edit the data that is in all caps, namely YOUR_API_CODE_HERE, YOUR_MAIN_ACCOUNT_NAME_HERE, and CASE_ID_NUMBER_HERE (the last one only being applicable in the case specific script. You will also need to remove the "s" from "https://" if you are on an account that doesn't have SSL capability.

In a moment, I'll show you how you can set the timeframe for each task as you enter it in Quicksilver. There is a default timeframe it fails over to, however, so you'll want to set this to whatever you need. I set it for "later," so if you want that you can leave it as it is. If you want a different default, change "later" in the line immediately following "else" to say your default timeframe.

The timeframe options for both this default and what you will type into Quicksilver are as follows:

  • today
  • tomorrow
  • this_week
  • next_week
  • later

I may add the ability to remind at specific times later, but it's a bit tedious to type so I probably wouldn't personally use it.

You'll need to put the scripts, with whatever name makes sense to you, in your ~/Library/Application Support/Quicksilver/Actions folder and then relaunch Quicksilver.

The method for creating a task with the default timeframe is very simple. It is identical for both scripts. Call up Quicksilver using whatever your standard shortcut is, type a period to enter text mode, and type the name of the task you want to create. Hit tab and type your shortcut to call up the pertinent highrise script. Hit return.

Creating a task with a different timeframe is almost as simple. There is only one change. After typing the name of the task, type a colon and then the timeframe. For example, "Do stuff with so-and-so:next_week"

3 · 04

Better 30 Boxes Event Creation from Quicksilver

While I was on a roll creating AppleScripts for APIs, I decided to work on deciphering the 30 Boxes API. The 30 Boxes calendar lets you send it an email to post an event, and the format for creating a 30 Boxes event is a bit more flexible than the Backpack calendar, especially since it allows you to specify the reminder time while entering the event. So you could type something like:

Wednesday 3pm Do some stuff remind in 30 minutes (note about event)

Part of the reason I stopped using 30 Boxes was that I was tired of the multi-step process required to create these events using Quicksilver (the same reason I created some of my Backpack scripts). While only three steps, having to remember the additional step when creating an event greatly increases the barrier to getting this procedure into muscle memory.

What was required was calling up Quicksilver, typing the text, selecting the direct email function, and selecting 30 Boxes (after first creating 30 Boxes as a contact in your Address Book). While the setup was simple, I wanted fewer steps for each time I entered an event.

So, I’ve created a script (I zipped it this time to make it download better) to lower the number of required steps. With this script, you will be able to type the event using the syntax as mentioned above, and then call the script. Like all my other scripts, it sends a response back to Quicksilver making it activate again, which adds another step; this step, however, doesn’t add as much to the brain work necessary, as deactivating Quicksilver is already second nature to most Quicksilver users.

You will need to modify a couple of things in this script to use it, and the steps to get these keys is a little obtuse:

1. Login to your 30 Boxes calendar, if you haven’t already.

2. Visit this link.

3. You will see an example url here that contains the two pieces of information you’re going to need, and the url is handily split up into multiple lines to make it easier to grab those two pieces of information.

The first one you’ll need is in the line that starts with “&apiKey=”. Get everything in that line after the equals sign, and replace the text YOURAPIKEY in the script with that. Do the same with the line that starts with “&authorizedUserToken=” and replace YOURAUTHORIZEDUSERTOKEN in the script with that.

Save it in your ~/Library/Application Support/Quicksilver/Actions folder and restart Quicksilver. Enjoy easier event creation with 30 Boxes and Quicksilver.

Matthew Fitzsimmons

Yet another random Christian web geek blogger.

About

Replaces fitzage.com, aka.fitzage.com, and all that other crap.

Contributors