This version of the site is now archived. See the next iteration at v4.chriskrycho.com.
Published during: November 2012

SICP for Kindle – improved by yours truly

I was looking for a Kindle version of the MIT Press classic text on computer programming, Structure and Interpretation of Computer Programs, which is (delightfully!) available online in its entirety here as an HTML book. (MIT is awesome like that.) I found one, by twcamper on GitHub.

Unfortunately, I discovered that he had eliminated paragraph indentation – apparently Kindle was doing that automatically at some point, but they have since stopped – so I forked it, thinking I’d just add it in, rebuild the .mobi file, and be on my way. Alas, it wasn’t that simple: his documentation skipped a few things (it looks like it was more a way of storing his personal project than meant for public consumption), so I spent a good chunk of the morning figuring out how the project worked, making some tweaks to get it to work the way I wanted it to, and updating the documentation so others could follow my steps themselves if they wanted to make their own tweaks to the CSS file.

You can get the updated book directly from the Downloads page. If you want the Ruby code used to generate it, you can get that direct from the main GitHub page for the project, which also has a (much improved, in my opinion) writeup on how to actually use it. Enjoy!

Something you should never do, but which did provide some hilarity for us today:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
if (idate < 65535)
  {
    CTime itime = CTime::GetCurrentTime();
      iyear = itime.GetYear();
        imonth = itime.GetMonth();
          idate = itime.GetDay();
            icurdate = (iyear - 2005)*512+12800 + (imonth*32 +1) + idate;
              if(icurdate > tdate)
                {
                  sprintf(str, "Key Expired");
                    MessageBoxEx(m_hWnd, str, "Error", MB_OK,LANG_ENGLISH);
                      exit(-1);
                    }
                  }

The whole 1500-line module was written up that way. Why? We have no idea. It’s better now. Less funny, but better.