Powered by Squarespace

Hi! I'm Shaheeb.  Here are some things I'm working on.  You may find a better description of my projects here.  If you think these are interesting, or want to chat about something you are working on, why don't you drop me a line here.

I'd love to get your feedback on these thoughts, so talk to me!



Understanding Options Trading

I have been a Malkiel fan, and a committed Random Walker for some years, and simple techniques like Dollar Cost Averageing have served me well.  However, I've grown interested in some more advanced investment techniques to boost my portfolio, and of these, Options Trading has really caught my attention.

Here are some resources that have helped formulate a basic understanding for me: 

  • Khan Academy:  American Call Options
    • A great little video to introduce the concept.  Sal's graphical, example oriented approach was an extremely instructive nugget to get me started
  • Khan Academy:  Call Options as Leverage
    • Reinforced the concept that a call option is a "force multiplier" and can yield magnitudes higher percent returns, while simultaneously reducing the required upfront capital.
  • Yale Econ 252:  Financial Markets - Lecture 23
    • With Khan Academy piqueing my interest in the topic, I found a more rigorous lecture on the topic.  While Shiller is not exactly the most dynamic instructor (at least this was my impression from this single lecture), the video provides an excellent historical and theoritical foundation on options markets.
  • TD Ameritrade's Investor Education
    • I have been a TDAmeritrade customer for years, and have found that their online portfolio management tools are simple and intuitive, yet quite powerful in terms of access to instruments.
    • They are definitely not the cheapest alternative in terms of trade commissions, but this has not yet been a concern for me given my preference for particular ETFs which TD offers commission free.
    • Their Investor Education center is geared primarily toward the use of TD trading platform, but the tutorials were very instructive in learning hw to read options chains and understand how to evaluate key attributes such as the option Strike Price, Expiration date, bid/ask spread etc.

The basics on Options Trading are easy to grasp, but (as with all other aspects of investing) are only just the beginning.  I have decided that I am most interested in taking advantage of the leverage advantage that call options offer.  In order to apply this concept, I first need to find an equity to formulate a position around.

In the meanwhile, I have been thinking that it would be very useful to have a simple calculator that accepts parameters like the option strike price, expiration date, commission rate etc. and returns back a single value for potential profit or loss.  The ones I've found are quite complex and attempt to estimate profits along a continuum with assumptions for volatility, and other "greeks".  More on that later perhaps?



T.R. Reid's Healing of America

I read T.R Reid's Healing of America last year for a graduate course on Healthcare Management, and found the text very thoughtful and engaging.  The debate around healthcare is certainly not as urgent today as it was when Obama was in the process of signing the Health Care Reform act into law.  Still, Reid raised some crucial points that remain relevant, at the very least in terms of the impact that Healthcare Management is due to experience.

What are the management implications for the US healthcare delivery and financing systems?

  • One of Reid's central tenants is that the financing of healthcare cannot be a for-profit enterprise.  Needless to say, moving toward a non-profit model for this entire industry will be nothing short of a sea-change.  While it is difficult to fathom the full extent of the changes that would result from such a transformation, some simple items to prepare for may be the shift away from the focus on medical billing, more centralized negotiation on prices for supplies and services, and greater focus on mission and vision values than profitability.
  • Healthcare providers will need to accept a reduction in compensation, a greater degree of scrutiny on their costs, and a greater accountability for the quality of the care they provide.  I imagine that this will drive (or attract) practitioners into more and higher administrative roles as management objectives will necessarily be more directly connected to the quality of outcomes in care settings. 
  • While much has been made of the profit-oriented motivation of insurance companies, I believe medical providers will also face similar pressures to behave in an even more socially responsible manner.  Reid focuses his attention to the payor role, but I believe hospitals will face a more stringent requirement on providing charity care and proving their benefit to the communities they serve.


