Full text lookup bookmarklet

I often want to find the full text article for a PubMed entry. This simple bookmarklet takes the PubMed page for a specific article (like this one) and goes directly to the list of full text options for my library. It beats the "Find at UMB" button that PubMed sometimes displays because it doesn't open a new window.

I'm posting this here because it could be easily modified for a different library.

You can use this bookmarklet creator to make your own bookmarklet with the code above.

If you're from UMB and want to use my bookmarklet, go to this page.

LiveReload Using Guard and Rack With No Browser Plugins

I sometimes want to use LiveReload to automatically refresh index.html when I'm working on some JavaScript. Yes, you can use the $10 app, but I generally end up using Guard anyway for compiling CoffeeScript or SCSS, and I dislike browser plugins because of the security risks. Turns out that it's pretty easy to get LiveReload working with Guard and Rack sans plugins.

The code is in a Gist below. All files go in a single folder (say, ~/git/myproject). To run it (after bundle installing), open two Terminal tabs in this folder. In the first one, run guard. In the other, run ruby serve.rb. Then hit up http://localhost:4567 in your browser of choice. LiveReload should automatically reload the page when you change index.html (as configured; modify the Guardfile to watch additional files for changes).

(These instructions are a little vague, because if you can't easily fill in the blanks you should probably just use the app. It's not worth learning all about Ruby/Gems/Rack/Guard to save $10.)

MailMate: my custom keybindings

I'm giving MailMate a try again after using Mail.app for the last six months. I accidentally deleted my custom keybindings 😢 so I had to re-create them. Here's what I came up with, on top of the built-in Gmail keybindings:

Note that some of these are not listed in the official custom keybindings documentation.

So far it's good to be back in MailMate. Mail.app has been getting slower and slower, especially search, which prompted my switch. So far I like the (fairly minor) changes to MailMate since I used it last.

SAS: Getting 2×2 contingency table variables in the right order with PROC FREQ

By default, SAS will format a 2×2 contingency table like this if you have 1=yes 0=no binary variables:

|           | outcome=0 | outcome=1 |
|-----------|-----------|-----------|
| exposed=0 |           |           |
| exposed=1 |           |           |


But we want it like this:

|           | outcome=1 | outcome=0 |
|-----------|-----------|-----------|
| exposed=1 |           |           |
| exposed=0 |           |           |


The following code demonstrates how to do this:


And here's the output from this code:

AppleScript: Save Clipboard to Text File

This AppleScript will open a "Save as" dialog, which lets you specify a folder and filename, using the folder of the front-most Finder window as the default folder. It will then save the (text) contents of your clipboard to that .txt file.

tell application "Finder"
	if (count of windows) > 0 then
		set theDefault to the POSIX path of ((folder of window 1) as alias)
	else
		set theDefault to path to desktop
	end if
end tell

set resultFile to (choose file name with prompt "Save As File" default name "paste.txt" default location theDefault) as text
if resultFile does not end with ".txt" then set resultFile to resultFile & ".txt"
set resultFilePosix to quoted form of the POSIX path of resultFile
do shell script "pbpaste > " & resultFilePosix

AppleScript to directly open a specific note in Evernote

I keep a daily work log in Evernote, and I wanted a quicker way to open up this note. AppleScript to the rescue!

tell application id "com.evernote.evernote"
	set notebook1 to "Cabinet"
	set myNotes to find notes "intitle:Note title goes here"
	set myNote to item 1 of myNotes
	open note window with myNote
	activate
end tell

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.