I often end up with tons of Finder windows open. I usually realize this when I ⌘-tab to Finder and notice there are 20 windows. I generally want to keep the frontmost window but close all the others. Turns out there is a super simple AppleScript to do this (source):
I know literally nothing about GIS, but I need to figure it out because I need to do some spatial querying. Specifically, I need to find all the Census Blocks that are in a given urban area. This is a I'm documenting it here for anyone else who needs to get into GIS and doesn't know where to start.
QGIS is the application of choice here. It's like open source ArcGIS. ArcGIS is the Microsoft Office of GIS.
Setup on OS X
You need matplotlib from this page.
Download QGIS (open source ArcGIS). You need the GDAL and NumPy installer from this page as well.
Opening Census shapefiles
I want to work with this shape file from the Census for urban areas (ftp://ftp2.census.gov//geo/tiger/TIGER2010/UA/2010/tl_2010_us_uac10.zip). Download, unzip. The in QGIS go to Layer > Add Layer > Add Vector Layer...
Looks like it works.
Adding another layer
I want to look at Census Blocks in a specific urban area. For example, Abbeville, LA (UACE=00037) as defined here.
Same deal as before for adding the layer (ftp://ftp2.census.gov//geo/tiger/TIGER2010/TABBLOCK/2010/tl_2010_22113_tabblock10.zip). Then do this to see them overlaid:
Finding Census Blocks in the urban area
First, find Abeville using the Query Builder (cmd-f):
This will hide all the other urban areas from the map. Go back in to the Query Builder and delete the query to get everything back.
Select the urban area of interest using the "Select Features" toolbar button (yellow square with a mouse pointer).
Now, to find the blocks in the urban area. This is done with the Spatial Query plugin. Enable it by going in the Plugin Manager in QGIS, searching for "spatial" and toggling the checkbox. You should have this icon in the sidebar now:
Then run this query by clicking that button and selecting the appropriate items in the dropdown (in the screenshot, the results are shown too):
Create a new layer based on the spatial query:
Then right click on that layer created from the spatial query, choose "Save As..." and save it as a CSV. This will export the attribute table for the layer, which is essentially a list of all the Census Blocks in the specified urban area!
I highly recommend using this with these high-resolution Hubble photos.
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.
The problem: SaneBox takes a second or two to automatically move messages out of my inbox, which causes the MailMate to temporarily show an unread message on the Dock icon and status bar, or show a notification.
My trick is to set up a Smart Folder called "Inbox badge" and use this as the source for my unread count and notifications.
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.)
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.
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:
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