I need these URLs for the next step toward total world domination ✍ 7:38:14 PM CST



Lately I've been somewhat into memorizing some of my favorite quotations from books. The most effective method I've found for doing so has been converting each word of whatever text I'm trying to memorize to just the first letter, and trying to reconstruct the passage from that. Here's the theory behind why this is helpful:
This is the crucial concept of any type of memorization. The act of reading something you want to memorize fires different connections than the act of recalling. This means that simply reading a particular piece of text over and over again is going to be the long road to memorization. You need to let your brain practice recalling the data so it can strengthen the same pathways that will fire when you need to remember the information later on. You can’t practice recalling until the information is at least partially contained in your short term memory.
-How to Memorize Verbatim Text
So, say I want to memorize this passage from Pawn in Frankincense by Dorothy Dunnett:
The woman sitting there, straight and still on the bright velvet cushions, was not young; nor was she less than beautiful. The black hair, loose and shining, and deep, fell back over her shoulder and forward down to her waist; her chin was high above the pure line of her neck, which you could have held in one hand. Her eyebrows were black, and arched in pride, or surprise, or over some deep, long-held thought; and below the black, silky lashes, the wide eyes were packed full of straw.
Here's what it gets converted to:
T w s t, s a s o t b v c, w n y; n w s l t b. T b h, l a s, a d, f b o h s a f d t h w; h c w h a t p l o h n, w y c h h i o h. H e w b, a a i p, o s, o o s d, l-h t; a b t b, s l, t w e w p f o s.
The website that describes this method provides a helpful JavaScript tool for performing this conversion, but before too long I was finding copying text into the box on the website a little unwieldy. So, I grabbed the relevant regular expression from the JavaScript code (str.replace(/(\w)\w*/g,"$1")) and turned it into an OS X Service, a transformation that, luckily for me, Snow Leopard has made very easy. All the service does is grab some text, run a simple sed replace command (sed 's/\([a-zA-Z0-9]\)[a-zA-Z0-9]*/\1/g'), and output it.
In case this tool I've created could be at all useful to anyone else, I figured I might as well upload it. To install it, just put it in either /Library/Services or ~/Library/Services.I previously described how to use Ruby and Automator to build a custom Mac OS X service. Today, in celebration of International Talk Like a Pirate Day, I present a quick-n-dirty text Pirate-ization service for Mac OS X Snow Leopard:
gem sources -a http://gems.github.com
sudo gem install mdeering-booty
To make my photos square used a script that i came up with when i experimented with Automator. You can download it here. (Only works with Mac OS X, since it's a Automator action)
You can see them at a bit higher quality over at my Flickr.
Building Snow Leopard Services with Automator & Ruby
Yesterday, Justin Williams posted a quick how-to on using Automator in Mac OS X Snow Leopard to create a service that helps you build clean Amazon affiliate links.
Justin's instructions create a workflow that requires you to manually select just the item's ASIN code, then uses AppleScript to concatenate the rest of the short URL together. He notes:
"The workflow on this isn’t perfect given that you can’t just copy in the entire URL, but given AppleScript’s lack of regular expression functionality, this was the best route I could think of taking."
I thought to myself, "hey, that'd be super-easy to do in Ruby". After a quick perusal of the available Automator actions, I discovered that you can select a Ruby, Python or Perl interpreter with the "Run Shell Script" action. Oh snap!
[Note: apparently the Ruby/Python/Perl support in Automator isn't new. It's there in 10.5 too]
As Justin noted, your typical Amazon URL is way too long and has lots of icky cruft in it. Take this link to the new Beatles Box Set, for example:
I know. Eww. In contrast, the shortest possible link for an item basically has Amazon's base URL, the item's ASIN code, and an affiliate ID:
With a head start from a guy at Microsoft (!) and some quick expression testing with Rubular, I had a working regex and the start of an improved "Create Amazon Affiliate Link" service:
To recreate this service on your own, you'll need to launch Automator and select the "Service" template for your workflow.
You may have noticed that your 'Services' menu (under the Application menu) is far less cluttered than in Mac OS X 10.5. This is because Snow Leopard now uses data detectors to determine if a given service applies to the current app or selection. In this case, we only want our service to be available if a URL has been selected. To do so, set the "Service receives selected" option at the top of the workflow to "URLs". I also suggest that you restrict your service to Safari, so go ahead select it from the adjacent drop-down menu.
Next, scroll to or search for the "Run Shell Script" action, and drag it into your workflow. Set the "Shell:" to "/usr/bin/ruby" and then type or paste in the following:
Change the value of 'affiliate_id' (shown here as my ID, 'nathos-20') to your own Amazon affiliate ID. Don't forget the '-20' at the end. Also, make sure the appropriate lines are properly indented.
This hunk of code features a fancy regular expression that extracts the ASIN code from any Amazon URL. It then concatenates the base Amazon URL, the ASIN, and an affiliate ID together into a final short URL. Lastly, it checks to see if the URL you processed actually contains an ASIN. If it does, the shortened URL is returned. If not, an error message is returned instead.
Since the workflow can take a few seconds to run, I think it's a good idea to add some notifications to the process. If you have Growl installed, you can drag the "Show Growl Notification" action to the end of your workflow. I set my title to "Amazon Affiliate Link Created" and my description to "A new affiliate link has been copied to the clipboard."
If you want an audible notificaiton, drag the "Run AppleScript" action to the end of your workflow. You can enter something as simple as "beep" to play your default system sound:
or something fancier like "say "Affiliate Link Created"" to have your Mac talk to you:Save your service as "Create Amazon Affiliate Link", then give it a try in Safari. Navigate to a product on Amazon.com, press Cmd-L to highlight the URL, then right-click the text and select "Create Amazon Affiliate Link". Alternatively you can activate via the application menu (Safari -> Services -> Create Amazon Affiliate Link).
Lastly, a very cool feature in Snow Leopard is the ability to assign keyboard shortcuts to your custom services. To do so, open the Keyboard System Preferences pane and click on "Keyboard Shortcuts". Scroll down to "Internet" and you'll find our new service. Assign a custom keyboard shortcut and you're up and running! (You may need to restart Safari for your new keyboard shortcut to work)
If you want to download this workflow 'pre-assembled', you can download my copy here. Unzip and place it in your ~/Library/Services folder. Double-click the workflow to open it in Automator and customize it to your liking. Enjoy!
[in case you're wondering, the title of this post is from a classic XKCD comic]

Article found thanks to my friend Nicola "nezmar" D'Agostino