Is there anything I disagree with?


  • Are Insurance Companies truly evil?
    • More clearly than any other point in the book, Reid paints a bright target on the for-profit insurance industry as the cause of human suffering in our country.  I can certainly appreciate that some practices that are commonplace in the individual health insurance companies can appear obtuse and in some cases even cruel.  But I think its important to recognize that these practices are in fact legal and quite well known, if a little technically difficult to understand.  
    • Rescission, for example, is not revoking someone's insurance coverage at will or because they don't feel like paying a claim.  Rescission is a measure to identify and penalize fraud.  If an applicant omits or misrepresents information that would have materially changed an underwriter’s decision to issue a policy, then that individual should not have an expectation to benefit from that type of fraud.  Afterall, if I misrepresent my income to qualify for a loan and purchase a large home, I cannot reasonably expect much sympathy when the bank repossess it after a few missed payments.
  • Are the systems in other countries really "better", and can we really transplant what works abroad into our system? 
    • In a late 2009 New Yorker article on health reform, Atul Gawande talks about the concept of "path dependence" as a major reason for the state of any country's health care system.  Essentially he argues that the systems one observes today are not the product of discreet events or sheer will of any particular political party.  Rather, these highly complex systems are the result of the momentum that builds over many years and many small decisions; each reflecting the unique set of circumstances of any particular time.  
      In a late 2009 New Yorker article on health reform, Atul Gawande talks about the concept of "path dependence" as a major reason for the state of any country's health care system.  Essentially he argues that the systems one observes today are not the product of discreet events or sheer will of any particular political party.  Rather, these highly complex systems are the result of the momentum that builds over many years and many small decisions; each reflecting the unique set of circumstances of any particular time.  
    • Following that argument, I am skeptical that we have a reasonable chance of deploying the Carte Vitale next year, or that we can impose a Japanese style "source of truth" index of fees the year after that.  Rather, I think we need to drive reform by evolving our current system; jettisoning the baggage and nurturing the good points.

Can we Americans think about and answer the "First Question" as it was intended - an ethical barometer for our outlook on the question of health?

  • Moral questions appear to have common understanding in these other countries.  Part of what defines our culture (and I believe is a strong reason for our success as a society) is that we are rigorously individualistic.  Inherently, we resist morality (at least I do), especially if it comes attached with a sense of a "right answer".  We are loathed to hear what we are "supposed to do".  That said, we have no choice but to drive reform in our healthcare system.  So I am holding out hope that we can achieve this reform without necessarily arriving at a univeral agreement on this moral/ethical question of right to healthcare.


What Get Set...GO! has taught me about mobile web development...

With just over 20 hours sunk invested into my beta/prototype of Get Set...GO!, I've picked up on a few realities of mobile web development.

Let me first introduce you to Get Set...GO!  

Think of middle school recess or those hot summer afternoons when you and your friends from the block would race to the end of the street.  Think of that free, simple feeling of just tearing down the alley to see who could get to that mailbox first (you know, that yellow one next to the big tree?).  There were no rules, and what you won was bragging rights.  

Get Set Go! revives that same simple sense of competition as a location-aware mobile game.  You pick a destination (maybe that Alterra coffeeshop two blocks over), send a challenge via sms or email to a few friends, and its game on!  Get Set Go! tracks your location, as well as your friends, and the first one to get there is checked in as the winner.  

You pick up points for races you start and join (with bonus badges for wins).  Businesses that sponsor destinations can offer prizes to winners and other checkin rewards to other racers.

Minimum Viable Prototype...

