Tips


2
May 12

Automated FTP from Dropbox with Hazel

Macstories.net linked to QuickShot 2.0. It’s an iOS app that can send photos directly to Dropbox. But I was thinking, I would prefer an app that could quickly send images to my FTP server at Macdrifter.com. So I came up with a little Hazel rule to connect Dropbox and my FTP server.

Design Considerations

I want to put these files on my FTP server so that I can use them for posts to this site. That means I need an easy way to get the URL of the image. I previously built an email rule that uploaded the file and returned the link to me in a reply email. That worked really well, but email is not where I write my posts. I wanted the URL somewhere convenient. So I decided to have the resulting links added to a URL log file in my Dropbox Notes folder. NVAlt, WriteRoom and Nebulous Notes all point to my Notes folder.

I knew I would use FTP. I really like Transmit for FTP, but it seemed a little heavy handed for Hazel automation. I decided I needed to use straight Python for the FTP and skip the application scripting.

The Hazel rule is simple. It just looks for a new file it has never matched before. All of the work is done by a Python script.


Hazel Rule

Note that the Shell path is actually invoking Python.

The Script

I learned something new with this Python script, which is generally my goal. I learned about using the Paramiko module for SFTP. Paramiko is primarily a Python module for SSH that also includes some convenient methods for SFTP. I’m not sure if it passes the Drang sniff test but I like it.

To install Paramiko, just use pip:

sudo pip install paramiko

It should also install the pycrypto dependency.

Here’s the entire Python script.

import paramiko
from datetime import date
import os
import sys
import urllib
try:
    # This is how Hazel gets the incoming file path
    localPath = sys.argv[1]
    # Location to write the URL links
    logFilePath = "/Users/weatherh/Dropbox/Notes/Linkin_Logs.txt"
    # Base File Location on the FTP Host to upload the file
    remotePath = "/home/macdrifter/webapps/wp/wp-content/uploads/"
    fileName = os.path.basename(localPath)
    # Just logging paramiko incase of issues
    paramiko.util.log_to_file('/tmp/paramiko.log')
    host = "my_host_name"
    port = 22
    # This will be the base URL path for the file link
    url_Base = "http://www.macdrifter.com/wp-content/uploads/"
    transport = paramiko.Transport((host, port))
    password = "my_super_strong_password"
    username = "my_sftp_user_name"
    # Determine the current month and year to create the upload path
    today = date.today()
    datePath = today.strftime("%Y/%m/")
    # Used to create full remote file path
    remoteFilePath =  remotePath + datePath + fileName
    transport.connect(username = username, password = password)
    sftp = paramiko.SFTPClient.from_transport(transport)
    # Do the deed. Use the SFTP put command
    sftp.put(localPath, remoteFilePath)
    sftp.close()
    transport.close()
    #Open the URL log file for appending
    logfile = open(logFilePath, "a")
    try:
        # %% encode the file name and append the URL to the log file
        logfile.write(url_Base+datePath+urllib.quote(fileName)+'\n')
    finally:
        logfile.close()
except IOError:
    pass

Obviously, you will need to provide your own connection details and file paths. This script is specific to my needs.

The Workflow

There are two ways I am using this. The first is on my Mac. Any file I drag to this Dropbox FTP folder gets uploaded and a link added my link log. It’s amazingly convenient.


Link Log

The second is on iOS. The QuickShot app is cool. I configured it to upload to this Dropbox FTP folder. The file is uploaded to the server and a link silently added to my log file. I can upload any file from an application that supports Dropbox uploads. But QuickShot is pretty convenient.

I’ll also add that it is convenient to have a Dropbox folder filled with the images I have uploaded to my server. It provides a history for me to see what I was thinking while adding screen shots. I take a heck of a lot of screen shots.

Comments

There are a lot of modules imported for this script. sys is needed just to handle the connection with Hazel. os is needed just for getting the file name and writing the log file. Heck, I even import the urllib module just to encode the file name. But you know what? It works and it is fast, so I don’t care. CPU cycles are cheap. Isn’t that the point of these scripting languages?

It’s never a great idea to hard code login credentials. I might change this in the future to use a config file, but I’m not too concerned with the kind of stuff I use this for.

The error handling in the script is pretty lean. Other than the try and except blocks there is none. I should add more. I probably will not.

