Blog

ActionScript 3 Maze Generator

September 13th, 2009

This is something that’s been sitting on my hard drive for a very long time now, an AS3 implementation of the Depth First Search algorithm, used here to generate mazes. This was originally created as a personal project, but it also ended up being applicable to a class. On both counts, the final product turned out to be pretty cool.

mikemaze_screenshot

In addition to generating mazes, it also allows you to spawn mice to mindlessly scamper through the maze. Although the same algorithm to generate the maze could be used to solve it, this would’ve been pretty boring to look at. The mice, when faced with a decision, simply randomly pick a direction to go. This simple solving algorithm also allows you to spawn a few hundred mice without any real speed loss, which makes it slightly more exciting to watch.

The only real problem with this implementation as it stands is that the mazes it makes aren’t very tough. The incorrect paths usually hit a dead end pretty quickly, making it a lot easier to backtrack and continue.

The download containing everything is attached below, released under a 2 clause BSD license.

Download SWF and source

JSONTamer: XUL-based JSON visualizer

July 27th, 2009

JSONTamer is a simple Firefox extension that adds a new sidebar, and a new menu item under Tools. It allows the user to paste in any valid JSON string, as defined by JSON.org. When a string is entered, and the user hits Display, a tree is generated, showing the resulting object.

jsontamer_screenshot_thumb

Current planned features include a version that can be used with the most excellent Komodo IDE, and a set of tools to allow creation of objects from scratch and manipulating existing objects.

A git repository will be available in the near future. For now, JSONTamer is only tested with Firefox 3.0 and above, though may work on older versions.

Download JSONTamer 0.1

Invoking the Firebug debugger from a script

June 9th, 2009

If you’re tired of digging through the Firebug scripts tab to find and insert breakpoints, I was told today about a little-known trick in Firebug that allows you to add breakpoints directly in the source JS file itself.

By issuing the ‘debugger’ statement anywhere in your code, Firebug will halt execution of the script at that location, popping up it’s debugger and highlighting the line where it was used. Example:

    <body>
        Debugging:
            <script type="text/javascript">
            for (var i=0; i<100; i++) {
                if (i === 50) {
                    debugger;
                }
                document.write(i+"<br>");
            }
            </script>
        Page end!
    </body>

Unfortunately, this feature seems to be specific to Firebug only, although the Chrome Javascript Debugger (CTRL + SHIFT + L) allows you to use the “break” command with an optional conditional. There does not seem to be any similar functionality in IE8, Opera, and Safari, although I would be glad to hear if it did.

QUAKE LIVE Twitter IRC Bot

March 13th, 2009

On #quakelive on QuakeNet, there is a bot named QLTwitter that spits out text everytime the QUAKE LIVE Twitter account is updated. I’ve gotten a few requests for the code, so figure I’d publicly release it.

It has a couple of dependencies, all of which are available in Debian packages. Specifically, it requires POE, its IRC client module, and JSON modules. It is basic, but it works, and can easily be changed to broadcast tweets from any other account.

use warnings;
use strict;

use POE;
use POE::Component::IRC;
use JSON;
use LWP::Simple;
use Time::HiRes qw(time);

my ($irc) = POE::Component::IRC->spawn();
my $currStatus = '';
my $updateDelay = 120;
sub CHANNEL { "#quakelive" }

POE::Session->create(
    inline_states => {
       _start     => \&bot_start,
       irc_001    => \&on_connect,
       tick       => \&checkTweet
    },
);

sub bot_start {
    $irc->call(register => "all");
    $irc->call(connect =>
          { Nick => 'QLTwitter',
            Username => 'QLTwitter',
            Ircname  => 'QLTwitterBot by sponge',
            Server   => 'us.quakenet.org',
            Port     => '6667',
          }
    );
}

sub on_connect {
	$irc->call(privmsg => 'Q@CServe.quakenet.org', 'AUTH sponge ------');
	$irc->call(join => CHANNEL);
	$irc->call(privmsg => CHANNEL, 'QLTwitterBot is LARGE and IN CHARGE!');
	$_[KERNEL]->delay( tick => $updateDelay);
	checkTweet();
}

