Zotero: quickly get links to library items using zotero:// url scheme links

I use Zotero for managing my digital library of scientific papers. Sometimes I want to link back to papers in my Zotero library from other applications, but there's no built-in way to do this.

Fortunately, Zotero is incredibly extensible and has a solid community of users who have developed various add-ins. Based on some plug-ins linked to in this forum thread, I created a Translator plug-in to get the output I wanted.

Here's how it works:

1) Select one or more papers in Zotero:

2) Press command-shift-c (on the Mac; probably ctrl-shift-c on Windows) to a "Quick Copy", or drag-and-drop the selected items onto another application.

3) You should see output like this:

zotero://select/items/0_HGFPVI65 - Sickle cell trait is not associated with endemic Burkitt lymphoma: An ethnicity and malaria endemicity-matched case-control study suggests factors controlling EBV may serve as a predictive biomarker for this pediatric cancer: Sickle cell trait and EBV loads in endemic Burkitt lymphoma - International Journal of Cancer (Mulama et al. 2014)

zotero://select/items/0_Q8GZQSJT - Rates and determinants of seasonal influenza vaccination in pregnancy and association with neonatal outcomes - Canadian Medical Association Journal (Legge et al. 2014)

zotero://select/items/0_HKRG6JXP - Capture–Recapture Method for Estimating Annual Incidence of Imported Dengue, France, 2007–2010 - Emerging infectious diseases (La Ruche et al. 2013)

zotero://select/items/0_9QST5VPW - Lifetime pesticide use and telomere shortening among male pesticide applicators in the agricultural health study - Environmental health perspectives (Hou et al. 2013)

The "zotero://" links will take you directly to the corresponding item in Zotero. 


Installation instructions

To install, grab the code from this gist and create a new file in the "translators" folder in your Zotero library folder called "modified-zotselect-link.js". Then go to your Zotero preferences, open the "Export" tab, and select "Modified ZotSelect Link" from the "Default Output Format" dropdown under "Quick Copy".

How to fix disappearing calendar invitations sent from an iCloud calendar

I recently ran into an annoying situation where invitations sent using my iCloud calendar (from iCloud.com and from Calendars.app on OS X).

Let's say I'm inviting john@example.com to an event:

But, john@example.com never receives my invitation!

What is happening is that iCloud sends calendar invitations on the server side. So when you invite someone to an event in any iCloud client (Calendar.app, BusyCal, iCloud.com's calendar, etc.), the client creates the event with the invitation on the server, and then the iCloud server sends an email to whatever address you specify with the invitation (john@example.com in this case).

This works great except when John has added john@example.com to his Apple ID. (He might do this so he can send iMessages from this email address, for example.) If John has done this, the iCloud server that usually emails invitations decides that he must be using an iCloud calendar and the invitation goes straight into his iCloud calendar notifications. It is never delivered to his inbox as an email, like would happen for non-iCloud users.

Solutions

There are two ways to fix this problem, but unfortunately they are both on the recipient's side (there's nothing you can do as the event creator).

First, the recipient needs to go to https://applied.apple.com and look under "alternate email addresses" to see if his email address is listed here. If it is, there are two options:

  1. Remove the email address from the Apple ID (which may break other Apple services like iMessage using this email account); or
  2. Go to https://icloud.com, log in, click on the "Calendar" icon, click on the gear in the bottom left corner, click "Preferences", click "Advanced", and then change "Receive event notifications" from in-app to "Email to john@example.com".

Bottom line

If you use iCloud calendars to send events to people who do not use iCloud calendars, but might have associated their email address with an Apple ID, you have to manually check with them to make sure they received your event invitation. 😒

SAS: best practices for working with datasets and libraries

The way SAS handles datasets and libraries of datasets is fiddly, and can cause big problems with analysis if not handled properly. Here, I explain briefly what SAS is doing behind the scenes and how I avoid common pitfalls.

Datasets in SAS

A SAS dataset is essentially a glorified Excel sheet (each variable is a column; each record is a row). SAS saves datasets in folders somewhere on your computer (more on that below). These files have an .sas7bdat extension. The name of the dataset in SAS matches the beginning part of the filename (the part before the .sas7bdat).

Libraries in SAS

A library is a collection of multiple datasets. It maps to a folder on your computer with .sas7bdat files in it. You can give the library a short alias that's 1 to 8 letters long. You do this by placing libname baz "c:\path\to\folder"; at the top of your SAS Editor file.

