uwMike.com

I am engaged to the beautiful and wonderful Tara Cleaver!

Archive for the 'Programming' Category

T9 Words

June 6th, 2009 2

Somewhere, a Telus rep is congratulating himself.

Four months ago, I was completely ready to ditch Telus and switch my phone service to an [MVNO](http://en.wikipedia.org/wiki/Mobile_virtual_network_operator). Indeed, if Zehrs hadn’t been repeatedly sold out of the handset I wanted, I’d probably be on the President’s Choice pay-as-you-go service. For light usage such as mine, it really is—by far—the most sensible and economical option.

In doing some soul-searching and bill-examination, however, it became apparent that my usage level really wasn’t light enough to realise a savings from switching to prepaid. So I called Telus and made a deal. Read on…

Pushing Data to the Browser With Open-Get

January 22nd, 2008 6

For anyone who’s curious how Gmail’s chat widget notifies your browser that a new message has arrived, be curious no longer: here’s a simplified page that [demonstrates the method used](http://sandbox.mikepurvis.com/js/openget/).

Note: Before we go on, I should just clarify that nothing here is based on insider knowledge of Google (I was never anywhere near the Gmail code), and any opinions expressed are mine alone.

This demo itself is of interest to technical folks, because it demonstrates a way for programmers to work around another frustrating limitation that arises from the architecture of the web—that when an interaction over http takes place between a client (browser) and a server (website), the client must always be the one initiating the connection. Read on…

Anatomy of an Open Social Network

July 8th, 2007 6

My Dad has [Facebook](http://facebook.com/). All my friends have Facebook. I have Facebook. I can count on one hand the people my age I know, that do not have Facebook. The people I met last term in New York and San Francisco all had Facebook.

Anyone who talks about “social networks” today as if they mean anything other than Facebook is being coy, or is deluded.

Classmates and Friendster haven’t been important in years; in the wake of its buyout, MySpace is rapidly losing relevance outside of musical artists using it for promotion.

Facebook is the model of a modern, successful, social website. It hits a very pleasant sweet spot between elegance, user-friendliness, and attention to [issues of privacy](http://uwaterloo.facebook.com/sitetour/privacy.php). But there is one major problem: If Facebook Inc screws up, the elegance and user-friendliness can all go away (some of the new Apps are definitely pushing it), and your privacy might go away, too. Facebook is a *closed system*; it’s a single point of failure on all three counts. Read on…

A Conch Shell Clock

June 10th, 2007 3

I’ve written before about the [power of JavaScript as a visualization tool](http://uwmike.com/articles/2007/01/08/javascript-visualization/). Then, I’d been talking about it in conjunction with straight-up HTML and SVG. Now I’ve got a neat new demo to share that takes advantage of Canvas.

You’re going to need Firefox or Safari to view this, but [check it out](http://sandbox.mikepurvis.com/js/clock/).

The genesis of this idea comes from Louis K’. Thomas’ [logarithmic clock](http://www.latenighthacking.com/projects/2005/logClock/), which [showed up on reddit](http://reddit.com/info/1thgm/comments) recently.

I had wanted to experiment with some more interesting visuals than what Thomas had in his original. I’ve always been fascinated with polar functions and spiral geometry, and this seemed like a fantastic opportunity to explore this area. Thinking of a traditional clock face, I mused about the feasibility of bending the log clock into some kind of round display that was less obviously just a mathematical plot.

Hopefully I’ll have more time at some point to write about the process of creating this, but for now, enjoy!

Prettify Bookmarklet

March 22nd, 2007 0

Google recently released [google-code-prettify](http://code.google.com/p/google-code-prettify/), a nifty little JavaScript for colouring up source code embedded in HTML pages. Anyway, here’s a version that you can [install as a bookmarklet](http://sandbox.mikepurvis.com/js/prettify/).

Parallelism

February 14th, 2007 0

Bjarne Stroustrup, designer of C++:

All that said, I don’t know what the next major conceptual shift will be, but I bet that it will somehow be related to the management of concurrency. As programmers, we have been notoriously bad at thinking about lots of things happening simultaneously, and soon our everyday computers will have 32 cores.

From a recent interview in Technology Review, [part 1](http://www.technologyreview.com/printer_friendly_article.aspx?id=17831) and [part 2](http://www.technologyreview.com/printer_friendly_article.aspx?id=17868). Read on…

Engines and Fireflies

January 8th, 2007 4

I had another opportunity recently to make a visualization out of JavaScript; I thought I’d share two examples of using the language for this purpose.

### The 6-Stroke Wankel

Last winter, there was brief flurry of activity over [some guy building a six-stroke engine](http://www.autoweek.com/apps/pbcs.dll/article?AID=/20060227/FREE/302270007/1023/THISWEEKSISSUE). The principle was ingenious—rather than waste excess heat through a cooling system, why not harvest it as an extra power stroke, by injecting distilled water into your cylinder? The rapid expansion of the liquid into gas would provide a small boost, plus drastically reduce the amount of cooling infrastructure necessary on the engine block.

6-Stroke Wankel

My immediate thought was, well, what about doing that with a Wankel? A [Wankel rotary engine](http://en.wikipedia.org/wiki/Wankel_engine) is a lightweight, high-torque system. Mazda uses standard 4-cycle Wankels with their RX7 and RX8 cars, but what about a 6-cycle one, that implemented this water-injection cycle?

[Jeff](http://jeffaho.com) helped me out with some of the formulas, and we ended up figuring out what the thing should look like. Now, it could certainly be modeled in a tool like SolidWorks, or AutoCAD, or maybe even MATLAB, but what’s the fun of that, when only people who have the software can look at it?

Instead, I tried going the SVG route. SVG is an open standard vector language that’s positioned to compete with Flash. Through various problems, it’s not as widespread as it could be, but all of Firefox, Opera, and Safari provide reasonable support for static SVG, and Firefox provides *excellent* support for SVG animation. So you’ll need to be using Firefox to view this, but [here's the animated demo of the six-stroke Wankel](http://sandbox.mikepurvis.com/design/engine.svg). Read on…

The Elevator Question

October 25th, 2006 0

In an [article about telephone interviews](http://www.joelonsoftware.com/articles/ThePhoneScreen.html), one of the design questions Joel says he asks is, *”How would you implement code to operate the elevators in a high rise?”*

Presumably, he’s looking for [something like this](http://everything2.com/index.pl?node_id=815179); a system that avoids “starving” the top and bottom floors.

Toronto Reference Library ElevatorIt’s a really interesting question, though. Legend has it that [SimTower](http://en.wikipedia.org/wiki/SimTower) had its origins as an elevator simulation, but then the SimTower elevator cars have that bizarre property that they can pass each other in a single shaft. I’ve heard explanations that each “shaft” represents a 15-deep bank of elevators, but that would require each condo and office to also be a group of 15, which in turn messes with all the other money- and people-scales in the game; ultimately, I think it’s easier to treat the elevators as fantastic and the game rules as highly abstract.

When [this article](http://dsc.discovery.com/news/briefs/20060403/elevator_tec.html) showed up last spring, it was unfortunately the middle of my exams, but I still took a few hours and tinkered with a quickie simulation. The notion of a rotating elevator is a highly interesting one—even moreso when you add in some kind of usable system that lets you declare your destination floor before boarding. The real challenge there, then, is to create a [game theory](http://en.wikipedia.org/wiki/Game_theory)-based control system that can group together people aiming for a single floor while still minimizing the wait time of each individual user. And also taking into account that lots of people will make mistakes, change their mind, and misunderstand the system.

Basically, I’m just writing because officially I’m studying for Signals, and it’s quicker to write than to dig out that code and start playing with it again. But yeah, I’ll post it up eventually.

Co-dependent Parts

October 17th, 2006 0

In an [article about mistakes a startup can make](http://paulgraham.com/startupmistakes.html), Paul Graham writes:

> Think about the overall goal, then **start by writing the smallest subset of it that does anything useful**. If it’s a subset, you’ll have to write it anyway, so in the worst case you won’t be wasting your time. But more likely you’ll find that implementing a working subset is both good for morale and helps you see more clearly what the rest should do.

I found this interesting simply because it has been my strategy for tackling our Realtime Operating Systems project this term. No individual piece of the project is particularly difficult, but it *is* a little tricky to map out a plan for incrementally developing it.

It’s obvious that certain auxiliary things can be bolted on later, but the majority of the assignment has to be in place before it does much of anything at all.

My approach? Get the major bits running in entirely separate, proof-of-concept programs. One group member is implementing a simple text parser, another the IRQ system, and I’m working with the final person on the switching stuff. There will still be an awkward moment when these parts have to be glued together, but at least each component will be known to function correctly on its own.

A Blast from the Past

October 4th, 2006 0

Some weeks ago, I randomly ran into an old acquaintance with whom I had a brief but extraordinarily profitable working relationship with during my last year of high school. As partners in *Drunken Ogre Entertainment*, we produced this little gem, over the course of a few shorts months of work:

empyrean09.gif
empyrean06.gif
empyrean08.gif
title.gif

Unfortunately, it won’t run playably under [DOSBox](http://mac.softpedia.com/get/System-Utilities/DOSBox.shtml) on my Mac, but for PC readers interested in trying this out, all you need is a friend and [the download here](http://uwmike.com/wp-content/uploads/empyrean.zip). You may need to turn off the audio (use the “nosound” command-line parameter) to get it to work, but it’s still a bucket of fun.

The thing I remember most about the game was not so much the fun we had making (and playing) it, but how much it taught me about geometry. It was in programming the particles and guided missiles that I finally gained a true understanding of how to apply basic trigonometry; until then, it had been a sort of voodoo-math that revolved around [some strange acronym](http://www.urbandictionary.com/define.php?term=sohcahtoa).

Recently, I was sort of hoping for some similarly practical exercise to teach me all about [Laplace](http://en.wikipedia.org/wiki/Laplace_transform).

© 2004-2010, Mike Purvis, some rights reserved. I'm running Wordpress, and I have an RSS feed.