sub checkTweet {
	eval {
		my $json = get 'http://twitter.com/statuses/user_timeline/quakelive.json';
		my @statuses = from_json($json);
		my $curr = $statuses[0][0]->{'text'};
		if ($currStatus ne $curr) {
			$irc->call(privmsg => CHANNEL, "New QUAKE LIVE Twitter update: $curr");
			$currStatus = $curr;
		}
	};
	eval { $_[KERNEL]->delay( tick => $updateDelay); }
}

$poe_kernel->run();
exit 0;

New Server

March 9th, 2009

If you are reading this (which is kind of silly since if you’re not reading this you’ll have no idea this is there) then you’re reading d8d on the new server! Have been spending a couple of hours tonight getting all my stuff off our old server which is very likely ready to die any moment now. Anyway, hopefully all goes well, and time permitting, there’s been a few things I’ve been meaning to blog about.

New design online!

January 29th, 2009

Finished up the couple of remaining bits, and my new design is now officially up! The blog at the moment is still unskinned, but I’ll probably be fixing that in the near future. The new site should hopefully be compatible, or at least working, in most major browsers, so any feedback on broken things would be greatly appreciated.

New Design

January 18th, 2009

Things have been pretty quiet recently, so I’ve been slowly redesigning this site. Although I’m still a fan of my current design, I figure it’s about time to change again. For anyone interested, here’s a screenshot of what the new site looks like. No clue when the new design will be up, but hopefully it won’t be as long as it took to finish my current one!

Twitter

January 3rd, 2009

Twitter is one of those things that a lot of people just don’t get. I didn’t either, but still signed up anyway. I’ve found already that I already use it more often than this bigger blog, mainly because the smaller message size forces you to write quick updates. It’s convenient like text messages, another technology that I didn’t get until I started using it. Essentially, it’s free text messaging with the added feature of broadcasting to a group of people.

There are quite a few clients available, too. On my Windows Mobile phone I’ve been using the standard m.twitter.com, which works more than well enough. On my desktop, I generally use Twittget, which works as a Vista sidebar gadget. Very convenient (the sidebar idea in general is) and it doesn’t create more tray icons. It notifies me of new messages in the gadget itself, and with a bird tweet sound.

If any of my 3 readers whom I aleady haven’t told about it wish to add me, check out my profile at Twitter. I’ll be looking into how I can integrate it with the front page somehow in the near future.

iPhone Web Applications

December 10th, 2008

RIT offer a class “Web Application Development for iPhone” and looking to fill my schedule, I’ve been taking it this quarter. Despite my skepticism at the hardware and Apple’s treatment of the platform in general, there is a lot of cool stuff there.

First, arguably the biggest feature, is Dashcode. Although it suffers from poor support and being Mac OS X only (attempts to run it in a virtual machine thus far have failed) the idea and execution is great. It is essentially a visual application builder, not unlike the old FrontPage, and the form builders in Visual Studio, etc. It does a reasonably well job of hiding the web part in web design, coming with pre-built components that match the iPhone look. Output will obviously only work on the iPhone/iPod Touch; not even Safari can run output.

Being able to target only one browser allows you to use much of the cutting edge features. CSS3, HTML5, and the more advanced JS features are all available, along with GPU-accelerated transitions. It is very much a look into the future of what all browsers will eventually support, except with a viable platform available today for immediate development.

Although the mobile web has a lot of hype and buzzwords associated with it, there is some substance to be found. It is pretty exciting to see what the next-generation of browsers will bring as a new standard. With technologies like Adobe Alchemy bringing C++ to Flash, there are certainly exciting times ahead for web applications.

Wheel of Friends

September 9th, 2008

This is something I produced last year, as a part of the Open Publishing Lab so unfortunately the source isn’t available as of yet, but it’s still worth nothing.

The below is a visualization of the results of a social networking game we ran at a festival last May. Hit the link for all the details, but the gist of the game is people trade barcode stickers with people who share at least one interest out of a pool of 8 or so. Those people who connect are scanned in via a normal scanner, an application rips the barcodes and stuffs them into a database. Once those links in the database are made, it’s a bit hard to visualize it all. This is where my part came in: visualising all the people via a wheel.

The wheel was created in PHP, using a little trig, and a lot of tweaking. The output can accomdate a virtually unlimited amount of people and links. Plus, it’s pretty to look at. The wheel has gotten a lot of mileage (no pun intended) on a lot of the promotional material for the OPL.