AppleScript to open a new Safari window directly to the compose page in FastMail

Sometimes I like to be able to write an email without seeing the new messages in my inbox. This AppleScript (triggered with LaunchBar of course) solves this problem. It opens a new Safari window directly to FastMail's compose page.

Because FastMail loads so quickly and Safari is generally pretty fast fast, this is essentially the same speed of LaunchBar's "Compose Email" action for Mail.app.

tell application "Safari"
	make new document with properties {URL:"https://www.fastmail.com/mail/compose?u=FILL_IN_FROM_FASTMAIL_URL"}
        activate
end tell

AppleScript to find FastMail tabs in Safari

I'm using the FastMail web interface more and more recently, but I keep losing the tab I keep it open in.

I found this AppleScript that is supposed to search Safari tabs based on the contents of a URL, but it gave me an error. So I fixed it (and hard-coded "fastmail.com" as the string to search for in the URL). I saved it as a .app file in Script Editor and trigger it with LaunchBar.

Update 1here's a (low-res) transparent icon pulled from FastMail's website that you can use for the .app created by Script Editor.

Update 2 (January 16, 2015): I've updated the script to fix a few bugs (like the window with the FastMail tab not actually coming to the front), and to automatically open FastMail in a new window if there isn't a current table open.


Terminal command to convert WAV to MP3

From the Apple StackExchange (user nqw1), this Terminal command will take all the WAV files in a folder and turn them into MP3s:

find . -name '*.wav' -maxdepth 1 -exec /usr/local/bin/lame -V 0 -q 0 '{}' \;

Apparently this is the highest quality (V is the best variable bitrate and q is the quality). This is apparently a bit faster and is the recommended setting:

find . -name '*.wav' -maxdepth 1 -exec /usr/local/bin/lame -V 0 -q 2 '{}' \;

Bookmarklet to re-perform a Duck Duck Go search on Google

I use Duck Duck Go as my primary search engine, but I often need to repeat a search on Google – Duck Duck Go is good, but nowhere near as good as Google for some searches, unfortunately.

I created this bookmarklet to prepend "!g" to the search and re-submit the search form. This will automatically perform the same search on Google.

If you use Safari and place it near the beginning of your bookmarks bar like I did, you can use ⌘3 (in my case; it's the third bookmark from the left) to trigger the bookmarklet.

Here's the "URL" for the bookmark that contains the JavaScript to do this:

javascript:(function()%7B$('%23search_form_input').val('!g%20'+$('%23search_form_input').val());$('%23search_form').submit();%7D)()

(To install, you'll have to manually make a new bookmark in your bookmarks bar with the URL as the code above.)

Mail.app: Get URL for selected message with AppleScript and TextExpander

I often use message://<message-id@example.com> URLs to reference a specific email in OmniFocus or Evernote: clicking one of these URLs will automatically open up the source message in Mail.app.

There's not a great way to get these very handy message URLs without AppleScript, so based on this SuperUser answer, I created a TextExpander snippet.

Now, when I type xmsg, TextExpander will insert the message URL for the selected message in Mail.app into whatever application I'm working in.

Here's the TextExpander snippet, and here's the AppleScript:

tell application "Mail"
	set selectedMessages to selection
	set theMessage to item 1 of selectedMessages
	set messageid to message id of theMessage
	-- Make URL (must use URL-encoded values for "<" and ">")
	set urlText to "message://" & "%3c" & messageid & "%3e"
	return urlText
end tell

Safely getting a MD5 checksum for a file

There are lots of 3rd party utilities out there for getting the a checksum of a file, but with sensitive data it's best to not read your files into any untrusted application.

Here is how to get MD5 checksums using only 1st party functionality from the OS vendor (Apple or Microsoft).


Mac

Download MD5.app, which is a thin wrapper around the built-in md5 command line utility (based on this AppleScript). If you run MD5.app, it will ask you to pick a file to checksum. If you drag a file onto MD5.app, it will checksum that file immediately.

You can verify the (very short) code for this application by opening AppleScript Editor.app, going to File > Open, and selecting MD5.app.

You can also run md5 /path/to/file.txt in Terminal.app.


Windows

Of course, this is not nearly as easy on Windows.

  1. Go to this Microsoft knowledge base page and click the download link for the File Checksum Integrity Verifier utility package midway down the page.
  2. Run the downloaded file, agree to the terms, and select your Desktop as the location to extract the files to.
  3. Two files will be extracted: ReadMe.txt (delete this) and fciv.exe. Create a folder for this at c:\Users\yourusername\fciv\ and move fciv.exe to this folder.
  4. Go to Start > Run, type "cmd", and press Enter to open the command prompt. You should already be in c:\Users\yourusername. Type "fciv\fciv.exe -add c:\path\to\file\to\checksum.txt"


Windows – Update (2019-08-26)

You can also use PowerShell to do this:

CertUtil -hashfile yourFileName MD5

(source)

OmniFocus 2: Quick defer + due date entry with TextExpander

In OmniFocus 2, there is not a good way to quickly enter a defer date and then a due date: it involves tabbing a bunch of times or using the mouse to move between fields.

TextExpander to the rescue!

I use the following snippets to set the same defer + due date for tasks:

  • Tomorrow at 9am: xx1 → tomorrow 9am%key:tab%%key:tab%%key:tab%%key:tab%tomorrow 9am%key:enter%
  • +2 days at 9am: xx1 → 2 days 9am%key:tab%%key:tab%%key:tab%%key:tab%2 days 9am%key:enter%
  • Next Monday at 9am: xxmon → Monday 9am%key:tab%%key:tab%%key:tab%%key:tab%Monday 9am%key:enter%
  • Next Saturday 9am: xxsat → Saturday 9am%key:tab%%key:tab%%key:tab%%key:tab%Saturday 9am%key:enter%

I also have "x1", "x2", "xmon", and "xsat" set up to work in the quick entry box, which requires a few less tabs.

You can grab all these snippets here.



Update:

Ken Case of The Omni Group explains that users will only have to press tab four times if they have the "All controls" checked in the Full Keyboard Access portion of System Preferences > Keyboard Preferences > Shortcuts. I always have this turned on, like many users, so I can tab between form controls.

So if you don't have this enabled, you'll need to adjust the number of tabs in the TextExpander snippets. I still think this idea is useful for quickly setting defer+due dates if you often use the same sets of dates, even if the fields are only one tab away.