Nik's Blog

Geekery, witty insights, software (of dubious quality) and more!

BBEdit HTML to Text

This script uses BBEdit to convert HTML to lightly formatted text. Unlike BBEdit's "Translate" utility, this maintains links, image ALT text, and even formats headers and bold text as all-caps. The formatting is ideal for making plain text versions of HTML email messages -- which is the reason I created it in the first place.

For best results, drop this in the BBEdit Scripts folder. (you can open it from BBEdit's script menu!)

BinRunner

An Applescript for your Startup Items. This simply executes every shell script in your ~/bin/sh/ directory when the script is run. Useful as an alternative to creating launchd agents to just fire off a handful of scripts as a group.

Convenient Password Generator

There's plenty of password generators out there, but how many of them generate passwords that are both secure as well as convenient?

This script creates just such passwords.

Convenience: The passwords this script generates can by typed with just one hand on the keyboard, and can also be entered into an iPhone without going back and forth between letters and numbers and symbols and capital letters. The passwords also use normal dictionary words that are easy to remember.

Secure: Every password is at least 12 characters long and contains a combination of letters, numbers, symbols, upper case and lower case letters.

Are you sure that's secure?

Okay, sure, a totally random string of letters and numbers and whatnot would be more secure than any password that uses dictionary words. However, by using two words, as well as numbers and symbols, these passwords meet a nice balance between convenience and security. It's a lot easier for me to remember "fate64$!SWAGER" than "}Uc^nGRJ3X3F", and of course it's easier to type the former too.

The truly paranoid should move along, though. If an attacker knew you were using this system, then they would have a much smaller set of possibilities for a brute-force attack -- and the ability to just download the script and steal the word dictionary.

Update: Added about a thousand more words to the list to make this more secure. There are now over four million potential combinations of words, letters and symbols.

Create new files in Evernote

I’ve gotten in the habit of attach meeting notes and brainstorming documents to my Evernote notebooks. They’re editable from the notebook and sync to all my computers and my phone, which is incredibly handy. One limitation that I’ve found is that it’s impossible to create a brand new document within Evernote… until now!

This AppleScript creates new files in the currently selected/viewed note, based on file templates you create. These templates are just documents of any sort that you put into the “New File Templates” folder in your documents folder. (This folder name can be edited as a script property.) When you run the script, it will let you select from those templates, set your file name, and then you’ll have a new file right there in your note! Easy peasy!

Note that you may want a premium Evernote account in order to handle the upload size of adding lots of files.

Drupal quick-post bookmarklet

Perhaps I’m being dense, but I’ve spent about four hours today trying to get a decent quick-post bookmarklet set up for Drupal. (And no, this isn’t a version 5 problem, I’ve never had such a thing.)

While I found many sites that had advice on crafting an appropriate URL, none of them mentioned that I needed the prepopulate module in order for any of them to work.

Additionally, only one person mentioned that I needed to put “edit[body_filter][body]” into the URL string rather than the more commonly suggested “edit[body]”.

So, in interests of saving people time, those are the two tricks to getting this to work. I’ve attached my javascript as a text file (it assumes you’re using Markdown for formatting, adjust as necessary for HTML) since it’s rather ugly to paste it inline.

I hope this helps somebody. I know I’ve wasted way too much time on it already.

Evernote Bookmarking Tools

I use Evernote in lieu of in-browser bookmarks. (You can read more about this project and how it works for me here.) I have two scripts I use to make this a little easier on me:

Append source HTML to selected notes: This takes selected notes with an associated URL and attaches the content of the URL’s page to the respective notes. If you change the “useIP” property to true, it will also trim down the source with the Instapaper service, thus eliminating ads, navigation, and comments before importing the HTML. I used this originally when I imported by Pinboard bookmarks into Evernote, but occasionally use it with other notes that I’ve just added my own comments to, so as to make them “full text searchable.”

Export Notes as HTML Bookmarks: This script takes every URL stored in Evernote and exports it into a simple HTML file that contains nothing more than a series of links, labeled with the title of the associated notes. I use [LaunchBar] to index this file (added it to LB’s index as a custom web bookmarks file), making it easy for me to quickly open bookmarks without even having to open Evernote. Use your favorite scheduling utility to make this happen on a regular basis. (I use Keyboard Maestro

Evernote Services for Snow Leopard

Updated October 2, 2009!

With Snow Leopards new services support, I’ve updated the old “Send to Evernote” service to include three services:

  • Clip Text to Evernote: This is the original “Send to Evernote” service, with the improvements provided by Snow Leopard. This service takes selected text and turns it into an Evernote note. It will also grab the name of the frontmost window for the title of the note so that you’ll remember where you clipped it from.

  • Clip URLs to Evernote: This takes any selected URLs, and downloads the contents of those URLs into Evernote. Very handy if you have a reading list of URLs and want to save them for later.

  • Clip Files to Evernote: This will accept files and folders and attempt to clip them to Evernote. In some cases this will fail if the file isn’t supported by Evernote (although premium users can attach anything they want). If it is a supported file type, the document’s contents will become the note, rather than just attaching as a file.

Installation’s easy. Just unzip the archive, and put the services you wantin your ~/Library/Services/ folder (make one if it doesn’t already exist).

This will also let you get rid of the little elephant in your menu bar if you like.

Find iTunes songs without album art

The perfect script for the obsessive-compulsive iTunes user! Want to make sure all your albums have artwork? Then this is the script for you!

When run, this script will create a new playlist, entitled "::No Album Art::", containing all your iTunes music tracks which don't have any associated album artwork. (This is best used after running *Find Album Artwork* from the iTunes 7 *Advanced* menu.)

Once you have all your artless files in a playlist, you can then easily update their artwork manually, or using the [Album Art widget for Dashboard](http://www.liquidx.net/albumartwidget/), the [iTunes Companion](http://www.widgetgallery.com/view.php?widget=33155) Yahoo Widget, or any of the [many other album art grabbers](http://www.macupdate.com/search.php?keywords=itunes+album+art&os=macosx).

This does take a pretty long time, so be patient. Any errors are logged to the system.log (viewable via the console).

To install: Either run it directly from Script Editor, or copy it to ~/Library/Scripts/Applications/iTunes/ to use it from the script menu.

Hide and Restore Desktop Icons

This is a handy little AppleScript that takes all the clutter on your desktop and packs it up neatly and out of the way. Run it again, and it'll unpack you and put your mess back just the way you like it. Handy for presentations or before you have visitors.

Run this script, and all the files and folders on your desktop will be cleaned up and dropped into a "Desktop Items" folder. When you're ready to get back to work, run the script again, and everything from the Desktop Items folder will get put back where it came from, as though they had never left.

And yes, you are free to keep working on files in the Desktop Items folder until you're ready to unpack. If you add items to the desktop after de-cluttering it, you can just run the script again to pack those ones up, or you can unpack right on top of them. Totally up to you. The "Clean Up" command is handy here to avoid double-decker icons.

Disks and whatnot on your desktop are just tidied up by name, no big whoop.

A lot to say about a simple script. Run. Clean. Run. Messy.

Hotkey Access to Google Chrome Bookmarks Bar

I've recently made the switch to Google Chrome, thanks in no small part to my taking on Pinboard as my bookmarks engine. Something I miss from Safari (about the only thing!) is the keyboard shortcuts for my first 10 bookmarks in my bookmarks bar. (CMD+1 through CMD+0)

Here's a series of Applescripts that do exactly that: Click your first 10 bookmarks. You can take these scripts and use your tool of choice to add hotkeys.

Unlike Safari's, this will work whether or not your bookmarks bar is visible. You can even use it outside of Chrome and it will bring Chrome to the front and then click the bookmark. Fancy!

And yes, this would make much more sense as a Chrome extension. Unfortunately, that extension has been built, and it doesn't seem to work very reliably.

iMovie '08 Library Compressor

This is a simple program to reduce the size of your iMovie 08 library.

I love iMovie '08. I know, I know, it has less whizzy features than iMovie '06 does, but darn it, it's so darn fast and easy to build videos. I can create a whole hour-long movie in about ten minutes! (Not a very good one, of course -- but none of my movies are very good.)

Part of why it's fast is that it keeps all my clips on hand, ready and willing to be part of my latest (crappy) movie. Unfortunately, all those barely-compressed DV clips take up A LOT of space. (About 10 GB/hour of video!) This application will compress all the DV files in your iMovie library to save huge amounts of disk space! Using Apple's H.264 compression technology, you can shave 70% off your library space with *minimal* loss of quality.

**UPDATE:** v1.2 works with SetFile installed in /usr/bin as well as in the default /Developer/Tools directory.

This is a simple applet, just double click it, select your chosen compression settings (from a pristine copy that shaves off 10% of the file size to a clip that's 93% smaller than the original, and only suitable for posting on YouTube), and let it work its magic. Your library will sweat off the pounds, and your original raw DV files will be set aside to be archived, thrown away, or whatever you want to do with them.

Note that any projects which use your DV-formatted clips will need to be rebuilt pretty much from scratch, as the clips they reference will no longer be in your library. You may want to export those projects before compressing your library.

This does not work with iMovie '06, which can only use DV/HDV formatted video for its projects.

This applet is released free of charge, and you're welcome to modify it and do what you wish with it, provided you give me credit if you release a version with modifications.

### System Requirements
* A Mac capable of running iMovie '08 with at least some DV videos in your events library.
* [Quicktime Pro](http://apple.com/quicktime/). The standard version can't export video. Sorry.
* [Apple Developer Tools](http://developer.apple.com/). In order to set the creation date of the exported file, you need the SetFile command-line utility that's installed with the developer tools.

Import TextExpander Snippets Into Keyboard Maestro

This script exports your TextExpander snippets as ".kmmacros" files, suitable for import into Keyboard Maestro 5 as typed key macros. Due to differences between the two applications, this is not a perfect conversion, so snippets that are likely to need additional work are marked with an asterisk after import.

This script uses BBEdit as an intermediary to build the files, but could fairly easily be altered to work with another text editor.

Keynote Whore for Google Chrome

Occasionally there will be, say, an Apple keynote speech, that is live-blogged from multiple sources. Rather than wear out your CMD+R fingers reloading tons of tabs and windows to get the absolute latest liveblog updates every second, you can use Keynote Whore to automatically refresh Google Chrome windows and tabs every 30 seconds, ensuring you're always looking at the latest and greatest.

Why Chrome? Well, I use Safari primarily, so Chrome makes for a nice background browser that'll sit and run. But don't worry, if Chrome's your main browser, the applet will let you select specific windows to refresh. (All that windows' tabs will refresh each time.)

Now you can rest easy, knowing that you're going to be the very first geek to know about the latest iWhatever! (Well, first geek outside of the live keynote...)

Lorem Ipsum and More

This is a collection of three AppleScripts to generate "greek" type to fill in for designers and anyone else who just needs some random copy.

There are three different versions of placeholder text:

Lorem Ipsum: Generates a random set of paragraphs using the much-loved Lorem Ipsum passage.

Lorem Chomsky: Generates obscure and academic text in the style of Noam Chomsky

Lorem Bullshit: Pardon the colorful wording, but this is aptly named. It creates Dot-com/IT/Web-2.0 marketing BS speak. Synergies and paradigms abound!

Run these scripts to generate three paragraphs. If you execute from LaunchBar you can pass a string with the number of paragraphs you'd like to generate.

The dictionaries were adapted from other sources and are credited within the scripts' source.

Markdown to Microsoft Word Service

Markdown to Word is a ginchy little service that will take Markdown-formatted text, and put it into Microsoft Word, making use of Word’s style sheets to do so.

This is in all ways identical in function to my previous TextMate script which does the same thing, except that this also auto-formats once in Word.

You may notice some funniness in the conversion. Lists, in particular, sometimes don’t convert perfectly. This is part of Apple’s textutil program, which is very handy, but sometimes a little… er… special in how it handles things. I take neither blame nor credit for its output.

IMPORTANT! This service relies on the setfile utility, included with Apple’s free “XCode” developer tools. You’ll need to have those installed (at least the developer applications).

And, of course, this program wouldn’t exist were it not for John Gruber’s “Markdown.” Mr. Gruber retains all copyright, etc., to said code. Disclaimers can be read below and are included with the Zip archive.

http://www.daringfireball.net/markdown

I am eternally grateful to Mr. Gruber for giving me Markdown. Without it, I’d probably be writing in LaTEX or something. Ugh.

OmniOutliner List Manager

This set of Applescripts lets you use OmniOutliner Pro to keep a variety of lists on your computer and easily add items to them from the script running application of your choice. (Including LaunchBar or Quicksilver!) These lists can also be set up to automatically sync to your iPod as iPod notes in order to take 'em with you on the road.

What kind of lists? Well, anything! A list of presents to buy, movies to rent, books to read, things to do before you die, groceries to pick up, names for your unborn child... The mind boggles!

A lot of people use text files for these kinds of lists. Call me an interface nerd, but I prefer something a little more... robust to maintain my lists. Specifically, I like OmniOutliner. So, I made this little program to give me the ease of use and flexibility of a text file within the wonderful interface of OOP.

Requirements:

* OmniOutliner Professional 3.x
* MacOS X 10.x (tested in 10.4, but it should work in earlier versions)
* Optional: Launchbar or Quicksilver for rapid list entry
* Optional: iPod to carry your notes with you

These scripts will probably work with older versions of the MacOS and OmniOutliner, but I've only tested them under MacOS X 10.4.

*Note: Downloads were broken for a while. They work now. Sorry for the trouble.*

OmniWeb 5 Ad Blocking Lists

OmniWeb 5 has an excellent ad blocking mechanism. What it doesn’t have is the ability to easily subscribe to or import some of the blacklists out on the internet, such as those used by the Adblock Plus Firefox add-on.

In order to make up for this deficit (at least partially), I downloaded the latest EasyList filter list and modified it so that it uses proper, OmniWeb-compatible, regular expressions.

The one downside with this list is that there is no way to automatically import the blacklist and whitelist files into OmniWeb. Instead, you have to edit OmniWeb’s preferences file directly to add the entries. Instructions on how to do this are included with the rest of the download.

I have no plans to continue updating this list. It’s current as of March 11, 2008. Consider it a good start for your ad filtering and update it manually as needed. I’ve included instructions on how to make your own custom file if you’re so inclined.

Procrastinate Better With an Untrustworthy Clock

Sometimes I run late. Late to meetings, late to go home, late to pick up kids... I know I'm not alone, too. So I fixed this problem with a handy little script I call "Procrastinators Friend". This script is pretty simple, it just sets your clock ahead by a random amount, between 5 and 15 minutes. I then set this up to run every hour, so I'll never quite know how fast my clock is running. In order to prevent this from going crazy, it also syncs up your time with a network time server before adjusting it, so you'll never be too fast or slow.

Naturally, the buyer should beware, here. System tools that rely on modification dates to do stuff will be thrown off by this little script. But maybe that's worth it to be on time, every time.

Use cron or launchd to run it regularly.

Search the Amazon MP3 store from the iTMS

Now you can browse the iTunes Music Store and search for songs you like in the higher-quality, cheaper, and DRM-free Amazon MP3 store!

Just select some songs you like while browsing the iTMS and run this script, and your browser will open up searches for each selected song. If you don't have any songs selected, it'll just search for the first song in the list.

Why would you want this? Well, the iTMS has a very nice browser and some convenient integration with your playlist (especially with the new Genius sidebar). This way you can take advantage of that nice browser, but still buy a high quality, DRM free, MP3 version of the songs you want.

It's kinda like going to Best Buy to try out a computer and then buying the computer on Amazon. Except with music.

Super Oda Dice Roller

Super Oda Dice Roller is an unobtrusive but powerful dice rolling program for use with tabletop role-playing games such as Dungeons and Dragons. It accepts text input as dice strings and rolls numerous dice with lightning speed!

*Example: 4d6+3d8+(4d8-5+2d6)/1d20*

It gets even better (and more "geektacular") if you use the included Applescript in concert with LaunchBar or Quicksilver and growl. Together, they turn your Mac into a dice rolling monster, capable of rolling dice without ever leaving your current application! How cool is THAT?!

**Requirements**

* MacOS X (tested on version 10.4.3, but should work on earlier versions)
* Ruby (tested on version 1.8.2 which comes with MacOS X 10.4 and later)

Optional:

• [Growl](http://growl.info/)
• [LaunchBar](http://www.obdev.at/products/launchbar/index.html) or [Quicksilver](http://quicksilver.blacktree.com/) to run the included Applescripts for easy launching.

**Version History**

* 0.2.1b: First public release.
* 0.3b: Combined LaunchBar and Quicksilver scripts. Added interactive Applescript ability. Streamlined code. Added error trapping in Applescripts for bad rolls.
* 0.4b: Eliminated the wacky QS/LB/terminal/interfaceless functioning and rebuilt as an Applescript Studio application! Now it has a window and all kinds of good stuff. Version 0.3b is still available for command line wonks and people who like Quicksilver/Launchbar integration. You can get it here:
* 0.5b: Added Growl notification support (optional). Bundled an Applescript, "Roll Super Oda Dice.scpt" which restores the Quicksilver/Launchbar functionality. Added an awesome icon, courtesy of Forrest Walter.

Using HTML Forms With AppleScripts

What if you could use an HTML form in place of an AppleScript dialog box?

AppleScript dialogs are terribly limited, which often forces a scripter to chain together a dizzying series of sequential dialogs and alerts. The alternatives either require additional software, or to tackle XCode and the newer and more complicated AppleScript Studio.

But thanks to AppleScript's ability to take advantage of URL handlers, you can use an HTML form to pass values to your AppleScript.

Rather than try to explain it in too much detail, I've attached a demonstration to download and try out. This is an application that writes a simple "thank you" letter to a relative. Just open it to run the script. You can fill out a form to create the letter, and then you can just click links to have the letter read out loud, edit in in TextEdit, or erase it and start over.

Under the hood, what's happening is:

1. The applet registers the "thankyou://" URL scheme

3. It opens up an HTML page in it's bundle's resources folder. The HTML page sends requests using "thankyou://" URLs (the form is sending a GET request, so it does the same)

4. The applet receives these events, parses the URL, and then acts on them depending on the "location" of the URL

The first step is well documented at MacOSXAutomation.com. Step 2 is straightforward HTML form building and a little AppleScript in the "run" handler to open the bundled HTML file. The last step is straight AppleScript, using an "open location" handler to receive and parse the incoming URL.

The parsing is the really tricky part, but as luck would have it, I've taken care of this for you.

If you open the script in AppleScript Editor, you can see the bundle contents and take the script apart. The complicated part is the "newURI()" handler and associated script object. It breaks down the "thankyou://write?n=Jimmy..." style URL into an object with useful properties, such as location and a record set of arguments. This handler can be pulled unmodified from this script and put into your own applications -- it's entirely agnostic as to the URL scheme or individual arguments it receives.

The rest is just taking the properties of that object and passing them to an if/else tree that checks the "location" of the URL and acts accordingly.

This is, of course, a frivolous example, but it demonstrates how powerful a tool this can be. With a little more complexity on the HTML side of things, a little javascript could work to pull in data from other sources, create more dynamic forms, and provide up-front data validation.

The one limitation of this method, compared to traditional dialog boxes, is that you cannot put any forms in-line with the script's execution. But for scripters who just want some up-front configuration, this can be a very flexible tool.

If you have any comments or feedback on this, sound off in the MacScripter forums.

Legacy Software

Here’s where you can find old scripts and goodies that, in many cases, have outlived their usefulness. They’re here in for those who still rely on them, eager and willing to work as well as they did on the day they saw daylight.

They are, however, entirely unsupported. Let the downloader beware.

In many cases, there are good alternatives, specifically:

@inik

inik: RT @chartier: Georgia house democrats introduce a state ban on vasectomies for men. Fantastic: http://t.co/XIoyVv1P >
inik: RT @eshanfelt: New Google glasses by end of the year ... cool, yet somehow disturbing at the same time. #want http://t.co/MR4fLsdZ >
inik: In the next Dan Brown novel, a secret scroll is ultimately found under the 2-year-old's booster seat, covered with creamed spinach. #mylife >
inik: @dcurtis @dcurtisfeed Retweet, please. >
inik: RT @Cabel: The Internet is rough on organized religion, but thanks to churches (that rent steeples to carriers) we all have better cell ... >

Google+

I love Seth's quote at the top. I think that's my new motto.. ; )

Powered by Plu.sr
>
Griping about OS X Lion? Here's two nifty tools that replace a variety of poorly supported third party tools: Command-line and Automator access to video and audio conversion. Super easy to use, and very flexible and supports any format that Quicktime can encode/decode. (So Perian is a must-install if you want to handle DivX/3viX, etc.)

Yes, ffmpeg, Handbrake and...
>
Fix Google Reader's horrible new interface with this user script! Now it fits nicely on my MacBook's small screen. >
Happy 11/11/11 11:11:11! >
What makes this ad awesome is not the true-to-life irony, because the idea is hardly innovative, but rather the excellent execution. Reminds me a bit of that excellent Nutri-Grain spec commercial. Quick delivery, good actors, hit all the high notes. Love it. >