The FTP put command will overwrite any file with the same name in the same location. That’s by design. If I want to edit a file on my Mac, I can just open it in Acorn or optimize it with ImageOptim and Hazel will reprocess it when I save. The new version is uploaded but the URL link remains the same.

This will work with any file type. That’s cool but a bit scary. If I accidentally drop-in something private, then it will be uploaded to my public FTP host automatically. I’m aware of the potential problems. I’m a big boy. I can handle it.

Future Plans

I’d like to add some automatic image processing. I definitely want to include ImageOptim processing but I would also like to resize any image larger than 650px. It would save a lot of trouble with iPad images. I might need some different rules to provide multiple options for image resolution.

I’m thinking about adding the links to my pasteboard on my Mac. That way I would have the log file and also a running list in my pasteboard.


25
Apr 12

TextDrop App

I’ve mentioned TextDrop in passing but I like it so much that I wanted to write a full review.

What it is

TextDrop is a webapp for notes. It looks a bit like Simplenote or NVAlt but it works exclusively with Dropbox. There is a list of notes on the left sorted by file name, search bar at the top and text window taking up the right 2/3′s of the window.


TextDrop

TextDrop can access all text files in a given Dropbox folder. What’s really convenient, is that I can bookmark different folders and notes with a plain URL structure.

Open a specific Dropbox Folder named “Notes”:

https://www.textdropapp.com/dropbox/Notes/

Open a specific note:

https://www.textdropapp.com/dropbox/Notes/My Awesome Note

I can also bookmark a specific search set too.

Shortcut to query results for “simplenote”:

https://www.textdropapp.com/dropbox/Notes/?q=simplenote


TextDrop

Those are some very useful shortcuts. I now have a group of bookmarks to different folders, notes and queries for quick access from the browser.

Keyboard shortcuts

The TextDrop interface is very sparse. This gives the initial impression that it lacks features. But TextDrop has keyboard shortcuts, and they are good.

Function Key Combo Description
Search SHIFT CTRL L Jump between search bar and document
Delete SHIFT CTRL Backspace Delete the active file
Rename SHIFT CTRL E Rename the active file
Markdown SHIFT CTRL M Toggle Markdown preview
Jump Word CTRL Right Arrow Jump to next word (normal text area function)

What it is not

TextDrop is not a complete replacement for something like Simplenote.

  • The search is more limited in TextDrop. Search by title only.
  • It does not preview MultiMarkdown (standard Markdown only).
  • There is no option to share a note.
  • There is no support for tags.
  • Notes can only be sorted by name.

TextDrop is not Simplenote. In some regard, that’s a good thing. The TextDrop sync is fast. There are subtle bits of polish. For example, tiny colored dots indicating the sync status of each note. This is version 3.0 of TextDrop and it feels like it. I have not had any problems with TextDrop.

Et Cetera

There are no settings for the app, which I like. The documentation and release notes are all presented as another list of notes.

I also like the privacy statement. It’s plain english.

Once you grant us access to your Dropbox, we theoretically have access to all your files, but on our honor we will never, ever, ever read them, store them, or use them in any way except to deliver them into your active TextDrop session.

After deleting a note, TextDrop displays the record with a cross-out. Clicking on the note provides an option to restore the note.

Files can be renamed by double clicking and entering a new name. This is a bit buggy for me on Windows Firefox 11.

Search is fast. A unique feature of TextDrop is searching in sub-folders with a separate list of hits for each sub-directory. Want to search all text notes stored in Dropbox, then you can do that. I don’t recommend it unless you have a small number of files.

The support has been great. Prompt email replies from the developer Sam Nguyen within 24 hours. He’s been honest, thoughtful and nice in each exchange. There’s a real person behind the app and it doesn’t feel like abandon-ware.

TextDrop is $5 per year right now. That’s nothing for browser access to all of my notes in a well designed UI with features that work.


24
Apr 12

New Safari Window in Spaces

This might be a “duh” tip, but it’s news to me. From any space in OS X, right click on Safari in the dock and choose New Window. Boom, a new safari window in the current space. So many wasted hours moving Safari windows between spaces.


20
Apr 12

Writing In Markdown – Lists

This is part two in the Writing in Markdown series. If you prefer, read John Gruber’s original guide. I will not be able to add anything new.

Lists come in two flavors in Markdown. There are unordered lists and ordered lists. The first item in a list must be preceded by an empty line. A list item can contain other Markdown formatting, however the list bullet or item number can not. It must be plain text.

