Matt Morris

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.

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.1

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.

  1. As always, if you spot any error, let me know and I’ll post a correction.

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.

Back to Octopress Master

After playing with the link log feature in the Octopress 2.1, and now 3.0, branches, I’ve decided to come back to the master branch. Octopress 3.0 looks like it’s going to be very nice, but things are too unstable for me at the moment. I shouldn’t be spending so much time hacking on the site itself when there is actual work to do.

For the linklog posts I’ve already made, I just edited the entry with a link to the external URL in the body of the post. Apologies if this causes repeat entries to appear in your RSS feed.

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.

On Pointless Check-Ins

What is the Point of the Check In ➜

I, too, have totally abandoned service such as Foursquare. I don’t see the point in publicly announcing when and where I have coffee or sushi.

However, a few months ago I became interested in creating a private log of “Check-Ins”. I wanted something that I could revisit years from now to help me remember what things were like during this era of my life. And some day, this may be interesting to my kids or future grandkids.

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.

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.