This version of the site is now archived. See the next iteration at v4.chriskrycho.com.

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.

PSA: Android browser and soft hyphens

The default Android browser does not love soft hyphens (Unicode: U+00AD, HTML: &#173; or &shy;). This means, for anyone using the good old PHP Typography tool or its WordPress plugin equivalent, wp-typography, that you’re in trouble if you have mobile viewership at all. While it’s nice to have a sensible hyphenization algorithm at play – the sort that can prevent widows – it’s a bad idea to be running anything that doesn’t support mobile these days. Read on, intrepid explorer →

Four Theses on Responsive Design

A friend and fellow web designer and developer (indeed, someone who gets to do a lot more front-end design) recently asked me,

Chris—what do you think of “responsive” layouts? I’m not a big fan. In theory, it’s a good idea. But it makes it difficult for ad placement, and in practice, I don’t know that anyone really needs five different “views” for a site based on browser width/height.

So, some thoughts from a guy who’s done a lot of reading, a lot of watching, and – alas – a lot less actual implementation than he’d like in the last year. (In other words: take these words with a grain of salt; they’re observations on watching others in the process as much as they are born of my own experience.)

I think responsive design is a great idea, but it has to be done carefully and thoughtfully, especially when considering ad placement. Read on, intrepid explorer →

Custom Fonts on Kindle

The standard typeface for the Kindle, Caecilia, works well enough: it’s a well-designed, high contrast slab serif that matches the needs of the low-contrast, low-resolution Kindle screens well. It’s also not even close to being a really great reading face. The new Kindle Paperwhite has gorgeous typography, by all accounts, but if you have an older Kindle, you don’t have to buy a new one to start getting some of the benefits of better typography.

I recently discovered that it is possible, with a fairly small amount of effort, to put whatever fonts you like on your Kindle, without jailbreaking. Here’s how. Read on, intrepid explorer →

PSA: jQuery Validate 1.10.0 ‘accept’ method

Just an FYI for any other potentially confused developers out there: the jQuery Validate plugin’s documentation is out of date as concerns the accept() method: I just spent an hour trying to figure out why accept() it isn’t working… Of course, it works just fine, but I was missing an important piece of the puzzle.

Though the method used to be part of the main validation plugin, this is no longer the case. The method still exists, but it is now part of the additional-methods.js. Accordingly, if you try to use the accept() method without including the extra file, you’re going to see the error message Cannot call method 'call' of undefined in your Javascript console.

The additional-methods.js script is part of the standard zip file download – it’s just not necessarily obvious that you need to include the extra file to make the method work. Hopefully the documentation will get updated soon so others don’t spend a bunch of time trying to figure out why a basic method isn’t working!