Archive for the ‘education’ Category

Chile’s earthquake

I’m not surprised that—so far, at least—the death toll from Chile’s earthquake is so low compared to Haiti’s, despite the much stronger quake. I was trained as a structural engineer, and my department was loaded with graduate students from South America. Latin American countries tend to take earthquakes very seriously, and their engineers are highly educated, both at home and abroad.

News reports will, of course, focus on the devastated areas, but most of the buildings must have done an excellent job of protecting the people within. This is not to say that the buildings weren’t damaged; there’s too much energy in a big quake to expect most buildings to escape unscathed. But I would expect to see most engineered buildings1 to have absorbed the energy without large-scale collapse.


  1. Buildings that were designed by engineers, like office and apartment buildings. Older, smaller residences are typically not engineered and usually suffer the most damage. 


S5

On Super Bowl Sunday I got a crash course in S5, the Simple Standards-Based Slide Show System by Eric Meyer. It’s pretty impressive, something I would almost certainly use if I were frequently giving slide show presentations.

My older son had made a Keynote presentation for a school project and needed to convert it to PowerPoint in order to run it on a Windows machine in class. The conversion seemed to work, but when I insisted he test it on a neighbor’s computer (we don’t have a working Windows computer, and I had recently uninstalled Parallels from our shared iMac), we learned that the movies embedded in the presentation wouldn’t run. My son had shot the movies with my Canon G10, which saved them in QuickTime, a format that PowerPoint doesn’t like.

I looked into converting the movies to other formats, but couldn’t quickly find a format that was compact, of decent quality, and PowerPoint-compatible. The paid versions of Flip4Mac probably would have made good looking WMVs, but I didn’t want to shell out for a single use.

So I downloaded the S5 template, looked at its structure and at the primer, and did a couple of tests. It worked perfectly right away, so I showed my son how to pull the text out of his Keynote presentation and wrap it in the appropriate tags. While he was doing that, I looked up how to embed QuickTime movies in HTML and gave him the skeleton code to add and modify on every slide that needed a movie. With a couple of lines of CSS to shift the content a bit to the right, the presentation was finished.

All the text content of the presentation is in a single HTML file. The individual slides are kept in <div>s like this:

<div class="slide">
<h1>[slide title]</h1>
<ul>
<li>[point one]</li>
<li>[point two]</li>
<li>[point three]</li>
<li>[point four]</li>
<li>[point five]</li>
</ul>
</div>

You’re not limited to bullet points, of course. Anything you can do in HTML that fits on a single screen can be put between the slide <div>s. The slide-to-slide control of the presentation is handled by some clever JavaScript and CSS.

The great thing about presentations made with S5 is that they run everywhere—Windows, Mac, Linux, even the iPhone. If your client wants a copy of your presentation after a meeting, you just give her the folder with the presentation and tell her to open the HTML file in Firefox or Safari.1

The only thing I didn’t like about S5 is that it forced me to work in HTML instead of Markdown. It wouldn’t take much to write a script that converts Markdown to HTML and inserts it into the S5 template. You could also use Pandoc to do the conversion, but

Oh, I believe it. I’ve done it.

Update 2/9/10
Mark Eli Kalderon, an old hand with plain text formatting, tweeted me about the S5 Bundle for TextMate, which uses Markdown to format the slides. I installed it and gave a short tryout.

It certainly works well, but it has one fatal flaw from my perspective: the S5 support files—the CSS and JavaScript—are stored within the bundle itself, and the generated HTML refers to those files. Thus, the presentation is hard-wired to my particular installation of TextMate. While this keeps duplication of files to a minimum, it means I don’t have a self-sufficient folder of files that I can put on a thumb drive or give to someone else.


  1. My son’s presentation didn’t seem to work in Internet Explorer, probably because S5 is standards-based and IE isn’t. For safety’s sake, I had him put a copy of Portable Firefox on his thumb drive in case the school computer had only IE. 


The wrong sort

Tonight I was killing time in Naperville’s Nichols Library, looking through the computer books. NPL uses the Dewey Decimal System for assigning catalog numbers, so I was in the 005 section when I ran across this book with a call number on the spine of 005.8 BIS.

It’s a pop sociology book, and obviously has no place in the computer section. I someone on staff saw the word “sort” in the title and started thinking bubble, shell, heap, quick,…, big. Despite the mistake, I’m kind of impressed that a librarian would look at that title and make a CS connection.