An unordered list is a simple bullet list. There’s not much to an unordered list. It must be separated from a text block by one blank like and each list item must be preceded by a hyphen, plus or asterisk. I use hyphen characters (“-”) exclusively for bullet lists. I have run into problems when using a mix of hyphens and asterisks with lists. Particularly, I have had issues when copying markdown into other applications.

To create nested lists, indent by one tab (or four spaces if you’re antediluvian. Markdown processors will automatically vary the bullet character between list levels. That’s the main reason it doesn’t matter much whether I use an asterisk or dash for bullets.

- Talk to Luke about his father
    * Skip the part where I leave him for dead
    - Don't mention the youngling "thing"
- Dinner with Yoda
    - Bring DEET
    - **Bring Pepto**
    - Dessert?
        - Wookie Pie
- Stop by to see Anakin on Death Star
- Submit restraining order against JarJar

Is converted to this:

  • Talk to Luke about his father
    • Skip the part where I leave him for dead
    • Don’t mention the youngling “thing”
  • Dinner with Yoda
    • Bring DEET
    • Bring Pepto
    • Dessert?
      • Wookie Pie
  • Stop by to see Anakin on Death Star
  • Submit restraining order against JarJar

But of course sometimes the order of items is crucial. That’s where ordered lists come in. The sequence of an ordered list is defined by the sequence of the list items and not by the number prefix of the item

For example, even though the first line is prefixed as item #3 in the list, the Markdown is converted to display as item #1. The actual number is irrelevant. It is only there to indicate that the line should be considered as an ordered list item. Also note that unordered and ordered items can be commingled in the same list, but not at the same indentation level. An ordered list can contain a nested ordered list. But an unordered list items are converted to numbered list items if they are at the same indentation level as another numbered item.

3. Stop by to see Anakin on Death Star
    2. Get a ride
    1. Wash robe
- Clean blood (and hand) off Anakin's old light saber
1. Talk to Luke about his father
    * Skip the part where I leave him for dead
    - Don't mention the youngling "thing"
2. Dinner with Yoda
    - Bring DEET
    - **Bring Pepto**
    - Dessert?
        - Wookie Pie
4. Submit restraining order against JarJar

Is converted to the list below. The originally drafted sequence would be lost in converting the Markdown to html or PDF.

  1. Stop by to see Anakin on Death Star
    1. Get a ride
    2. Wash robe
  2. Clean blood (and hand) off Anakin’s old light saber
  3. Talk to Luke about his father
    • Skip the part where I leave him for dead
    • Don’t mention the youngling “thing”
  4. Dinner with Yoda
    • Bring DEET
    • Bring Pepto
    • Dessert?
      • Wookie Pie
  5. Submit restraining order against JarJar

As with all Markdown, these are just tags to interpret the start of a ul or ol html tag block. As long as the first item in a list, all subsequent list items will be interpreted as an ordered list. For example:

#### Pack Suitcase ####
1. Lightsaber
- Leisure brown robe
- Formal brown robe
- Night time brown robe
- Dress Sandals

Generates this formatted list

Pack Suitcase

  1. Lightsaber
  2. Leisure brown robe
  3. Formal brown robe
  4. Night time brown robe
  5. Dress Sandals

Unfortunately, Markdown never implemented an option to start an ordered (numbered) list at an arbitrary number. The only option I have found is to create the list manually by escaping the Markdown using a \<pre> or \<code> block. These blocks tell the Markdown processor to skip interpretation of the list all together.

<pre>
2. Lightsaber
3. Leisure brown robe
4. Formal brown robe
5. Night time brown robe
6. Dress Sandals
</pre>

To generate this list:

2. Lightsaber
3. Leisure brown robe
4. Formal brown robe
5. Night time brown robe
6. Dress Sandals

Alternatively, I can skip the \<pre> tag by indenting each list item with one tab (or four spaces). This just makes it a code block which also escapes the Markdown processor.

    2. Lightsaber
    3. Leisure brown robe
    4. Formal brown robe
    5. Night time brown robe
    6. Dress Sandals

There are many more details about extending lists to include multiple paragraphs as well as code blocks. I highly recommend reading from the original source as handed down by Gruber.


17
Apr 12

Color Pickers in Acorn and BBEdit

I use about 5% of what Acorn can do for image editing, but what I use I love. Take, for example, Acorn’s color picker. I use this regularly for tasks that have nothing to do with editing an image. I use it to grab the info about a specific color. I pop open Acorn’s color panel with shift-cmd-C. I can then use the color picker by hovering over some pixel anywhere on the screen. Acorn tells me the hexadecimal name of the color immediately. I can then save it as a favorite if I want to come back to it later.

The same thing goes for BBEdit. I can open the BBEdit color picker to inspect a pixel anywhere on the screen. But BBEdit will drop the color’s hexadecimal into the front BBEdit document. Both of these applications are great for their primary uses, but it’s the little details that keep them perpetually open in my dock.


13
Apr 12

Why So Many Notes?

Several people have asked me why I have so many notes in Simplenote. I think the Notational Velocity site sums up my approach to notes best:

To make good use of NV, try to maintain one detail/fact/item per note. Notational Velocity’s strength, note-filtering, is diminished when only a few notes contain most of the content in the database.

That’s how I treat notes. Many small notes about a specific topic. While I do have long notes occasionally, they are usually unwieldy and difficult to sift through. If I have a large project, all related notes have a unique tag. I can group all of the notes together by the tag. But let’s say I want to quickly lookup the Windows Server 2008 Apache service logon user for Pipeline Pilot1, that’s much easier to find if there is one note about it. If I have one note with everything there is to know about Pipeline Pilot, it would be almost useless in an emergency.


  1. I use this every single day, for many hours. It’s an impressive development/automation/web server platform that is far too expensive for mere mortals. It’s for rapid “Enterprise” development. 


10
Apr 12

Writing in Markdown — Hiding Notes

This is the first in a series of short posts on writing with Markdown1. I don’t know how many, what the topics are or how often I will post them. These will be boring to many, obvious to some and useful to few. Sounds exciting, right?

If you need some introduction to Markdown and why it’s great, I recommend Brett’s two minute explanation and MacSparky’s introduction to plain text.

Notes and Outlining

When I write a long post for Macdrifter2 I typically write an outline first. Previously, I would paste the list into my Markdown document so that I could refer back to it as I wrote. The downside to that approach was that when I’d view the article with Marked, I’d have to look at the ugly outline along with the nicely formatted text. It was not satisfying.

Here’s what it looked like in Marked while I would write

After reading Glenn Fleishman’s Take Control of BBEdit book, I realized I was doing it all wrong. By wrapping my notes in the HTML escape block, I could have my notes visible during the writing phase but exclude them from Markdown processing.

<!---
- Outlining
- Tasks
- TextExpander
- Syncing
- New Dropbox
- Web access
- Export and Import
- Search
- iPhone
- iPad
- Sharing
--->

That’s for my CarbonFin post from a few days back. All of the bit in the comment block is escaped by the Markdown processor and by any HTML renderer. In fact, if you go look at the source for that post, you will see the list is still in there.

I usually try to remove the list when I am done, but sometimes it makes it through.

Also note, that I use three dashes at the beginning and end of the comment block. It makes it easier to do a grep search in BBEdit to find all of my little unintentional easter eggs.


  1. Technically I write in MultiMarkdown which is an improvement on Markdown provided graciously by the phenomenon known as Fletcher Penney. I tend to call it Markdown. I am wrong. 

  2. Which is virtually every post I make. What can I say, I like to ramble. 


1
Apr 12

Twitter Saved Searches

Yuvi produced a funny and accurate code of conduct for Twitter that is so eerily familiar, I had to check my closet to make sure he wasn’t watching me. Go read it and then let the Twitter enjoyment rise within you.

I have one more tip to offer. If you are not using and regularly reading saved searches in Twitter, you are truly missing half the value of the service. Twitter can be a great research tool:

Twitter can also be one of the funniest public forums when unrelated tweets are corralled together by the force of saved searches.

Thanks for the laughs Twitter.


25
Mar 12

The Color of Plain Text

I guess I have a common theme for my text editors. I prefer light text on a dark background. Without making a concerted effort, all of my primary text editors have ended with similar color schemes. Unfortunately Simplenote, which I use the most, does not support color schemes.

I’m sure many different people have different preferences. I always gravitate to the same sort of thing. I also prefer the night mode for Instapaper. Oddly enough, I dislike the DaringFireball.net color scheme. Maybe the background is not dark enough.

NVAlt

NVAlt provides a couple of options for text coloring. While there is an option for the foreground and for the background, NVAlt somehow decides on the link coloring without user input. I’d love another option to adjust the link color. I don’t care for the blue colors that it defaults to.


NVAlt Colors

Background Color: #010424

Text Color: #D4D4B2

BBEdit

I write a lot in BBEdit. I’ve created my own color scheme and a couple of language modules. What I like about my BBEdit theme is that it’s easy on my eyes but specific elements, like links, are highly visible.


BBEdit Scheme

Some of my BBEdit settings can be found on GitHub


BBEdit Preferences

Sublime Text 2

I primarily use Sublime Text 2 when I’m on MS Windows. I still prefer BBEdit overall, but I take what I can get when I’m at work. I use the Sunburst Color scheme for Sublime Text. It’s not the most attractive, but it packs a lot of contextual information into one window.


Sublime Text 2

Nebulous Notes (iOS)

Nebulous Notes is the app I use for long form writing on iOS. I customized the colors manually.

Background Color: #000000

Text Color: #BEBBA8


Nebulous Notes

Textastic (iOS)

I use the “Solarized Dark” theme with Textastic. It’s a built in theme and looks great with CSS, PHP, HTML and Markdown. Textastic is my default code editor on iOS.


Textastic

Writing Kit (iOS)

I use the “Pastels on Dark” theme.1


Writing Kit


  1. I’m giving Writing Kit another go based on Viticci’s review. I do find it fairly buggy still but it’s a nice editor. 


16
Mar 12

FTP Files to WordPress by Email

Yes, another hack to make this site easier for me to manage.

I post a lot from Simplenote now. While this is very efficient for making link-posts, it makes it rather challenging to create a post with images. Images are stored on the Macdrifter host in the standard WordPress content directories but I need a URL to create the image link reference in Simplenote.

I have used GoodReader in the past to upload an image to the server, but I have to manually create the URL for the image. That’s no fun.

So I created this insult to everyone that appreciates clean code.2 The script is attached to a mail rule on my primary Mac. When I send an email message with an attached image1 and a subject prefix “iii”, the script is triggered. It saves the image to a specific directory on my Mac and then uploads it to Macdrifter.com by FTP using Transmit3. Upon successful upload, it sends a reply email with the URL to the image.

The Abomination

(*
Author: Gabe Weatherhead
date: 2012-03-16_090533
Script for FTP upload to WordPress via Apple Mail rule processing.

This work is Creative Commons-Attribution licensed. Basically, do what you want with it, but don't be dick.
http://creativecommons.org/licenses/

Mesaage subjects are expected to be prepended with "iii"
Transmit is expected a favorite to exist for the destiantion. Mine is named "Macdrifter_WP"
*)


using terms from application "Mail"
    -- Uploads file using a saved favorite in Transmit
    on upload_file(theFile)
        try
            -- Creates base URL for remote file based on standard WordPress content structure
            set urlPath to "http://www.macdrifter.com/wp-content/uploads/"
            set myMonth to do shell script "date +\"%m\""
            set myYear to 1 * (year of (current date))
            set clipContents to {}
            tell application "Transmit"
                -- Stored Transmit favorite
                set myFav to item 1 of (favorites whose name is "Macdrifter_WP")

                tell current tab of (make new document at end)
                    connect to myFav
                    -- tempMSG is used for Growl reporting of errors.
                    set tempMSG to "Transmit attmepting to connect"
                    set this_item to theFile
                    -- Update Error reporting
                    set tempMSG to (this_item as text)
                    -- Get the File's path
                    set this_info to info for this_item
                    set myPath to (POSIX path of this_item)
                    -- Update Error Reporting
                    set tempMSG to "Attempting to locate local file" & (myPath as text)
                    set myFileName to name of this_info as text
                    -- Transmit must open the local location that holds the file
                    change location of local browser to path (POSIX path of ("Macintosh HD 2:Dropbox:Todo Files:Blog:"))
                    -- It's just easier to encode URL safe characters with Python
                    set myURLFileName to do shell script "/usr/bin/python -c 'import sys, urllib; print urllib.quote(sys.argv[1])' " & ¬
                        quoted form of myFileName
                    set myURLFileName to urlPath & myYear & "/" & myMonth & "/" & myURLFileName
                    set end of clipContents to "
"
& myURLFileName

                    -- Tell Transmit to do the upload
                    tell remote browser
                        upload item at path myPath to "webapps/wp/wp-content/uploads/" & myYear & "/" & ¬
                            myMonth & "/" with resume mode overwrite with continue after error
                    end tell
                    -- I like to have the URL put on my clipboard as well
                    set the clipboard to myURLFileName

                    close remote browser

                end tell
                close front window
            end tell
            set AppleScript's text item delimiters to "
"

            set clipContents to clipContents as string
            set AppleScript's text item delimiters to ""
            return clipContents
        on error errmesg number errn
            set AppleScript's text item delimiters to ""
            return errmesg & return & tempMSG & "error number: " & (errn as rich text)
        end try
    end upload_file

    -- I prefer Growl messaging for error reporting since I also use Prowl for iOS
    on growl_message(theMessage)
        tell application "System Events"
            set isRunning to (count of (every process whose bundle identifier is "com.Growl.GrowlHelperApp")) > 0

        end tell
        if isRunning then
            tell application id "com.Growl.GrowlHelperApp"
                set the allNotificationsList to ¬
                    {"FTP Mail Handler Script", "Script Success", "Script Error.app"}
                set the enabledNotificationsList to ¬
                    {"FTP Mail Handler Script"}
                register as application ¬
                    "FTP Mail Rule Script" all notifications allNotificationsList ¬
                    default notifications enabledNotificationsList ¬
                    icon of application "Script Editor"
                notify with name "FTP Mail Handler Script" title ¬
                    "FTP Mail Handler" description "FTP Upload: " & ¬
                    theMessage application name "FTP Mail Rule Script"

            end tell
        end if
    end growl_message

    -- Mail Rule starts processing the messages that match
    on perform mail action with messages theMessages for rule theRule
        try
            -- Just another sanity check. Only messages that begin with this prefix get processed.
            set custom_prefix to "iii"
            -- All of my WordPress images start in the same local location
            set localPath to "/Volumes/Macintosh HD 2/Dropbox/Todo Files/Blog/"
            repeat with oneMessage in theMessages
                set receivedSubject to subject of oneMessage
                set outgoingSubject to "Re: " & receivedSubject
                set theSender to extract address from sender of oneMessage
                if (receivedSubject starts with custom_prefix) then
                    set {mail attachment:theAttachments} to oneMessage
                    repeat with oneAttachment in mail attachments of oneMessage
                        set newFilePath to POSIX path of (("Macintosh HD 2:Dropbox:Todo Files:Blog:") & (name of oneAttachment))
                        --growl_message(newFilePath)
                        save oneAttachment in ("Macintosh HD 2:Dropbox:Todo Files:Blog:") & (name of oneAttachment)
                        set fileURL to upload_file(newFilePath)
                        growl_message(fileURL)
                        set mailBody to "File Uploaded to Server: " & return & return & (fileURL as rich text)
                        set AppleScript's text item delimiters to {""}
                        set theNewMessage to make new outgoing message with properties ¬
                            {visible:true, subject:outgoingSubject, content:mailBody, sender:"gabe@macdrifter.com"}
                        tell theNewMessage
                            make new recipient at end of to recipients with properties {address:theSender}
                        end tell
                        send theNewMessage
                        set AppleScript's text item delimiters to ""
                    end repeat
                end if
            end repeat
        on error errmesg number errn
            set AppleScript's text item delimiters to ""
            growl_message(errmesg & return & return & "error number: " & (errn as rich text))
        end try
    end perform mail action with messages

end using terms from

Commentary

It might not be obvious, but this method requires an always-on Mac with Mail running. That’s not a problem for me.

This is written explicitly for my WordPress content structure. This is pretty standard stuff but it’s possible to use another file structure. Just change the urlPath variable appropriately.

I use Growl for notifications. About 1/3 of this script is for error handling and Growl messaging. I like this method because I also use Prowl. Any errors are displayed on my iOS devices almost immediately. I can also look over the Growl logs to see the history. Good stuff.

The script also inserts the link on my Macs clipboard. Since I use Launchbar, that means when I come back to my desk, all the links I generated remotely are right there in my history, ready to paste.

The script replies back to the same email address I sent from. I am not using the AppleScript “reply” method for Mail. It doesn’t work well. Seriously, this is why we can’t have nice AppleScripts.

Usage

This will work from any app that can send an image by email. That covers most of them, including the new iPhoto for iOS.

I wish there was an Acorn for iOS, but iPhoto does some nice stuff with images. It’s not perfect, but it is pretty good for basic image enhancements.


  1. Technically, it will work with any attachment. It should handle multiple attachments as well, but I haven’t been using it that way. 

  2. It’s bad. I’ve tried to provide comments, but that will not make the code any better. I’d clean it up, but I’m planning a total rewrite using AppleScriptObjC. That will take a long time. This works now. 

  3. I use Transmit because it’s the best FTP client around. But it also has some nice features that make scripting easy. For example, Transmit can save my credentials with the FTP connection. The script can then login without ever needing to know the credentials. When I change my FTP credentials, I only need to change them in Transmit, not 25 different scripts. 


12
Mar 12

MPU Interview with Daniel Jalkut [Link]

This is one of my favorite MPU episodes. A bit more technical but not too in-side to be useful to most nerds.


6
Mar 12

Hazel Archive Rule

I’m really having fun with the new Hazel 3. Not only does it have a number of new rules and actions, it’s performance is now good enough to work on large collections of files.

Here’s a file archive rule I made that scans all files and folder in my Dropbox account. When I set a file or folder label color to yellow (my archive label) Hazel automatically moves it to my deep freeze archive on my networked Drobo. It works at all directory levels and on entire folders or a single file. It’s also very fast.1


Hazel Rule


  1. I’d be careful how this rule is deployed. I would not deploy it to the top level of a drive. That’s way too much overhead for Hazel to process with every single change. Keep in mind, Hazel is always scanning these files looking for a status change. I am considering copying this rule to specific levels of Dropbox. 


5
Mar 12

Cheaters System from the Illustrious Brett [Link]

Remember this post and the followup post here for creating cheat sheets? Well, Brett has done an amazing job taking a hack solution and turning it into something gorgeous. Please, go download it and revel in it’s perfection.

For the record, I don’t consider it a “ripoff” as Brett describes. It’s an evolution by someone better than me. That’s awesome.

There are only a couple dozen people in the world doing truly original work. I’m guessing most of them are mathematicians.


3
Mar 12

Hazel Import Into Aperture

Ever since Dropbox added photo download from iOS, I’ve switched off PhotoStream on my iPhone. I got tired of stupid or boring photos showing up in the stream. I decided I would configure the PhotoStream through Aperture. I had good intentions, but Dropbox has slurped over a hundred photos off and I have yet to add any to Aperture. It’s just too easy now to download and never add to Aperture

But one of the new actions for Hazel 3 is to import into iPhoto or Aperture. Light…Bulb.

I setup a rule to watch the Dropbox camera folder. When I set the label of a photo to “purple”, Hazel imports the photos into a specified project folder. Inside Aperture, I have a Smart Album that gathers all photos that match a number of criteria. One of those criteria is the “purple” label. As if by design, the labels from the Finder carry over into Aperture.

Hazel Rule

Now, I can leisurely flag photos to automatically send them into Aperture and later add them into PhotoStream. Selectively. Imagine that. Adding photos to PhotoStream selectively. Crazy, right?


24
Feb 12

A Shortcut Viewer

I posted a tip for creating a Markdown cheat sheet a week ago. That solution used Marked to display the Markdown as formatted text. But I wasn’t happy with needing to open and then close a Marked window. So I got to noodling around and remembered how useful Automator is.

I’ve created a very simple Automator workflow that uses the URL viewer. Rather than loading a remote HTML file, it loads a local file that I created with Marked.


Automator Workflow

I take an ugly MultiMarkdown file with a bunch of tables like this:


Markdown

and load the file into Marked.app. Marked converts all of that awful markdown to a lovely styled page like this:

I then export the HTML to a local file and use that file as a source for my Automator action.

There are a couple of tricks to make this work well. First, escape any problematic characters in the tables. For example, I place a backslash in front of the asterisk and pipe characters so they are not processed as Markdown.

Second, I change the Automator URL view to simulate the iPad browser. This ensures a small display window. I have several smaller versions that use the iPhone browser too.

I think this works nicely. The pop-up hovers over top of other windows, so it does not get lost and the Esc key closes it immediately. Of course, I trigger this with a Keyboard Maestro macro tied to my F6-key. The pop-up looks like this:


Cheat Sheet