In the screenshot above, the first line of the Editor window is telling SAS to look in c:\path\to\folder whenever the library "baz" is referenced. On the third line, data=baz.foo is telling SAS to look in the folder with the alias "baz" (that's c:\path\to\folder) for a file called foo.sas7bdat.

The default library (work)

Perhaps the most confusing thing in SAS is what happens when you don't specify a library name when referencing a dataset. SAS has a temporary library it calls "work", and this is used whenever you don't specify a library. Datasets in "work" are deleted every time you restart SAS.

This makes the following two editor windows exactly equivalent.

This is convenient but confusing, because proc contents data=foo; and proc contents data=baz.foo; are referencing two entirely different datasets.

Note that you can see the library and name of the dataset when you run proc contents;:

Best practices

Here's how I avoid confusion about datasets and libraries in my own code:

  • I always use the full "libname.datasetname" syntax so there's no ambiguity about whether I'm using "work" or my own manually defined library.
  • I only use "work" for something that's truly temporary. Anything I want to reference in a later proc, I save to a manually defined library so it won't disappear if I close SAS.
  • If I create a dataset based on an existing dataset, I prefix the name with "drv" like this. This stands for "derived", which tells me that it's based on another dataset and could theoretically be recreated by running my code again. In contrast, my raw datasets with no "drv" prefix can't be reproduced by running my code.
  • I use descriptive names for my derived datasets. "drv_foo1" and "drv_foo2" are not particularly helpful when trying to remember what has changed between them. "drv_foo_drop_missing" is much better.
  • SAS will allow you to run proc whatever; without explicitly specifying a dataset. I never do this because it makes it ambiguous which dataset I'm using.

An example

If I was doing a Broad Street Pump analysis, I would make a folder called c:\projects\broadstreet where I would save all my SAS Editor (.sas) files.

I would also make a subfolder called c:\projects\broadstreet\data where I would point my SAS library at with libname broadst "c:\projects\broadstreet\data"; at the top of my Editor file.

If my primary dataset was called "primary", then I would expect there to be a file on my computer called c:\projects\broadstreet\data\primary.sas7bdat.

I would then use "broadst.primary" to reference this dataset in my procs. For example: proc contents data=broadst.primary;.

How to enable old-style listing output in SAS 9.3 and best practices for sharing SAS output

Starting with version 9.3, SAS has switched to using the "new" ODS HTML-style output in favor of the "old" listing-style output format. While the new format is arguably easier to read, it may be more difficult to copy/paste into documents or emails.


How do you get the old-style listing output in SAS 9.3?

Add the following line to the very top of your SAS Editor file:

ods listing; /* Turn on old style output */


How to you avoid weird ƒ characters when copying/pasting listing output?

SAS uses a special font for displaying lines in listing output. If that font isn't available or isn't selected, you get strange characters instead of lines.

There are two ways to fix this. The first is to paste your SAS output into the form on https://sasfix.herokuapp.com, and then paste from the website into your document/email. This looks the best but requires an extra step.

The second is to add the following line to the top of your SAS Editor file. It doesn't look as good but it saves the extra step of the first method.

options formchar="|----|+|---+=|-/\<>*";

Here's what both look like:


Remember to use a monospaced font

If you paste SAS output into Microsoft Word or a similar editor, you should use a monospaced font like Courier New.

MailMate: select previous (older) message on archive

If you want to mimic the Gmail behavior of selecting the next older message after archiving (MailMate by default selects the message above the one you archived if you're sorting from newest to oldest), you need to toggle this hidden preference:

defaults write com.freron.MailMate MmMessagesOutlineMoveStrategy -string 'previous'

This is posted in the MailMate bug tracker, but I wanted to post again here to potentially enhance googleability.

Update: this is also posted on the official documentation page for hidden preferences.

MailMate: add "open in MailMate" link to FastMail's web interface

Search in MailMate works great in terms of accuracy, but is a bit slow with ~65,000 messages (searching "common headers or body", which is the most resource-intensive search option, but I prefer to search everything from one field a la Spotlight). Search in the web interface for FastMail (my email provider) is both accurate and very fast. So why not use FastMail for searching and MailMate for everything else?

To this end, I made a quick-and-dirty Chrome extension for adding a "Open in MailMate" link to FastMail's web interface.

No guarantees this will work for you because it's quite a hack. It has to load the raw message via an XHR request and then find the "message-id" in order to build a message:// URL that will trigger MailMate.

When MailMate opens the message, you can use the Message > Go to Source menu item to show the message in context (possibly followed with showing all messages in a thread).

Head over to GitHub to grab the extension.