Ancient Photo from My First Job

Last night I was prepping my Aperture library for the upcoming move to Yosemite. I ran across this photo from my first Job.

PET/SPECT in Amsterdam

I was in Amsterdam at Vrije Universiteit, helping install this PET/SPECT camera. I wrote the gantry control software and the UI pictured on that screen.

Cass Scenic Railroad

DSC_9403

Last weekend I took my family to Cass Railroad to ride some steam engines.

Cass is a small town in the mountains of West Virginia. Formerly a company logging town, Cass offers a chance for a relaxing weekend getaway. And free from the burdens of broadband and cellular reception, you can be sure that your enjoyment of the trains will never be interrupted by blips and boops from your smartphone.

If you have a young child that loves trains, I highly recommend it.

Riding the #11

Click through for the full album.

A New Chapter

A few weeks ago I announced that I have departed Bomgar to work on my own projects and to spend more time with my family.

It was my privilege to work with the great team at Bomgar for almost 7 years. The job was challenging and rewarding, and I’m very proud of what we accomplished. Leaving is very bittersweet.

However, I’m excited about the future. I have a new product in the works that will launch on iPhone, iPad, and OS X, and I’m already writing a work estimate for what could be my first contract as a freelancer.

Most importantly, I believe that providing my children with a full-time parent will yield benefits in every corner of our lives for years to come. I expect to look back on this period of our lives and say with certitude that it was all worth it.

Building a Web Backend from Scratch

I built the backend for my last project on Heroku using Sinatra. It was great; I got to learn about Ruby and a new web framework and it was a very stable and fast API.

I’ve been thinking about what to use for my next project when I saw Marco’s Web Hosting for App Developers and the ensuing discussions among developers on Twitter. After giving it some thought I came to the conclusion that I could probably learn alot by self-hosting the backend myself. Maybe I can even build something as stable and reliable as what I built on Heroku?

Rebuild, Rebuild, Rebuild

I made the decision up-front to script the entire process of building the server. This way, in the event of a network outage at Linode or in the unlikely event that my app comes under heavy load, I can add new servers in a matter of minutes.

My current scripts do the following:

  • Setup SSH keys and disable SSH password authentication
  • Setup firewall, leaving only ports for my application open.
  • Install git, postgres, golang, and other software used by my application.
  • Configure postgres and golang
  • Checkout the application code from my repository
  • Configure it so that it automatically starts when the system reboots.

Did I miss anything?

Another thing that I do to make sure that my scripts are always in working order is to rebuild the server every time I make a substantial change to the script. Also, I completely rebuild the server every evening I sit down to work on it. This leaves me feeling pretty confident that I can quickly recover from a serious outage.

Now, you might have noticed that I mentioned golang above. I’d originally planned to use Flask, but as I already have some experience with Python, I chose Golang so that I can learn something new. The dowside of this will be that Go isn’t as widely used, and I will be navigating uncharted water without the usual wealth of online sample code and SO Q&A. Still, my early impressions of Martini + Golang are very positive. I’m hopeful that I can get everything working withough too much headache.

Next:

I need to setup automatic database backups. I’ll probably use a cron job that automatically sends raw backups to Amazon S3. Also, I’d like to support HTTPS for all API calls. Since I’m just building a web API for my own app, I can just be my own Certificate Authority and issue my own SSL certificates and keys. Any problem with that?

Have any comments or suggestions? Let me know.

Charting Dividend Reinvestment: AAPL

I recently wanted to see a graph of a particular stock assuming dividend reinvestment. This seems like it would be a common thing to do, but neither Google nor Yahoo’s finance sites appear to have the capability. After a bit of searching, I found a way to do it.

aapl-div-2

So here, I’ve plotted $AAPL over the past two years with and without dividend reinvestment. Note that $AAPL first paid a divident in Augustof 2012, so it’s logical that the graph begins to diverge shortly after that. Currently the difference in return is about 4.3% over the two years.