I got curious and looked it up at the Library of Congress site when I got home. According to the LOC, the Dewey number should be 305.800973 22, which puts it in the social sciences where it belongs. I had always assumed libraries used the numbers assigned by the LOC and didn’t try to do their own classification. In this case, that would have worked out better.

Tags:


Math practice sheets

After writing last night’s post I started thinking about who would be likely to read it and how it could be made more useful to them. I think regular readers of this blog—both of them—are conversant with at least one scripting language and are pretty handy with a text editor. For those people, providing the source code with line numbers makes sense; they’re as interested in the code as in what the code does. But parents who find these posts by Googling “math practice” or “multiplication homework” aren’t interested in the code, just the results.

So I’ve uploaded all my math practice sheets as standalone web pages and put the links to them in this article. No need to copy and paste, no worries about the proper file extension or whether you’re using a text editor or a word processor. Just click a link and you’ll get a page full of practice problems you can print out. Reload or Refresh the page and a new set of problems will appear. If you want to download them to your own hard disk, just use your browser’s Save or Save As command; but you don’t have to. As long as this blog is running, I’ll keep the math practice sheets available with links to them here.

I’ve written the pages as generically as I know how; I believe they will work in any browser on any operating system. If you have a problem, let me know and I’ll try to fix it.

As I make more of these pages, I’ll revise this post to include links to them.

And if you are interested in the thinking behind the code, you can look at these posts.

Tags:


More multiplication practice sheets

Update 10/15/09
I’ve made this page to list all the math practice sheets I’ve made. And I’ll update it if and when I make more.

Earlier this evening I was looking over the fourth-grader’s homework, and I saw he was having a little trouble multiplying two-digit numbers. So we talked about strategies for doing the multiplication, and he redid a couple of the problems. Afterward, I went back to the addition/subtraction practice sheet and the single-digit multiplication/division practice sheet, made a few changes, and created a new multiplication practice sheet for two-digit numbers.

Like the previous practice sheets, this is an HTML file that I keep on my local hard disk. Opening it in a browser (any browser on any operating system should work as long as JavaScript is enabled) generates a set of 25 problems ready to be printed on a single sheet of paper. Reloading the page creates a new problem set, so by repeatedly reloading and printing I can quickly make a week’s worth of practice sheets, which should be enough to get him comfortable with problems like this. Environmental guilt compels me to print them on the backs of sheets that were destined for the recycling bin, but that’s not an essential part of the process.

The HTML, JavaScript, and CSS are all in this one file:

 1:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 2:    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 3:  <html>
 4:  <head>
 5:    <title>Math Practice</title>
 6:    <style type="text/css">
 7:    h1 {
 8:      text-align: center;
 9:      font-family: Sans-Serif;
10:      font-weight: bold;
11:      font-size: 36px;
12:      margin: 20px 0 0 0;
13:      padding: 0;
14:    }
15:    #whole {
16:      margin-left: auto;
17:      margin-right: auto;
18:    }
19:    table.problem {
20:      font-family: Sans-Serif;
21:      font-size: 24px;
22:      text-align: right;
23:      border-bottom: solid;
24:      margin: 40px;
25:    }
26:    </style>
27:    <script>
28:    function single_problem() {
29:      var operator = "&times;";  //&#215;
30:      var top = Math.floor(Math.random()*90 + 10);
31:      var bottom = Math.floor(Math.random()*8 + 2);
32:      return '<table class="problem">' +
33:                     '<tr><td></td><td>' + top + '</td></tr>' +
34:                     '<tr><td>' + operator + '</td><td>&nbsp;' + bottom + '</td></tr>' +
35:                     '</table>';
36:    }
37:    </script>
38:  </head>
39:  <body>
40:    <h1>Math Practice</h1>
41:    <table id="whole">
42:      <script>
43:      for (i=0; i<5; i++){
44:        document.write("<tr>");
45:        for (j=0; j<5; j++) {
46:          document.write('<td>' + single_problem() + '</td>');
47:        }
48:        document.write('</tr>');
49:      }
50:      </script>
51:    </table>
52:    
53:  </body>
54:  </html>

The only real programming is in the single_problem function defined in Lines 28–36 and the nested loops that call that function in Lines 43–49; the rest is formatting. The top number of each problem is always a two-digit number (Line 30), and the bottom number is always a one-digit number greater than 1 (Line 31). When my son has mastered these problems, I’ll change Line 31 to make the bottom number two digits as well.

If you want to use this to make your own sheets, just copy the code (without the line numbers), paste it into a plain text document, and save the document with an .html or .htm extension. Or just go here and use your browser to save the page to your local hard disk.

