5/4 Teaching math (1)
A Mathematician’s Lament, by Paul Lockhart (via DHall)
I’m writing this response as I read through this fascinating paper on math in schools. I have for many years held the belief that (at the high school level at least) anyone can make straight A’s, even if they’re doing everything in their power to challenge themselves. This paper, if anything, strengthens my belief.
When I entered college, I thought I was pretty good at math. Then I met quite a few people that were good at math, so I stopped saying as much. I still very much believe it, though. A more surprising lesson was that I actually hate math classes. What I enjoyed were classes that relied on constructing and evaluating hypotheses and algorithms based on their mathematical merits.
Lockhart and the many others who’ve called BS on the way math is taught to students today have a point: math is inherently creative. Beyond that, though, they get a little overzealous. Painting and poetry (my go-to counter-example for the alliteration and audible distinction from “math”) are commentary about the world and its people, inspired by the painters and poets coming before. Math is an observation about the world and (less frequently) its people, based on the work of mathematicians coming before. Inspiration does not equal groundwork.
“[Math] has relevance in the same way that any art does: that of being a meaningful human experience.” This discounts the most beautiful thing about math: it elegantly describes the world in which humans experience. Economics is a fantastic framework for teaching this very thing. Economics is about building up simplified mathematical models of repeated observations about our world. Teaching math through economics will work because the types of observations economics sets out to describe are far more tangible than the concepts hand-waved away by formulas memorized in math classes.
“‘What do they want me to do? Oh, just plug it in? OK.’ [said the fictional average student.]” This is an all too common conversation, so much that teachers frequently reached for the canned reply, “plug and chug!” I had the distinct torture of taking a physics class in high school where the teacher instructed us to “just take the cosine” to find the length of one side of a triangle that didn’t contain a right angle. My classmates were happy to follow along. I felt the need to disagree. Teachers are not infallible and that must be accepted before the intellectual dialogue Lockhart describes can begin.
The lack of infallibility opens the door for other liberties, too. Paul Graham wrote that schools are primarily holding pens: “In fact their primary purpose is to keep kids locked up in one place for a big chunk of the day so adults can get things done.” Without teachers’ infallibility, the signal to noise ratio in the classroom would approach zero. Operating within the constraints of order first, learning second, it isn’t at all surprising that school is about following protocol.
Joy of joys, there’s a whole section on High School Geometry (capitalism his). Like the author, I found the material presented in High School Geometry fascinating and the scaffolding erected around it suffocating. I do lots of math in my head and made absolutely no accommodations for my teacher that insisted I “show my work.” I showed my thoughts, not my arithmetic. But due to the infallibility discussed above, I could not tell her where to shove it.
Math is not an art form the same as painting or poetry. But it is creative. It is an experience. And to teach it, it must be a dialogue. We need better teachers. To get there we need to make teaching noble again. More realistically, we need to make teaching a financially sane decision. Capitalism is cruel, I know, but it’ll get a whole lot worse if students learn only process and not how to progress.
4/28 MacBook Pro updates imminent (speculation) (0)
I purchased a new MacBook Pro last week. My 3 1/2 year old PowerBook has served admirably but it simply can’t keep up with me anymore. The faint and occasional clicking from the hard disk was the final push over the Intel edge for me and I couldn’t be happier. I decided to go with the 2.4 GHz model because $750 is a lot to pay for 200 MHz. I haven’t upgraded the memory to all 4 GB yet but that’ll come as soon as I spend some serious time with Aperture and Photoshop (CS3, finally).
I present this post as a warning to anyone holding off to see what Apple does next. Because I’ve made this purchase, I’m relatively certain that the WWDC will bring glorious new MacBook Pros, probably even radically redone AirBook-style. Maybe I’ll pawn this one off on my parents when the new ones come out (almost, but not quite not kidding).
A parting thought: holy crap the LED-backlit displays are bright.
4/8 Starting at OpenDNS today (16)
There are so many things to love about Flickr and especially about working at Flickr that I initially thought myself crazy for even considering leaving. But with time came sanity and I saw the pros for leaving start to outweigh the cons.
The folks at Flickr are without a doubt the most talented group I’ve ever had the honor of working with and I will miss them all. Flickr as a whole is a dream, a place with passionate staff matching passionate members and no shortage of new ground to break into, but my piece of this puzzle was not exactly right for me. I developed the new Flickr Uploadr desktop client as an open-source, extendable app for getting your photos and metadata onto Flickr. The project had everything I wanted — new technology, technical difficulty, performance concerns, design quirks and the goal of open-source extendability. But for all of that it had a fatal flaw — I am not a desktop software developer.
Thinking more forwardly, “I am not a desktop software developer” started to say what I really meant: “I do not want to be a desktop software developer.” Selfish personal preference.
This job at OpenDNS has all the ingredients of a good time in my book — C++, maybe some map/reduce, I/O bottlenecks, oh-my-god-databases-are-slow and a whole lot of networking (the TCP/IP kind). The people there are awesome just like Flickr’s and I have no doubt I’ll become just as attached to them.
(Housekeeping: it looks like the XULRunner saga on rcrowley.org has come to an end for the time being. I almost guarantee I’ll be back to dabbling with it sometime, though, since it’d be a shame for all that practice to go to waste. Don’t count on Windows XPCOM, though.)
3/22 PownceFS (21)
The magical code push finally happened! Time to send PownceFS into the Internet. PownceFS is a Fuse filesystem that mounts your friends’ files from Pownce as a local filesystem. Given a mountpoint, it fakes a directory for each of your friends and puts all the files they’ve uploaded inside. Files are cached locally for a while so you can repeatedly access things without spending your life waiting on yet another API call.
I can ls -l Mike Malone now!
rcrowley@banzai:~/powncefs$ ./powncefs.py mnt rcrowley@banzai:~/powncefs$ ls -l mnt/ total 0 dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 ajvchuk dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 andreiz dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 Andrew dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 chaddickerson dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 cowsandmilk dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 eston dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 evilcindy dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 flawedartist dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 halletecco dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 iamcal dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 ianloic dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 karaemurphy dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 katherinerose1224 dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 katiejane dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 laughingsquid dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 leahculver dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 mmalone dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 philfreo dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 phil_halley dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 rcrowley dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 tychay dr-xr-xr-x 2 rcrowley users 0 1969-12-31 16:00 waferbaby rcrowley@banzai:~/powncefs$ ls -l mnt/mmalone/ total 41429 -r--r--r-- 1 rcrowley users 59381 1969-12-31 16:00 loveletter.jpg -r--r--r-- 1 rcrowley users 291326 1969-12-31 16:00 mule.png -r--r--r-- 1 rcrowley users 3830 1969-12-31 16:00 powncer.zip -r--r--r-- 1 rcrowley users 75202 1969-12-31 16:00 sxsw_badge.jpg -r--r--r-- 1 rcrowley users 41992791 1969-12-31 16:00 TWiT0134H.mp3 rcrowley@banzai:~/powncefs$ fusermount -u mnt rcrowley@banzai:~/powncefs$
How can I get some, too?
On Linux it’s simply a matter of installing Fuse, python-fuse and the Python OAuth library.
$ sudo apt-get install python-fuse $ cd /usr/lib/python2.5/site-packages/ $ sudo svn co http://oauth.googlecode.com/svn/code/python/oauth
On a Mac I think it’s pretty easy but my Python’s wonky. Methinks the dependencies work themselves out — can someone verify?
$ sudo port install fuse-bindings-python $ cd <wherever the hell Python is> $ sudo svn co http://oauth.googlecode.com/svn/code/python/oauth
powncefs-0.1.tar.bz2 or http://svn.rcrowley.org/svn/powncefs/
Nerd out with me
The “architecture” (if you can really call something with 2 files an architecture) goes something like this: when you run the script a PownceFS object is created. The first thing it does is authenticate with Pownce and pull down your friends list to create it’s directory structure. Whenever necessary it makes an additional API call to Pownce to fetch the list of files for a particular user (say, if you ls their directory). API calls and files are cached for 45 minutes (safely under the one hour TTL of the S3 URLs returned by the API).
The root of the filesystem is a PownceFS.Base object that contains a dictionary of usernames to PownceFS.User objects. Each PownceFS.User contains a dictionary of filenames to PownceFS.File objects (look, Ma, inheritance!).
The main PownceFS object implements system call equivalents like getattr and readdir but defers the thinking to the tree of PownceFS.Base and friends. Each of those objects has a getattr function handling all of the filesystem bookkeeping, get and put methods for manipulating children and a fetch method for performing any API calls that need to happen. PownceFS.Files have an additional read method that reads the locally-cached copy of its file.
The point of that long-winded explanation is that the “architecture” is useful for absolutely any web service that might be a useful filesystem. The api.py file handles all of the OAuth-y stuff and leaves powncefs.py fairly generic. Hack!
Again, http://svn.rcrowley.org/svn/powncefs/.
Future plans
The most obvious enhancement is to allow file uploads, which I’m planning on adding soon. Otherwise I need to find a few minutes to loop the API calls to return more than 100 files for those Power Users. Details, details.
3/19 Oh yeah, that’s right, I went to SXSW (1)
I wrote this about a week ago and then forgot about it. Best course of action is to just post it.
The hangover has ended, time for some reflection.
There were so many people this year that it expanded into new parts of the Austin Convention CenterCave System I didn’t know existed. The increased attendance was most noticeable at the parties where I frequently had to request favors to gain entry. Thanks, pals.
The panel schedule this year was, to say the least, weird. There were days on end that contained nothing of interest to me, even given my temporarily broadened interests (more on that later). Emotional design? Gaming? Continued beating of the Internet video dead horse? No thanks across the board. Where was Khoi Vinh with a followup to his excellent grid design presentation from last year? Where were Mark Boulton and Richard Rutter with more typography? Hell, where were the Rails folks with at least something technical? Answer: they were all at the same time on Monday afternoon. I heard someone say they put all of the good panels in parallel to force people to choose so they wouldn’t have one one ginormous panel in each block with empty houses everywhere else. Slightly logical and incredibly annoying.
A quick list of favorites: the Kevin Rose led and Cal Henderson profaned panel on scalability; John Resig and company’s panel on JavaScript libraries (Alex Russell and Andrew Dupont were hilarious); and icanhascheezburger. In other words, I didn’t learn a great deal.
I’ve been kicking around this idea in my head that started as my explanation for what I hope to get out of South-By: SXSW is a necessary yearly dose of design for engineers. With as much fun as the “How to Rawk…” panels were to watch (again, learning absolutely nothing), it seems like a panel along those lines would float pretty well. Thoughts?
Anyway I’ve finally gotten back to the real worldInternet and been hacking up some good sauce. More on that whenever I damn well please.
3/3 Functional programming in C (3)
I’ve been meaning to write this post for some time to document how I avoid the giant-if-statement-with-strcmp() problempattern when writing C programs.
The solution to every problem in C is to use pointers. Keeping with that lemma, it’s possible, beneficial and even fun to make pointers to functions do your bidding without the pile of if or switch statements typical of most student programming projects. It’s really close enough that I started calling it functional programming years ago even though this is still a far cry from Lisp/Python/JavaScript/whatever. It doesn’t matter because C is still awesome.
Use the STL, Luke
I’m cheating a bit when I say functional programming in C. The use case I’m going to present is a C++ sample but there’s no reason why you can’t hash your own table in straight C99. I just don’t care to myself. The example uses the STL map class to map strings to functions, making it trivially easy to build your own shell-like app that takes some argument and dispatches a function to make it so. The map provides the nice dispatch-y interface but there’s no reason you couldn’t do something like this in plain C:
void foo(int i) {
printf("You called foo(%d)!\n", i);
}
void bar(void(*)(int) f) {
(*f)(2);
}
Anyone fluent in a scripting language that isn’t PHP will likely understand exactly what’s going on here. foo is a simple function that does nothing interesting. bar is a function that takes as its argument a pointer to a function. That function can’t return anything and must take a single integer argument. Many will call foul here saying that the strong type restrictions here make this sort of “functional programming” rather useless. I say nay and cite curvr.cc as my example. In any language, a function lacking any expectations for its arguments will be rather tedious. C doesn’t give you this as a way to shoot yourself in the foot (there are so many other ways, however).
Function pointer declaration
The simplest way I know to explain the difficult syntax of function pointer declaration is an analogy to something easy like a character and a pointer to a character.
char c : char * p :: void foo(int i) : void (*)(int)
The first half declares a character, c and a pointer, p that can point to c. Similarly, the second half declares a void function foo that takes an integer argument and a pointer to a void function that takes an integer argument.
Now for the useful part
Using this pattern for creating function pointers we can now define a few functions and map them in a useful way. This is again taken from my curvr.cc file (more info about curvr).
// First a few function prototypes to map
int curve(Magick::Image & img);
int bigcurve(Magick::Image & img);
int anticurve(Magick::Image & img);
// Then the map part
int main(int argc, char * * argv) {
// Magically figure out a string called process
// Setup the map using the address operator (&)
std::map<std::string, int (*)(Magick::Image &)> processes;
processes["curve"] = &curve;
processes["bigcurve"] = &bigcurve;
processes["anticurve"] = &anticurve;
// Call a function from the map
(*processes[process])(img);
}
Your code will be shorter now. Go forth and hack.
2/25 Firefox 3 — more better (6)
- Go to
about:config. - Set browser.urlbar.matchOnlyTyped to true.
- Profit!
This will cause Firefox to almost revert its address-bar behavior to the familiar Firefox 2 style where it matches the beginning of URLs instead of attempting some hairbrained search. If I’d wanted to search, I would have hit Apple+K.
2/11 More GReader hacking — immersion (2)
First, some updates to readelicious. I worked in Mike Malone’s patch to add a keyboard shortcut which I now can’t live without. I also reworked some bits of it to interact nicely with the new script.
Immersion is another Greasemonkey script that will load the current entry as an <iframe> within Google Reader. I made this one almost exclusively to look at A Brief Message but it works just as well for leaving a quick comment since it doesn’t interrupt your train of thought like opening a new tab does (I tend to forget new tabs until hours later).
Just like readelicious, immersion adds a link to each entry but also uses ‘i’ for keyboard access to the current entry.
http://svn.rcrowley.org/svn/greasemonkey/immersion.user.js or http://userscripts.org/scripts/show/22685
2/8 readelicious — hacking del.icio.us directly into Google Reader (7)
It’s just too many clicks to leave the ol’ feed reader to see an article and save it to del.icio.us. I’m not into that kind of commitment. I am, however, into Greasemonkey so I headed to userscripts.org and discovered two fairly poor attempts to do what I wanted. The first one just took me to the del.icio.us/post page which is a different kind of bad solution. The second one displayed a nice box in the page for editing the info before saving away to del.icio.us but it appeared halfway off of my screen and I didn’t have the patience to figure out why. Here are those two:
Mine has many virtues. First off it actually works and on any browser window size larger than 422 pixels. Secondly it is visually a bit more disruptive than the small Google-styled “window” that one displays but not so obnoxious as to take you off the page entirely. And finally, it automatically pulls the title, link and selected text from the article. Fully featured! As a bonus you get the timeless, classic and beautiful feel of my favorite color, #eee.
Because of the way del.icio.us’ API works, it’ll ask you for your username and password the first time through but after that should behave nicely.
http://svn.rcrowley.org/svn/greasemonkey/readelicious.user.js or http://userscripts.org/scripts/show/22494
2/5 Stop doing it yourself and use CPAN — curvr-0.2 (0)
Just like the career of the average software engineer, Curvr has now grown up just a bit and started reusing other people’s code.
Dopplr integration in curvrmail
Geotagging is awesome but a bit of a pain to automate with any kind of accuracy. I’m making a compromise here by automatically tagging things using my location according to Dopplr. I had this working with my original PHP curvrmail script but have since switched to using Flickr::Upload::Dopplr just to practice some Perl.
AutoManual image rotation
Since my N73 isn’t friendly enough to rotate pictures for me, I’ve added a way to specify rotation in the email you send to Curvr. Prefixing with “L ” or “l ” will rotate 90 degrees counterclockwise and prefixing with “R ” or “r ” will rotate 90 degrees clockwise. Note in both cases that it is a letter followed by a space followed by the normal title/tags syntax.
It is a bit awkward to think about in terms of left and right, since I could either be talking about the direction you rotated the camera or the direction the photo should be rotated (which itself could be rather ambiguous, so we’ll say that it is relative to the top). So here’s the official word: the rotate syntax wants to know which direction you rotated the camera to take the picture.
curvrconf for getting API tokens
Getting tokens for the Flickr and Dopplr API, while not something you need to do often, is quite a drag. Enter curvrconf, the copy-and-paste simple way to get your tokens out. All it needs is to be setup with the same API key as curvrmail and it’ll guide you through grabbing tokens. For the Flickr API, setup your key for web-based auth and give it a garbage URL to return to (I use http://localhost:81/).
As usual, the API key is up to you. I accidentally committed my keys/secrets/tokens to Subversion but have expired all of them so don’t even bother trying to steal my accounts.
Anti-blue C code
The main curvr program has for a long time introduced some strange blue artifacts into my photos. I figured this was due to some underflow or overflow issues with my color maps. I finally took the time to do some serious experimentation and it turns out that if I just favor a stronger red channel in these edge cases, the artifacts seem to go away. Strange and beautiful indeed. I can’t fully explain the phenomenon but believe it’s somehow related to my using the red channel as my indicator of color value (as many photographers do when converting to black & white).
So there it is, curvr-0.2.
Er, here it is: http://svn.rcrowley.org/svn/curvr/tags/curvr-0.2