Category Archives: Computer Science

MyTTC and StopFinder

So maybe everybody else in Toronto knew about these mashups, but I sure didn’t.

Until this afternoon.

So here’s some free publicity for them…

MyTTC

New to Toronto?  Intimidated or confused by the Toronto Transit System?

If you’ve tried the actual TTC website, you may find it confusing, and lacking in beginner information.  You just want to know how to get from point a to point b.

Enter MyTTC.  Just give it your starting and finishing location, and the hour you plan to leave, and it will plot you a trip through the TTC, lickity split. Google Maps style, with instructions on where to board, and where to get off.

I could have certainly used this during my first year here.

StopFinder

Tired of paying too much for parking?  Think you’re getting ripped off by sketchy lots?  Wouldn’t it be nice to get a good look at the entire “parking” picture of Toronto?

Check out StopFinder.  Just give it your destination, when you intend to arrive, and for how long, and it will show you the nearest lot, the cheapest lot, and all of the other options in the area.  Also via Google Maps.

Cool and useful mashup.  I like.

Making my First Firefox Extension…in 90 Minutes

It’s a race.

I’m going to attempt to create a simple Firefox extension that will display the DOM ID of an element that my mouse cursor is hovering over in the status bar.

There are probably a ton of Firefox extensions that will do that already, but I want to give it a shot as a project.

It’s 3:30PM right now, and I want to try to get this done by 5:00PM.  I’m going to be using Ubuntu 8.04, gEdit, and Google to get me started.

And I’m going to record my progress here in this blog post.

Note: After I’m done, I’m going to edit my sporadic notes so that they make more sense.  So if you’re wondering just how I managed to stay so cool, calm, and collected in my prose under such time pressure, and why the publish date on this article is after 5PM, now you know.

3:35PM:

Gonna start with Google:  “building a firefox extension”

Ok, found an article about how to create a Firefox extension.

Apparently, the first thing I want to do is try setting up a development profile in Firefox.

3:41PM

Finished setting up my dev profile by opening up FF with this command:

firefox -no-remote -P

Then created a profile called “Development”.  After that, I typed “about:config” in the URL bar, and changed some settings as instructed on this site.

3:49PM

According to that last article, I can create a skeleton Extension project using this site.  Done – calling the project DOM ID Displayer

3:53PM

Installed this Extension – apparently, it’ll be some help.  Will let me reload Firefox’s chrome  shtuff without restarting the browser each time.  Useful.

3:55PM

Found this article on making a status bar extension in XUL.  Easy as pie.

4:05PM

Ok, I’ve coded something in XUL that should display a new panel in the status bar.

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="chrome://domiddisplayer/skin/overlay.css" type="text/css"?>
<!DOCTYPE overlay SYSTEM "chrome://domiddisplayer/locale/domiddisplayer.dtd">

<overlay id="domiddisplayer-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script src="overlay.js"/>

<!-- Firefox -->
<statusbar id="status-bar">
  <statusbarpanel id="domiddisplayer" label="Hello, World!" tooltiptext="Dom ID Displayer" />
</statusbar>
</overlay>

I put that in the “overlay.js” file in my ~/Experiments/Extensions/domidinspector/content folder that was created using that Wizard from 3:49.

Now, to get this thing to run in my Development profile, I create a symbolic link to it in the Development profile’s extensions directory

ln -s ~/Projects/Experiments/Extensions/domidinspector ~/.mozilla/firefox/nzuzbdpz.Development/extensions/domiddisplayer@mike.conley

Open Firefox with Development profile:

firefox -P Development &

4:16PM

Looks like I can access and relabel the XULElement that I’ve ID’d as “domiddisplayer” using this:

domiddisplayer.updateDisplay = function(event) {
var dom_element_id = event.relatedTarget.id;
document.getElementById('domiddisplayer').setAttribute('label', dom_element_id);
}

Cool – I can now change my text in the Firefox status window.  Now I just need to capture any time a mouse moves over a DOM element….yikes, that might be tricky.

4:33PM

Been tinkering with this as a way of putting a mouseover event listener on everything in the window:

window.addEventListener("mouseover", function(e) {
  domiddisplayer.updateDisplay(e);
}, false);

4:35PM

Seems to only be capturing mouseover/mouseout events on Chrome elements – so I can get the ID’s of the statusbar, etc.  These are XUL Elements, not the DOM elements of a web page…

So I’m close.

4:44PM

This page is super helpful…

Apparently, I need to wait for the content of the page to load before I can attach observers to all of its sub-elements.  Makes total sense.

So, in my domiddisplayer.onLoad function, I write this:

var appcontent = document.getElementById("appcontent");
if(appcontent)
  appcontent.addEventListener("DOMContentLoaded", domiddisplayer.onPageLoad, true);

And now, I create a function called onPageLoad, which looks like this:

domiddisplayer.onPageLoad = function(aEvent) {
//Runs when the page is loaded
  window.content.document.addEventListener("mouseover",
  function(e) {
    domiddisplayer.updateDisplay(e);
  }, false);
}

5:03PM