The earlier practice sheets were a big help, and I expect these will be too. The fourth-grader gets a set of truly random problems, and I get to spend my time checking his work and helping him correct his mistakes rather than making up new problems.

Tags:


iTunes U and iTunes 9

You may have noticed that iTunes 9 has a new media kind: iTunes U. It will show up as one of the Library types in the left sidebar (if you have the iTunes U item checked in the General Preferences) and is one of the things you can sync with your iPod. Any lecture series you download from the iTunes U section of the iTunes Store will be saved as this media kind.

What about lecture series you downloaded before iTunes 9? By default, they’ll stay where you had them and will not show up in the iTunes U Library. But putting them there is pretty easy: select all the lecture tracks and press ⌘I (or choose Get Info from the File menu). Click to the Options pane of the Info window and choose iTunes U from the Media Kind popup menu.

Now your old stuff will be where your new stuff is going.

Tags:


Camry smart key battery replacement

The battery in my Camry’s smart key just died and information on how to replace it wasn’t as easy to find as I thought it would be, so I decided to post some instructions here. Even if no one else finds it useful, I’ll be able to come back in a couple of years to remind myself how to do it.

Most likely, the battery died in less than three years because it’s almost always near my cell phone. When I’m walking around, the key is in one pocket and the phone is in an other; when I’m riding my bike, they’re both in a waterproof case in my saddlebag; overnight, they’re both on my bathroom counter. According to a Toyota service bulletin

Some customers may experience limited battery life in their Smart Keys. The Smart Key “wakes up” by receiving a “ping” or electronic noise. many electronic devices emit a “ping”, therefore a Smart Key(s) could wake up and as a result, battery life could be reduced.

If the Smart Keys are stored near any of the following components, battery life may be reduced. Keep Smart keys at least 1 meter (40 inches) from these electronic devices.

TVs or computer monitors
DVD or VCR units
Desktop PCs or notebooks
Cordless phones or cell phones
[etc.]

Toyota is not making this easy. The only way I can think of to keep more than one meter of separation is to tie the keys to my shoelaces and carry the phone in my hat. I don’t usually wear a hat, but I’ve read that Lincoln carried paper and a pen in his, so maybe I should visit my local haberdasher and shop for a nice new stovepipe. Or just plan to replace the battery every couple of years.

Before getting into the instructions, I should mention two things:

  1. This is for a 2007 Camry. Although I would expect the instructions to be similar for other years and models, the hints I’ve found elsewhere on the web indicate that Toyota hasn’t standardized its smart key design or its battery choice.
  2. My car’s digital display started telling me last week that the key’s battery was low. So if you get a low battery warning, expect the battery to die relatively soon.

The little mechanical key that’s stored in the smart key is the tool needed to get at the battery. So the first step is to push the latch on the side of the fob and pull out the mechanical key.

The end of the mechanical key is thinner than the rest of the key, and that’s what we’ll use to pry open the fob. Put the end of the key into the narrow slot that’s perpendicular to the hole you just pulled it out of.

Twist the mechanical key to pop open the fob.

The battery is on the other side of this circuit board. The board is held in its compartment by double-sided tape, so it won’t just fall out. Slip the end of the mechanical key under the board and gently lever it out.

The battery is held in place by three little legs. Spring them open one at a time to remove it.

The battery is, unfortunately, a CR 1632, which your local drug store is unlikely to carry. I found one at a Radio Shack.

After replacing the battery and putting the board back in its compartment, snap the two halves of the fob back together. It may take a bit of squeezing.

A brief note on the photos: Although you can tell by the chewed fingernails that I’m not a hand model, I think the photos turned out quite well—despite being shot with overhead fluorescent lighting. I had my G10 set up on a GorillaPod, with the flash turned off, the lens set to macro, and the shutter release timer set to 5 seconds. I’d get the focus set with just my left hand and the key in the frame, then get my right hand in position after pushing the shutter release. The blue paper I put down on the table makes a nice background. The only post-processing needed was some lightening of the shadows in iPhoto to bring out details along the dark edge of the fob.

Update 10/6/09
Just replaced the battery in the car’s second smartkey. Since the second key is stored away from any electronic devices, I guess the battery life of the first key wasn’t reduced much by always being near my cell phone. Also, I learned of a second source for the CR 1632 battery: my local Batteries Plus.

Update 1/15/10
Two commenters have said that dealers charge $50 to replace a battery. I thought the $4+ I had to pay at Radio Shack was too much. No wonder car dealers are held in such high regard.

