Monday
Jun302014

Turn web sharing back on in Mountain Lion

Another one of those tips I've had to re-google one too many times.

I want to be able to open web pages/data saved in ~/Sites.

First, create a configuration file /etc/apache2/users/USERNAME.conf containing:

<Directory "/Users/USERNAME/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

To turn on temporarily until next restart:

sudo apachectl start

To turn on more than temporarily (may need a restart or the above command to turn on for first time):

sudo defaults write /System/Library/LaunchDaemons/org.apache.httpd Disabled -bool false

This tip is available in multiple places such as here.

(And, yes, I really should upgrade that MacMini to Mavericks one of these days....)

Thursday
Jun262014

Easily manage photos & videos on iPhones & iPads

Every now and then I've had to re-google this and spend a few minutes stumbling around looking for it.

There's a 'hidden' utility on Mac OSX called Image Capture that is the best way I know of managing the photos & videos on an iOS device, including dumping to disk and/or deleting from the device.  Lots of options for sorting on various metadata.

MacWorld article describing Image Capture.

 

Friday
Jun202014

NSF Astronomy grant sizes

A news item in today's Science contains this statement:

the average size of an NSF astronomy grant, roughly $325,000 a year over 3 years, is almost 30% larger than it was a decade ago.

A colleague pointed out to me that that number ($325K/year) seemed high and was probably a typo. Without commenting on the news item itself (that NSF AST is implementing a "voluntary" limit of one proposal per year as a PI or Co-PI), let's look at some data. (Bottom line: yeah, I'm pretty sure it's a typo and should have read roughly $325,000 over 3 years, giving more like ~$108K/year.)

NSF Awards are searchable. There's a limit of 3000 records returned per search, so I broke up Astronomy awards into <1990, 1990-2004, and >=2005 and downloaded each as a CSV file.

After combining them into a single file, I read it in with a little python:

Now, we're ready to play with the data with a few caveats:

  • Recall that buried in these data are everything from a few thousand dollars for a summer student to some $400Mil for ALMA construction.
  • Also, the data field we're looking at in the CSV file is called AwardedAmountToDate. Sometimes NSF funds a 3 year project all at once. Sometimes they do it year-by-year. It depends on lots of factors. So, the data should be reasonably decent for completed awards ('expired' in NSF lingo). But, for currently active awards there will be some noise. (e.g. Dr. X was awarded a $300K grant for 3 years starting 2014-01-01 that was funded all at once, while Dr. Y was awarded a $300K grant for 3 years starting 2014-01-01 that received its first $50K on 2014-01-01, but has been promised another $50K in September and then the remainder in 2015 and 2016. While for Dr. X and Dr. Y these are nearly effectively the same grants ($300K over 3 years), in the publicly available data we're using here those show up quite differently.)

First, let's look at the per-year funding on grants:

The mean is extremely noisy due to big projects (like ALMA at something like $400Mil), but the median tells a consistent story, having crept up toward about $100K/year. (Recall that the data should be viewed as incomplete for the most recent few years, back to 2011 or so.) You can also see the effect of the ARAA stimulus money in 2009-2010. But, there's no (fair) way to claim that typical NSF Astronomy awards are $325K/year, without cherry picking data. More likely it was a typo. The median per year per grant looks like it's crept up to about $100K/year or a little more depending on how you extrapolate into the 'noisy' data of the past few years. Most grants are 3 years. You can do the math.

Finally, let's look at total award per grant to confirm that:

Yup. Nothing too wacky going on here.


Code to generate the first plot:

Code to generate the second plot:

Wednesday
Mar192014

An aside: Every Conference Call Ever

You will either read this and have tears of laughter running down your face, like me just now, or you are one of a few incredibly lucky people who don't understand it.

Every Conference Call Ever (with tweets) · swilliams · Storify

Tuesday
Feb042014

Retrieving Display sizes and layout in an AppleScript

I wanted a way to get the size and layout of my displays, e.g. if I'm on my MacBook Pro Retina there should be one display with a size of X×Y at an origin of 0,0 where X×Y varies depending on which scaling factor I have set in System PreferencesDisplaysResolution. If the MBPr is plugged in at my desk, then there should be three displays each with their own sizes and origins. I don't care whether this is done in AppleScript or a unix command as one can always call the other.

This was surprisingly difficult to figure out how to do, but surprisingly easy to implement once I did figure it out.

First, a few things I tried that got me part way, but in the end were unfruitful:

xdpyinfo

The command line utility xdpyinfo gives some useful information, but not everything I need and is particularly unhelpful in the multi-monitor case.

com.apple.windowserver.plist

At first glance /Library/Preferences/com.apple.windowserver.plist looked very promising.

I could dump it to xml:

plutil -convert xml1 -o test.xml /Library/Preferences/com.apple.windowserver.plist

And then examine test.xml in a text editor. (or even explore the original plist file in Xcode)

I could pull out individual bits of information, e.g.:

/usr/libexec/PlistBuddy -c "Print DisplaySets:0:0:Width" \
    /Library/Preferences/com.apple.windowserver.plist
→ 1680
/usr/libexec/PlistBuddy -c "Print DisplaySets:0:0:OriginX" \
    /Library/Preferences/com.apple.windowserver.plist
→ 0

I could even write a bash script that would output [width, height, originX, originY] for each screen in all DisplaySets:

The problem with this is that I could not figure out how to reliably know which DisplaySet is the active one.

AppleScriptObjC

Finally, I found AppleScriptObjC. Follow the instructions contained within the first gist file to install and use:

Pretty cool.

One note is that the coordinate origins start from Lower Left, while at least in some other places in the operating system I need to use coordinate systems starting from Upper Left. Oh well, that math is at least easy.

Page 1 ... 2 3 4 5 6 ... 32 Next 5 Entries »