Planning is key (I'm told).  I forced myself to spend a few hours paper-napkin-ing the idea.  I developed a flow for the app (try LucidChart for dirt simple flowcharting), thought about some basic game mechanics and worked out a value-proposition for the race sponsors (ie my revenue model).  The exercise helped me land on a basic spec for the game that would allow me to get my phone out and tap on some screens as I pitched the concept to friends anyone who'd listen.

I decided to try wireframes using Balsamiq and some others, but found that for my own use, the mockups made the app much harder to visualize.  I decided to try platforms like ApplicationCraft and Rhomobile to simplify the visual aspects of designing a mobile application flow.  Now these tools are incredibly powerful, and while they do simplify certain advanced aspects of multiple platform targeting, they do come with a non-trivial learning curve.

My needs were centered around developing a usable protoype of the concept, quickly and cheaply.  I've written some code now and again, and decided that it would be faster for me to whip something together myself, and then transition to ApplicationCraft when I'm ready to refine the prototype into a more beta product.

jQueryMobile to the rescue...

Any developer familiar with the incredibly powerful and popular jQuery framework can be extremely productive extremely quickly using the jQueryMobile platform.  However!  Beware.  I was surprised to find so much of what I needed to accomplish required various degrees of hackery.  

  • Cross-domain requests or Same Origin Policy woes
    • Not quite a hack per se, but the whole concept of how JSONP is implemented is oddly complex, but a necessary reality in mobile web development
  • Variety of mobile specific implementations of the Google Map API
    • Google's eerily awesome javascript mapping API (v3)
    • Best API to the API I've found (GMap).  Certainly consuming the Google API directly is likely the best way to go for reliability and performance, but in reality fairly routine operations like searching for markers on a map is often easier through wrappers than dealing with the core API.
  • Implementing fixed headers and footers

Now, I'm not complaining mind you!  Just cautioning that although access to the raw tools can empower you to produce workable prototypes with minimal friction, you have to evaluate whether its sustainable for you to deal with build challenges *and* business development priorities.

So what can I say about my experience so far with mobile development:


  1. Plan.  Committing to a hardline spec for your prototype will bound the scope of your effort, and also go a long way in refining your best available options to deliver that desired state.
  2. Build it yourself.  At least in the beginning.  You will very quickly learn the key challenges you will need to invest the greatest amount of resources into as you move further toward delivery.
  3. Share it.  Its a difficult proposition, but share what you have early and often.  Its painful to hear comments like "is it supposed to look like that??", or "huh, that didn't quite work!", but you will end up directing your effort more accurately toward the right challenges in your project.  That is, the ones your users and customers care about;  and these may not be the ones you thought of first!




Shabana's guest post on

My sister (Shabana Wollin) was invited as a guest blogger at  She wrote a post on negotiating in a tough job market.  I can tell you from personal experience, Shabana has mastered the art of understanding a client's technical problem space, figuring out if she's the right solution fit, and then agressively negotiating an arrangement that benefits both parties.  Check out the post and comment!


A quick note about Hu Moments (re: DARPA Shredder Challenge)

Kat Scott from the SimpleCV/Ingenuitas team was gracious enough to share some feedback with me on my use of the SimpleCV package and approach to the Shredder Challenge.  Not surprisingly, she and her colleagues have had their own thoughts on how to tackle the puzzles, and I for one am eagerly looking forward to their attempts.

Kat (very diplomatically!) confirmed my comment that shape matching would not work, and then very kindly shared some specific technical information on why.   

"Your approach is a good first start, but unfortunately the Hu moment is not going to work in this situation. The Hu moment is a measure of the image moment, which is kinda like a moment in physics. Basically a moment describes how much work you have to do to get something to spin. Round things have less of a moment and spin easily, long things are a lot more difficult to spin. Moments are actually a good way to match things that are similar shapes, but not to align edges that are a like puzzel pieces."

Kat also forwarded a video of a simplified visual explanation of the math behind the Hu moments that illustrates how robust the calculations are in identifying a particular image, regardless of transformations applied to it: 

Personally, I found that while the video definitely drove the point home, Kat's simple, straightforward explanation was key for me in understanding the nature of this feature.

I hope this little bit sets off a light bulb or two for others, as it did for me.  At the moment, my thinking on the first puzzle has turned to collision detection; the type you might be familiar with if you've played any old-school platform scroller arcade game.  These games determined when two polygons intersected each other, and I think the principle should apply to determine whether two puzzle pieces in the shredder challenge are a good fit.

My latest homework is to understand the Separating Axis Theorem and see if I can develop an approach based on this concept.


DARPA Shredder Challenge - Part Deux

As promised, here is a bit of code that follows my preliminary line of thinking on Puzzle1: 

from SimpleCV import *
from optparse import OptionParser
import random

cmdOptParser = OptionParser()
cmdOptParser.add_option("-i","--input",dest="inputFilename",help="Filename of the image to operate on")
cmdOptParser.add_option("-o","--output",dest="outputFilename",help="Filename of the image to save on")

(options,args) = cmdOptParser.parse_args()
puzzleImg = Image(options.inputFilename)
#  The source images for the challenges are flippin huge. So let's up the recursion limit to support the search for many blobs
#  Kick things off by creating a binarized() version of the source image
binarizedSrc = puzzleImg.binarize()
#  Now lets find the blobs. Lets set some mins to make sure we don't worry about the itty bitty scraps
binBlobs = binarizedSrc.findBlobs(-1,2000)
#  We have a set of identified blobs, so we can do some basic analysis. Let's just stupidly try to match up blobs. This won't really work for us because we are not trying to find duplicates etc, we need matching tiles. But anyway.
blobBestMatches = {}
for i,blob in enumerate(binBlobs):
  blobMatchSet = {}
  for c,blobCmp in enumerate(binBlobs,1):
    blobMatch = blob.match(blobCmp)
    if (blobMatch > 0):          #blobMatch at 0 means it is itself
      blobMatchSet[c] = blobMatch
  blobBestMatches[i] = min(blobMatchSet,key=blobMatchSet.get)    #this clever little bit identifies the index of the dict that contains the lowest possible match value.
for k,v in blobBestMatches.iteritems():
  randomColor = (random.randint(0,255),random.randint(0,255),random.randint(0,255))
  print randomColor


Forgive me if the code formatting creates issues for you.  The script is dirt simple, and should be easy to follow.  It is only a proof of concept that (usefully) gets as far as identifying the distinct blobs.  From there, I've asked it to perform a simple match and identify the pairs by coloring each of the matches the same.  Running the script produces something similar to this:

Doesn't that look a lot easier now?

This last bit is not at all useful in solving the puzzle because we are not attempting to identify duplicates in the image.  Rather we need to match each shred to a "fit match".  I have not yet figured out the math to express the "fit match", but at least I'm a step closer in this marathon.


DARPA Shredder Challenge - Preliminary (quarter-baked) thoughts...

DARPA opened its Shredder Challenge late last week, and in typical DARPA style threw down a fantastic, seemingly impossible gauntlet:  extract meaningful information (intel) from a series of damaged and destroyed documents.

I am struck by two things about this challenge:

  1. DARPA is asking "How would you...", and not "Can you...".  That is, DARPA believes it is wholly possible to complete the challenge, and it is only a matter of your ingenuity to find any particular path to a solution.  This is a striking position considering that the simplest of the puzzles looks like this:  (reproduced unwisely without any permission from DARPA. )And it's worth 2 points!
  2. Anyone can win this challenge.  I mean that it occurs to me that there are not (likely) a cadre of paper shredding experts with degrees in advanced document reconstruction that are shoe-ins for this contest.  Anyone with a methodical mind should be able to design a solution approach, test it and stand a chance to win the purse.

I have often admired DARPA's innovative challenges (like their Network Challenge -or "Red Balloon"- problem), and I decided that I would enjoy at least participating in this one.  I am thoroughly confident that I won't score even a point, but I hope to share some ideas that may prove helpful to others.

Some thoughts on tools...

I am interested in machine vision and image processing, so I decided to take this opportunity to learn more about OpenCV and apply its capabilities to Puzzle 1.   OpenCV is a very popular image-processing library with several interfaces including Python and Processing.  I develop primarily on a (aging) Mac and I found getting started with OpenCV on OSX something of a Sisyphean ordeal.  Here are some key notes I learned through a couple of discouraging hours of headaches:

  • Use homebrew to install OpenCV, rather than Cmake and compiling the library from source.  Surely more awesome ninjas can solve the myriad dependency and python version compatibility issues that crop up in compiling the OpenCV libraries from source, but for the restofus: 
    • brew install git 
    • brew update 
    • brew install opencv
  • You'll need to update your environment's path variables to allow python to locate the appropriate bindings.  This site does an excellent job walking you through the necessary shell magic.
  • Forget OpenCV entirely and use SimpleCV.  I found that in the interest of getting productive quickly (especially on a mac), SimpleCV has nailed down the process of setting up your environment easily and correctly.

SimpleCV:  Computer Vision for the Restofus.

I will be using SimpleCV for the bulk of my exploration of the DARPA challenge, and I would encourage anyone interested in trying their hand at machine vision to do the same.  In addition to providing a simple, one-and-done installation package for most environments, SimpleCV also simplifies the native OpenCV python interface.  You can access Camera streams and Kinect devices, implement common image processing algos etc. in fewer, more readable lines of code.

I love the snip on their homepage that captures a frame from your webcam in 3 lines of code.

A few notes I learned that may help you:

  • Use the appropriate single "super" package installer to get yourself the required libraries and the SimpleCV stable code base
  • Then download the latest Git commit and re-install SimpleCV.  The latest Git revision has Blob detection algorithms baked into the SimpleCV interface, and allows you to by-pass dealing with the installation of the cvblob-python project.
  • Give the SimpleCV Interactive Shell a try.  It might get in the way of more experienced developers, but for newbies its a great way to quickly experiment with key features.
  • Browse the source.  The documentation has gaps, and I found myself understanding how to operate the image processing capabilities much more clearly as I started looking at the classes directly.
  • Read the OpenCV docs.  Remember that SimpleCV is a wrapper to OpenCV (and some other libs as well).  So it will help you to understand the native libraries, while taking advantage of the scaffolding that SimpleCV can provide.

It took me mere minutes to get my SimpleCV environment setup to a point that I could quickly and intuitively load in an image and begin to run some basic operations.  

The following is my line of thinking on the first puzzle.

Puzzle 1:  "What is the appropriate title being referenced?":

The challenge image looks basically like a jigsaw puzzle (albeit one where the edges on the pieces are more subtle).  My main objective is to achieve just enough reconstruction to extract the intel.  No extra points for the completeness of the reconstruction, so I am not concerned about the tiny little scraps at the bottom right.

My first thought about this puzzle is to get a hold of my pieces.  That is, I'd like to be able to run match algorithms against a particular scrap, so I need to be able to identify, extract and manipulate each bit of the paper.  Enter Blob Detection.  The complicated mathematical description aside, I am interested in clumping pixels together that look like they are part of the same entity.  Given that the background is a nice distinctive Pepto pink, this ought to be a doable excerise.  And thanks to SimpleCV's findBlobs(), you get the following image pretty quickly:

 Detected blobs are highlighted here in white. Note that the source had the bits of scrap in yellow, and thie image shows that we can locate them all.

Neato.  Well, now that we have the blobs, what about running some matches.  I was nearly floored to learn that SimpleCV has a terrific implementation (or rather re-interpretation) of OpenCV's matchShapes().  I am struggling to understand the technical details, but from what I can gather, this method compares two contours and reports back a value that indicates the stregth of the match.  The method is based on comparing Hu Moments which express information about a contour and is not sensitive to rotation, scale or reflection!!!!  

And so that's my approach to Puzzle 1:  loop through each "puzzle shred" and compare it to every other shred in order to find its match.  Then perform the same loop with each pair and so on until we reduce a couple of hundred shreds into a handful.

Of course this is easier said than done, but at least I can break down the approach.

  1. Extract the shreds as distinct, contiguous blobs
    • So, something you will notice if you simply run findBlobs() using SimpleCV is that it is fairly indiscriminate.  That is, while the image above looks like each shred is highlighted individually, in fact, each is fact composed of several "sub blobs".
    • We (I) first need to clean the image with a few passes of a "morphological operation".  Probably a morphClose() which should basically (hopefully) give us more robust blobs.
  2. Adapt the blob match to our needs
    • In its current format, simply running the blob match between two contours would really only tell you whether (or rather to what degree) they are identical.  We are after something close, but not quite an exact match.  I'll need a more clever math wiz than I to adapt the algorithm to make that happen.
  3. Profit!!!


So with that.  Back to more thinking.


Paramiko: easy, native ssh in Python...

I just discovered Paramiko (docs here)!  This module allows SSH interaction natively (meaning directly through code, and not through system calls), and supports a pretty comprehensive scope of operations over ssh.  The key items that caught my attention are:


  • Intutive syntax and application
    • mysshclient = paramiko.SSHClient() mysshclient.connect('hostadd',username='user',password='pass')
    • Addressed the missing host key issue we are all familiar with directly on the shell
      mysshclient = paramiko.SSHClient() mysshclient.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  • Key based authentication
    • Terrific example here
    • mysshclient = paramiko.SSHClient() mysshclient.set_missing_host_key_policy(paramiko.AutoAddPolicy()) privateKeyPath = '/path/to/your/key' privateKey = paramiko.RSAKey.from_private_key_file(privateKeyPath) mysshclient.connect('hostaddr',username='user',pkey=privateKey)
  • Send commands and interact with output on the remote machine
    • mysshclient = paramiko.SSHClient() mysshclient.set_missing_host_key_policy(paramiko.AutoAddPolicy()) mysshclient.connect('hostaddr',username='user',password='pass') stderr, stdout, stdin = myssh.exec_command('ls -latrh') stdout.readlines()


Brilliant.  Will be applying Paramiko to a teeny automation script that will start an Amazon EC2 instance, run a series of commands on the server (neat scraping and analysis stuff I hope to write more about), and then process some post shutdown ops.


Oct132010 let me down today...

I have been a loyal user for over 2 years, and today I experienced a level of dissatisfaction with the service that surprised me.

 A little background:  At around 6:45am CST today (10/13/2010), I received an email with no message body or subject line from " <>".  The message contained an single 1x1 pixel image that "phoned home" to - an email marketing firm that presumably tracks visits and message load statistics.  After a little Googling, I learned that apparently sent a "flood of emails" the previous morning due to a "simple" misconfiguration of a test server "with no customer data".  Stephen Mann ('s Director - Customer Advocacy) assures us (other loyal users like me no doubt) that measures were being put in place to ensure this never happens again.

So when I received a second blank email - identical to the first - about 6 hours later, I was upset.  I then learned that many others had received a half dozen or more emails well after Stephen Mann's rather inadequate message.  As I re-read that message that Mann posted early on 10/13, I grew more upset as I saw clearly both the incompetence and the utter lack of professionalism represented in the content.  

Here are my two main issues with Mann's message:

  • Stephen Mann's choice of language in posting "sorry for being annoying" and "We also apologize if we woke you up from your sleep! " indicates that he thinks he's managing the social presence for a brand new shiny web2.0 side project. manages the personal financial information for hundreds of thousands (millions?) of users.  Stephen Mann should take this more seriously.  Moreover, a $30million sale to Intuit should firmly signal (at least to that has a greater responsibility to its userbase.  We should not be subject to amateurish mistakes like allowing a test server to communicate with the outside world.
  • I believe Stephen Mann is either too incompetent to have correctly determined the technical details of the problem, or outright lied in this message.  If the mistake occurred on a test-system with "no customer data", how was the email delivered to my email address?  If the test system has access to my email address, what other detail exists in this environment?

My final concern is that not many people appear to be aware of this problem!  To my own tiny part, I have hooked the RSS feed for this utterly shameful feedback thread into twitterfeed.  Any updates to the forum will be pumped into my embarrassingly lonely twitter stream.


For shame  Cereal.


Track the Forum Here:



On becoming a positive deviant...

I just finished Atul Gawande's "Better" and found his closing thought particularly inspiring. Gawande is a gifted author, and masterfully guides his readers through a series of case studies that illustrate instances of remarkable achievement, how these were accomplished (and then replicated), and what he learned about the people that dedicated themselves to the relentless pursuit of "better".

Gawande's closing centers around a lecture he once gave to medical students that he hoped would help guide them in their own efforts to distinguish themselves in their careers (and likely their lives in general). He offers his students 5 ideas that he feels would condition them into a pattern of behavior that would set them in the right direction:


  • Ask an unscripted question: he encourages stepping outside the routine to establish a more human connection; not just with patients, but also with collegues or friends.
  • Count something: in one of my favorite lines in the book, Gawande suggests that everyone should be a scientist in their world.   Counting something - as he did the number of instances sponges or tools were left behind in the body after surgeries - conditions the mind to ask the types of probing questions that invariably lead to innovation and change.
  • Embrace change: he is careful to caution against blind adoption. Rather he encourages the willingness to learn, critically evaluate, and adopt new ideas if they bear merit.
  • Don't complain: Gawande suggests (from his own experience) that nothing is as demoralizing in healthcare than hearing doctors complain.   I'm inclined to think that a variation of that sentiment applies equivalently to virtually any situation.
  • Write something: perhaps this last suggestion was the most compelling as it motivated me to write this short blurb. I find that writing (particularly about things that are meaningful to me personally) naturally forces me to think more critically and creatively.   At the very least it has forced me to put the iPad keyboard through it's paces! (this post was authored on my spanking new iPad using SquareSpace's iPhone app.  Thanks Mona!)


I highly recommend Better, as well as Gawande's other texts (including The Checklist Manifesto, and his very insightful contributions in the New Yorker).