Update 2/5/10
I didn’t put this in the original post, because it is in the owner’s manual, but it’s probably worth mentioning here: if your smart key battery gets so low that the car won’t start with the key in your pocket or purse, you can start the car by putting the back of the key (the side with the Toyota logo) right up against the Start button on the dashboard.

Thanks to Jan in the comments for pointing this out, and thanks also to Jeffrey E. for prompting me to put it up here.

Also, you may be interested in my other Toyota-related post, which discusses the gas pedal recall.

Tags:


Heads-up on Iridium flares

Iridium flares are momentary bright reflections of sunlight off the polished antennae of the Iridium satellites. They can be as bright as magnitude -8 and last as long as a few seconds. There’s usually a good one every few days, and they’re fun to go out and see on clear nights—even more fun if you go out with your kids. Predictions of the time and position of up to a week’s worth of flares (and of other satellite crossings) are available at Heavens Above. To make the most of Heavens Above, you should create an account and have it save your latitude and longitude.

While it’s nice to be able to go to Heavens Above and look up the next set of flares, I thought it would be even better to have the information sent to me. Heavens Above doesn’t have an alert service, so I decided to make one of my own, scraping the information off its page and emailing it to me once a week.

The bulk of the work is done by this script, which I call iridium.py. It uses the Python mechanize module to automate the login procedure, grab the table of data from the Iridium flares web page, wrap that table in some HTML and CSS, and set up mail header that sendmail understands.

 1:  #!/usr/bin/env python
 2:  
 3:  import mechanize
 4:  from time import strftime
 5:  
 6:  # Card and email information.
 7:  mailFrom = 'drdrang@gmail.com'
 8:  mailTo = 'drdrang@gmail.com'
 9:  user = {'name' : 'username',  'password' : 'seekret'}
10:  
11:  # The URLs for heavens-above.com.
12:  # Login
13:  lURL = 'http://heavens-above.com/logon.asp'
14:  # Iridium flares for next 7 days. Need to add session id after login.
15:  iURL = 'http://heavens-above.com/iridium.asp?Dur=7&Session='
16:  
17:    
18:  # Create virtual browser and login.
19:  br = mechanize.Browser()
20:  br.set_handle_robots(False)
21:  br.open(lURL)
22:  br.select_form(nr=0)    # the login form is the first on the page
23:  br['UserName'] = user['name']
24:  br['Password'] = user['password']
25:  resp = br.submit()
26:  
27:  # Get session ID from the end of the response URL.
28:  sid = resp.geturl().split('=')[1]
29:  
30:  # Get the 7-day Iridium page.
31:  iHtml = br.open(iURL + sid).read()
32:  
33:  # Extract the table of flare times and magnitudes.
34:  table = iHtml.split(r'<table BORDER CELLPADDING=5>')[1]
35:  table = table.split(r'</table>')[0]
36:  
37:  # The links in the table are relative. Turn them into absolute URLs.
38:  table = table.replace('href="', 'href="http://heavens-above.com/')
39:  table = table.replace('HREF="', 'href="http://heavens-above.com/')
40:   
41:  # Templates for the email.
42:  mailHeader = '''From: %s
43:  To: %s
44:  Subject: Iridium flares
45:  Content-Type: text/html
46:  '''
47:  
48:  pageTemplate = '''<html>
49:  <head>
50:  <style type="text/css">
51:  body {
52:    font-family: Helvetica, Sans-serif;
53:  }
54:  h1 {
55:    font-size: 150%%;
56:    margin-top: 1.5em;
57:    margin-bottom: .25em;
58:  }
59:  table {
60:    border-collapse: collapse; 
61:  }
62:  table th {
63:    padding: .5em 1em .25em 1em;
64:    background-color: #ddd;
65:    border: 1px solid black;
66:    border-bottom: 2px solid black;
67:  }
68:  table tr.due {
69:    background-color: #fcc;
70:  }
71:  table td {
72:    padding: .25em 1em .25em 1em;
73:    border: 1px solid black;
74:  }
75:  </style>
76:  </head>
77:  <body>
78:  <p>For the week of %s</p>
79:  <table>
80:  %s
81:  </table>
82:  </body>
83:  </html>'''
84:  
85:  # Construct the html.
86:  html = pageTemplate % (strftime('%b %d, %Y'), table)
87:  
88:  # Print out the email header and contents. This should be piped to sendmail.
89:  print mailHeader % (mailFrom, mailTo)
90:  print html