Done.  I’m over time, but I’ve finished a (relatively) working extension.

Here, it’s a mess, but you can download the whole thing right here if you want to tinker with what I did.

Download domiddisplayer.zip

Parts of Firefox…coded in JavaScript? News to me…

So, maybe I’m about to state the obvious here, but believe it or not, parts of Mozilla Firefox are coded in JavaScript.

JavaScript?  Powering Firefox?  Holy smokes, I had absolutely no idea.

Let me back up for a minute.

There’s a very small possibility that I’m going to be working with Mozilla for Google Summer of Code this year, so I downloaded the Firefox code base to take a look at what their code looks like.

And it looks good.  Really good.  Clearly, the guys at Mozilla are pros.

So I was digging around in the source code, and in the folder mozilla/browser/base/content/browser.js, there is a JavaScript file that essentially details how Firefox behaves.

Look – here’s the function that handles when a new tab is opened in Firefox:

function BrowserOpenTab()
{
  if (!gBrowser) {
    // If there are no open browser windows, open a new one
    window.openDialog("chrome://browser/content/", "_blank",
                      "chrome,all,dialog=no", "about:blank");
    return;
  }
  gBrowser.loadOneTab("about:blank", null, null, null, false, false);
  if (gURLBar)
    gURLBar.focus();
}

JavaScript.  My mind is starting to get blown here, and I’m getting excited by the possibilities – seeing as how I’ve grown quite comfortable with JavaScript over the years.

And it’s all thanks to the Mozilla framework, apparently.  I’m only scratching the surface here, but I’m really interested in this, and I’ll post more as I learn it.

Sound in Theatre

I’ve been doing sound work in theatres since high school, and I’ve run into some pretty interesting software over the years.  I’ve used audio editing tools like Sound Forge, Audacity, Audition, SoundBooth, etc.  I’ve composed music in Cubase, Sony ACID Pro, FruityLoops, Apple Logic Express.  The list goes on.

But once the music is composed, and the sounds are all edited, how do you play them back during a performance?

The old way was to play them through a CD player; you’d burn all your sounds and music to disc, and then track through.  God help you if you had to do a cross-fade on an actor cue though, because that would mean having two CD players, cuing them up simultaneously, and doing a manual cross-fade on the mixer.

There are better ways to do this.

In fact (and my boss, UCDP Tech Director Peter Freund would agree with me on this), there seems to be a trend nowadays to put more emphasis in programming and preparation, and to make playback mostly automated.  It’s true for lights (lighting boards are pre-programmed with cues, and then the lighting operator just hits the ‘GO’ button to go through each transition), and it’s now true for sound.

Check out this piece of software. It’s called QLab.  And it’s free!  This is what we use at the UCDP.

But there’s a small problem:  it’s only for Macs.  Which blows.

Actually, it really blows.  As a modern web-developer, I take cross-platform applications for granted.  Sure, IE may quirk out, but we can usually work around that (thanks jQuery!  Prototype!).  QLab, however, is Mac software, and that’s all she wrote.  It’s really kind of heartbreaking.

If I had the time, and if someone would pay me, I’d look into writing an open-source cross-platform QLab clone.  In Java, maybe.  There’s probably a ton of issues doing cross-platform sound work, but Audacity did it – why can’t I?

Just a thought.

Oh, and yes, there is a free piece of playback software for Windows called Multiplay that’s alright, but I find QLab a bit more flexible.

CodeSprint ’09: What Happened?

For those of you who don’t know, this past Thursday, Friday, and Saturday, I’ve had my face planted into a laptop, working 8 hour days on the OLM project.  

And I wasn’t alone.

I was in a room with plenty of other Computer Science students – some even coming from as far as the West coast to join us. Good people, good times, interesting problems, and free food – all care of Greg Wilson, Karen Reid, and the other support within the department.  It was really fun, and I learned a lot.

And we coded our asses off.  Literally.  It was awesome.

So what did I end up actually doing?  Well, when TA’s are marking code, there are little menus that let them attach pre-built annotations to highlighted sections of code.  I’ve also replaced the ugly Javascript Prompt dialog that asks for new annotations with a nice, modal dialog, using LivePipe UI.  The team also got the rubric listed next to the code, and we now have the ability to apply grades on the rubric!  Awesome!  We’re almost there!  There are plenty of tickets, plenty of ways this code and interface can get cleaned up, but we almost have the behaviour we want.  And that’s something.

If I get a chance, there are two things I’d like to do:

  1. Replace the SyntaxHighlighter Javascript code with something a little less client-heavy.  Maybe we can syntax highlight the code on the server side before we send it to the client for viewing?  That doesn’t sound too bad… does anybody know of a Ruby gem that’ll do that?
  2. Refactor the annotations code.  Right now, it’s a lot of Javascript.  A lot.  I’d like to shave it down, simplify it, streamline it.  But that’s what refactoring is all about, right?

Oh, and, in other news, I’m considering graduate school, and doing Google Summer of Code.  Just something I’m mulling over in my head…

Update:  Coding for three days straight brought sooooo much tension back into my shoulders…this is where Movement class exercises become very handy…