You can fiddle with this graph yourself. Or, starting from scratch, do the following:

  1. Create a chart for AAPL
  2. Set the range (above I used 2 years)
  3. Set “Type” to Thin Line (optional)
  4. In both the Overlays and Indicators sections, click “Clear All”
  5. Under Indicators, create a Price/Performance indicator with parameter_AAPL and set “Position” to “Behind Price”.
  6. Click “Update”

Interestingly, stockcharts.com appears to assume dividend reinvestment by default, while Google Finance and Yahoo Finance do not.

Playing Around with the Fitbit API

I recently became interested in pulling some of my own personal data from the Fitbit API. I’ve never used OAuth before, and it’s been years since I last made any serious use of python, but I managed to throw together a small program that does a few basic things. Currently it just posts your cumulative year to date total floors climbed to Twitter. Feel free to have a look at the github project or see it in action.

It was right about when I got this far with the project that I realized that there is now a free way to play around with the App.net API. So I’ll be adding ADN support and make it into a more interesting bot.

Working From Home

For the past five years, I have worked in a traditional office. A few weeks ago, I moved a thousand miles across the country and became a telecommuter. Several months before the move, I started gathering material to try to help me prepare for the new work situation. Here are a few I found useful.

Here’s my core advice to anyone about to start telecommuting for the first time. Give some proactive thought and planning to your home office setup, your work/life schedule and boundaries, and your effectiveness as a communicator. Also, try to be aware of what distractions are most problematic for you and take steps to minimize them.

launchctl asuser

launchd provides many ways to configure when and under what conditions a job is started. You can define agents that run for each user, or daemons that run as root outside of a GUI context.

The launchctl command is a convenient way to interface with launchd. Recently I came across a command in the launchctl source code that is not documented in the launchctl man page. The ‘asuser’ command can apparently be used to “Execute a subcommand in the given user’s context.” This would mean that you could use this from a Launch Daemon to spawn a GUI process for a given user, which could be very useful in certain circumstances.

A quick glance at the code and this looks to be the case. It gets the root bootstrap port, looks up the per user mach port for the given UID, sets the bootstrap port for the current task, set some environment, and then does a fork/exec/waitpid.

Sure enough, if you ssh to a mac as root, you can spawn GUI applications into other users’ consoles. I was even able to run Grab.app and capture images of the user’s desktop. Without the asuser command, you get nasty errors like “RegisterApplication(), FAILED TO establish the default connection to the WindowServer, CGSDefaultConnection() is NULL.”

One days soon I’d like to resurrect my Launchctl API project and add a few more commands, including this one.

In Lieu of Ads

I recently saw this project in my news feed and wanted to give it a try. It’s a simple rails app that gives you an easy way to accept credit card payments online. I’ve never liked the way that ads looked on my site, so I’m going to run a “tip me” button for a while and see how that works.

If you find one of my posts useful, or if you’d just like to buy me a coffee, give it a try.

Cellular Networking on OS X

Lamenting the lack of cellular-aware APIs in 10.8, Marco writes,

I was hoping Mountain Lion would add some APIs suggesting cellular data considerations, but it didn’t happen. Maybe 10.9 will.

However, Mountain Lion did offer one tiny inkling that cellular awareness in OS X APIs could be on the way. NSURLRequest added –(BOOL)allowsCellularAccess

Returns whether the request is allowed to use the cellular radio (if present).

Return Value
YES if the cellular radio can be used; NO otherwise.

Availability
Available in OS X v10.8 and later.

Also, it’s interesting that the NSURLRequest.h also exposes the corresponding setter method, which is not linked in Apple’s documentation. The comments direct you to “pass NO if the receiver should not be allowed to use the built in cellular radios to satisfy the request, YES otherwise.”

Then again, this is the Foundation framework we’re talking about, so perhaps the inclusion of this method was just a byproduct of the continued convergence of the iOS and Mac APIs. Still, it would be exciting to see full support for cellular connections in Mac OS 10.9.