Lines 6–9 customize the script for a particular user. You’ll want to change the email addresses and the Heavens Above username and password. Lines 18–25 create a virtual browser and log in to the site. The site responds by sending the browser to the site’s home page, but with a special session ID string appended to the URL. We grab that session ID for our subsequent browsing.

Lines 30–39 open the Iridium page, extract the data table, and convert all the relative URLs in the table’s links to absolute URLs. This is the sort of thing I would normally do with the Beautiful Soup parsing library, but for some reason, Beautiful Soup chokes on the Heavens Above HTML. So I just did a couple of straightforward splits on the HTML to isolate the data table.

The rest of the script consists of the HTML wrapper code and the mail headers. To send myself an email with the Iridium flare schedule, I run

python /path/to/iridium.py | /usr/sbin/sendmail -t

and I get a nicely formatted email of the schedule, which looks like this in Mail.app

and like this on the iPhone

The table is a little wide for the iPhone, even in landscape mode, but it’s easy enough to read and the links work.

There are several ways to use this code. As it stands, I’ll use Lingon to set up a launchd process that runs the above command every Monday morning and sends me the schedule for the upcoming week. But it would be relatively simple to eliminate the mail headers and wrap the HTML with RSS headers to turn it into a news feed. A more substantial modification could search the table for especially bright flares and send an email or targeted Twitter message on those days.

Tags:


An iTunes U recommendation

I’ve been listening to David Blight’s wonderful series of lectures on The Civil War and Reconstruction Era, 1845-1877, one of the Open Yale courses available through iTunes U. It’s 27 lectures, each about 50 minutes long, taken from the Spring 2008 session of Yale’s History 119 course. The short course description:

This course explores the causes, course, and consequences of the American Civil War, from the 1840s to 1877. The primary goal of the course is to understand the multiple meanings of a transforming event in American history. Those meanings may be defined in many ways: national, sectional, racial, constitutional, individual, social, intellectual, or moral. Four broad themes are closely examined: the crisis of union and disunion in an expanding republic; slavery, race, and emancipation as national problem, personal experience, and social process; the experience of modern, total war for individuals and society; and the political and social challenges of Reconstruction.

There are two versions of the course, audio and video. Because I wanted to listen while driving and biking, I downloaded the audio version. I suppose it might be nice to see a map once in a while, but I really haven’t felt as though I’m missing much by not having pictures.

Before discussing the course, I should mention its dangers. The Civil War is a topic that attracts buffs, especially among middle-aged white men, the demographic I happen to inhabit. As I was looking through the Open Yale offerings, I skipped over History 119 a couple of times. I was afraid that listening to it would identify me as a buff. Worse yet, it might turn me into one. Don’t get me wrong, buffs can be very nice guys1—a bit boring, perhaps, but relatively harmless. Among the foolish things men do in middle age, becoming a Civil War buff ranks as somewhat more foolish than becoming an avid biker (ahem) but less foolish than chasing after young women and—worst of all—golf.

The big danger of Civil War buffness is that it’s a gateway to becoming an re-enactor. One day you’re making room on the shelf for your Ken Burns DVD set and thinking about swinging through Chickamauga on the next family vacation; the next you’re growing out your mutton chops and wearing a woolen union suit in a canvas tent while having a heated discussion over the relative merits of James Longstreet and Stonewall Jackson.

Truthfully, History 119 isn’t likely to be especially thrilling to buffs. Only about a third of the course covers the war itself, and even that part doesn’t get into tactical details. Blight is more interested in telling us what America was like and how it changed—and didn’t change—over the course of those three middle decades of the 19th century.

I was at first put off by Blight’s voice; it seemed like he was doing a bad Garrison Keillor impression. But the strength of the material and the way he constructs his lectures soon won me over. Like every class I’ve attended—or taught, for that matter—History 119 has digressions, but Blight sticks pretty faithfully to the narrative he’s built.

With about two-thirds of the course behind me2, a few things stand out:

A few technical notes on the recordings. While the sound quality is good, with little of the echo common to recordings in lecture halls, it is at a fairly low volume. Also, the tracks are not excluded from shuffle play and do not remember their position—settings which are inexplicable for tracks of this type and length. All three of these problems are easily fixed by selecting all the lectures, invoking the iTunes Get Info command (⌘-I), and changing the settings like this

Tags:


  1. The buff gene is apparently attached to the x chromosome. I have never heard a woman—of any age—called a buff. 

  2. Spoiler alert: the North wins; Lincoln gets shot.