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"

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.


OS X: Set the output device for sound effects with AppleScript

When I switch audio output devices from LaunchBar, sometimes Mavericks decides to change my system sound effects to my laptop's internal speakers rather than the selected audio device, which is what I always want.

The command line utility I use to switch audio output sources doesn't support changing the sound effects output device, so I threw together an AppleScript. The AppleScript has to pull up the Sound panel in System Preferences on the screen, so it takes a second to run, but it's still way faster than doing it manually.

FastMail: Hide unread count for folder with a Userscript

I just wrote a JavaScript snippet to hide the unread count on folders in the FastMail web interface's sidebar. I use this with Fluid.app's Userscript support.

Here's the snippet:

window.mmHide = function() {
    jQuery('.FolderTree span:contains("Folder 1 name here") + .badge').hide();
    jQuery('.FolderTree span:contains("Folder 2 name here") + .badge').hide();
    // Duplicate previous line as needed
}

jQuery(function() {
    setTimeout(window.mmHide, 1000);
    setInterval(window.mmHide, 10000);
})

You'll need to also include jQuery as a Userscript. (You can just copy/paste the minified jQuery above this snippet in your Userscript.) I'm sure there's a non-jQuery way to do this but I already have jQuery available so this was easiest.