Paste Your Taste - a Last.fm replacement

August 20th, 2008 | by: Justin Mazur

Remember back in the old days of last.fm there was this really helpful feature called paste your taste. It allowed you to get a list of all your top artists, copy that list, then paste it into social networking sites like FaceBook or MySpace. That featured disappeared with the release of the new last.fm… until now.

Follow my few easy steps to get your pasteable atrists in no-time.

One hundred Pushups - Week 1 of 6

August 18th, 2008 | by: Justin Mazur

Someone on twitter (follow me) was talking about this site hundredpushups.com and I decided I would give it a shot. I mean, doing a hundred consecutive push-ups is pretty bad-ass, is it not? So on my trek to bad-assery I recruited Chris and Neil from the office to take part. We did our initial tests on Friday August 8th and were pumped for the following 6 week challenge.

Initial test - Do as many push-ups as you can.
Chris: 18 - Level 3
Justin: 20 - Level 3
Neil: 30 - Level 4

From this point on every Monday, Wednesday and Friday we drop what we were doing and do 10 minutes of push-ups. Week one went over fairly well. For the first week we followed the chart for our push-up level:

Monday the 11th:
Chris: 10 (max)
Justin: 15 (max)
Neil: 31 (max)

Wednesday the 13th:
Chris: 12 (max)
Justin: 20 (max)
Neil: 30 (max)

Friday the 15th:
Chris: 12 (max)
Justin: 20 (max)
Neil: 30 (max)

And that draws the conclusion to week one of six for the hundred push-up challenge. I’ll keep everyone updated as week two rolls to an end.

One Of The Best Things I’ve Ever Watched

August 15th, 2008 | by: James Hamilton

Watching this guy remove the dent from this car is strangely captivating. Hopefully this clip with get an Oscar nomination for best short because it really is one of the best things I’ve watched in years.

I also have to mention that the soundtrack is top notch. Anyway, enjoy watching the dent disappear before your eyes. It really is a treat to see how this guy works. He’s like the Michelangelo of dent repair.

Javascript Controller

July 29th, 2008 | by: PJ

Article Quicklinks

Wha?

What exactly do I mean when I say “javascript controller”? What I have in mind is a program/script that resides on the server side which controls the way the javascript is passed to the browser (or whoever requests it).

Let’s have a couple of examples to illustrate what I think a basic javascript controller should be able to do.

Consider the following HTML code example showing how to load two javascript files using only one <script> tag:

<html>
<head>
	<script type="text/javascript" src="scripts/script1+script2"></script>
</head>
<body>
	Hello!
</body>
</html>
Example1.html: Example showing two javascript files being included in the same script tag.

And consider the following javascript code example showing how to include/require another file:

/* REQUIRE: Coordinates */

var Circle = function()
{
	this.coords = new Coordinates();

	this.setCoords = function(x,y)
	{
	this.coords.set(x,y);
	}

	this.draw = function()
	{
		// ...
	}
}
Circle.js: Example showing a simple require statement.

And finally consider another javascript code example of a file loading another javascript file from some javascript code library.

/* REQUIRE: lib/Animation */

Animation.fadeOut('some_div_id');
FadeSomeDiv.js: Example showing a require statement from some predefined javascript library.

Why?

At the bare minimum, what I ultimately wanted was to have a script that would be able to require/include other files, especially from a reusable library or framework. But there are so many side benefits that come along with it.

  • the ability to (re)use a library or framework across all projects
  • less server calls (that is, the browser only grabs one big javascript file instead of a bunch of smaller ones)
  • organization (no more massive 100k files to work with)
  • sweet inheritance possibilities
  • future possible addons: caching; and compression, things like removing comments and whitespace, and maybe even variable name shortening

The point is that there are a ton of advantages in creating such a script - or, I suppose, in having someone else create one for you.

How?

So, if all of this sounds interesting enough to try out for yourself, let’s try get it setup.

You can download the controller, including the examples files, here:

Download Javascript Controller + Examples

Unzip that business to your server (or on your home xampp setup). Here’s a running example of example.html.

Included in the .zip are these files (a more thorough investigation of these files can be found in the next section):

example.html
The example html file showing how to include/require files.
scripts/.htaccess
This is a configuration file which tells Apache to route all requests from scripts/some/request/ to scripts/index.php (that is, route them to the javascript controller).
scripts/index.php
This is the controller. You can set the path to your own library in this file.
scripts/Examples/ShapesExample.js
This is the example javascript file that the example html file opens.
scripts/My Library/Shape/Circle.js
A circle object in the library.
scripts/My Library/Shape/Rectangle.js
A rectangle object in the library.
Contents of javascript-controller.zip

But there are a couple things to note about how the controller works:

  • The library path is set inside of the javascript controller (index.php); in the example case the library path is “My Library”. Just change the value of the $libdir variable to the path of your library, and you should be good.
  • The extension .js is always appended to the end of the requested script files, so just something to be aware of.
  • If a file is “required” twice, it will only be included once (the controller keeps track of the included files and checks for duplicates).
  • When a file is required (R), it will appear before the file that required it (A), but if another file (B) which appears before the first file (A) and which requires the same file (R), the required file (R) will always appear before both files which required it (A and B). (I get the feeling that could have been said much more simply..)

An explanation of what’s going on in the example included in the .zip

Alright, so if we take a look at this html file:

<html>
<head>
<script type="text/javascript" src="scripts/Examples/ShapesExample"></script>
</head>
<body>
	<input type="button" onclick="circle1.report()" value="Call method circle1.report()">
	<input type="button" onclick="rectangle1.report()" value="Call method rectangle1.report()">
</body>
</html>
	
example.html: showing off how to include files in the html file

We can see that the script is “scripts/Examples/Shapes”, but what’s actually going on is that there is a PHP script located at “scripts/index.php” which gets executed, and checks to see if there is a file on the system called “Examples/Shapes.js”.

Our example script “Examples/ShapesExample.js” looks like this:

/* REQUIRE: lib/Shape/Circle */
/* REQUIRE: lib/Shape/Rectangle */

var rectangle1 = new Rectangle();
rectangle1.setCoords(0,0,30,40);

var circle1 = new Circle();
circle1.setRadius(9);
circle1.setCoords(30,30);
Examples/ShapesExample.js: the shapes example includes the files circle and rectangle from the library

The Javascript controller reads in this file and parses it, looking for REQUIRE statements surrounded by comments, like the ones above. It then loads those files in the same way (reading and parsing), including more files.

The special case, like the one above (e.g. lib/Shape/Circle), is when something from the “lib” (the library) is specified. The library path is set inside of the javascript controller; in this example case the library path is “My Library”.

The javascript controller thus looks for the files My Library\Shape\Circle.js, which looks like this:

var Circle = function()
{
	this.x = 0;
	this.y = 0;
	this.radius = 0;

	this.setRadius = function(r) { this.radius = r; }
	this.setCoords = function(x,y) {
		this.x = x;
		this.y = y;
	}

	this.report = function()
	{
		alert("I am a Circle with a radius of " + this.radius + " and which sits at co-ordinates " + this.x + ", " + this.y + ".");
	}
}
My Library/Shape/Circle.js: a circle object, located in the library

And, it looks for My Library\Shape\Rectangle.js, which looks like this:

var Rectangle = function()
{
	this.x1 = 0;
	this.y1 = 0;
	this.x2 = 0;
	this.y2 = 0;

	this.setCoords = function(x1,y1,x2,y2) {
		this.x1 = x1;
		this.y1 = y1;
		this.x2 = x2;
		this.y2 = y2;
	}

	this.report = function()
	{
		alert("I am a Rectangle which sits at co-ordinates (" + this.x1 + ", " + this.y1 + ") are (" + this.x2 + ", " + this.y2 + ").");
	}
}
My Library/Shape/Rectangle.js: a rectangle object, located in the library

It then puts all the files together and spits out one big Javascript file, which looks like this:

var Circle = function()
{
	this.x = 0;
	this.y = 0;
	this.radius = 0;

	this.setRadius = function(r) { this.radius = r; }
	this.setCoords = function(x,y) {
		this.x = x;
		this.y = y;
	}

	this.report = function()
	{
		alert("I am a Circle with a radius of " + this.radius + " and which sits at co-ordinates " + this.x + ", " + this.y + ".");
	}
}
var Rectangle = function()
{
	this.x1 = 0;
	this.y1 = 0;
	this.x2 = 0;
	this.y2 = 0;

	this.setCoords = function(x1,y1,x2,y2) {
		this.x1 = x1;
		this.y1 = y1;
		this.x2 = x2;
		this.y2 = y2;
	}

	this.report = function()
	{
		alert("I am a Rectangle which sits at co-ordinates (" + this.x1 + ", " + this.y1 + ") are (" + this.x2 + ", " + this.y2 + ").");
	}
}

var rectangle1 = new Rectangle();
rectangle1.setCoords(0,0,30,40);

var circle1 = new Circle();
circle1.setRadius(9);
circle1.setCoords(30,30);
This is the generated javascript file that’s sent to the browser.

Hopefully there should be no surprises with that result.

And let me know what you think — it might be inspiring enough to write some of those future addons!

Zend Framework 1.6RC

July 25th, 2008 | by: Chris Woodford

If you don’t frequent the zend framework website you might not have realized that they already have a release candidate for version 1.6 of the zend framework. What’s interesting about version 1.6 (other than the additions to my new friend Zend_Form) is that it comes bundled with the Dojo javascript framework. On the surface this seems like a good idea: a php framework and a rich integration with a javascript framework. Your basic all-in-one package. Looking deeper, I feel like this has the business equivalent to “code smell” to it. Why did Zend select Dojo out of all the javascript frameworks out there? The community doesn’t seem to think Dojo is the right way to go. All the blogs I’ve been reading seem to be really pushing jQuery. But then again programmers (yes, myself included) are a fickle sort and tend to always jump on whatever bandwagon seems to have the most hype. So now Zend has taken it upon themselves to make it easier for programmers already using the Zend Framework to start using Dojo. Did Dojo start loosing the popular vote and figure their best bet for the future is attempting to piggy back on the Zend Framework’s hype? The relationship between the Zend Framework and Dojo is clearly beneficial to both parties and the integration of the two will only become easier and more seemless over time. I suspect it will get to the point where the ease of using Dojo far out weighs the hassle at attempting to use another javascript framework. I figure the result can go one of two ways, developers using ZF will either: convert to using Dojo or come together and extend the Zend Framework to have a rich integration with other javascript frameworks.

In a perfect world, business wouldn’t determine the choice of programming language or tools that we use. As part of an open source community, we have the tools required to make our own decisions and to branch off when business begins to constrict our choices.

What do you think?

Free App: PHP Simple Gallery

July 25th, 2008 | by: Justin Mazur

Here at the office, when we’ve run into a bottleneck design wise, we’ve used a collection of images to inspire us, mostly in the form of large, slow to open, and hard to share layered PSD resource files.

To fix this problem I slapped together this simple php image gallery. No database required, no extensive configuration. Just upload files and folders and you’re done.

The gallery seeks through up to 2 levels of folders and generates thumbnails* of png, jpg or gif images on the fly. The left hand navigation lists all the main folders and sub folders so you can get to what you need to look at quickly.

Installation is simple:
1. Un-Rar all the files.
2. Upload to your server
3. Create the directory ‘files’ in the same folder as index.php
4. Upload your files and folders to the ‘files directory’

thats it.

Feel free to give it a shot, modify it to your heart’s content. If you come up with a wicked awesome mod let me know and I’ll add it to any modifications that I do in the future.

Download Here

*Thumbnails are generated by WV4, modified by me to work with png, jpg and gif

Guh Guh Guh Guh Guh Guh Google-Unit???

July 24th, 2008 | by: Neil

Google Unit

Monster Energy Drink Feature Requests…

July 21st, 2008 | by: Neil

A few feature requests…

1. A half can size… Sometimes you only need a taste…

2. More drink flavours based on the green formula…

3. More frequent stocking of Assault. A few droughts last year… Can’t handle that shit.

4. Monster candies. Def gotta have a variety pack.

5. Caffeine free? I love the taste… Tired of feeling like a crusty custy…

Thank you

iPhone CDMA

July 15th, 2008 | by: Justin Mazur

iPhone CDMA

iPhone CDMA

Thats right, you didn’t read wrong. I said iPhone CDMA. It does almost everything the iPhone 3G does and it’s cheaper, has twice the space and I can send mass text messages.

This is me giving the finger to Rogers for their ridiculous iPhone plans. Lets backtrack to January 2008 for a minute.

Once upon a time, when iPhones were only available in the States, I pre-ordered an iPod Touch. It was a great piece of technology. I said ‘was’ because it disappeared a few months later. After mourning the loss of my beloved device I began searching for an imported iPhone. After giving up in light of the crazy-high prices on eBay I waited patiently for the iPhone to officially come to Canada.

The iPhone came to Canada, but not without a steep price. I weighed my options, fork over my hard earned cash for this sweet sweet phone or carry on with my Bell Mobility contract for a few more years and feel like a little part of me is missing.

Around this time is when it hit me, the iPod that I had once lost would have been able to function almost the same as the iPhone (minus all the phone and GPS goodness). The next day I headed over to my local Apple store and picked up an iPod Touch 32 GB. That night I had my fun downloading and rampaging the App store and damn was it ever worth it.

Now I carry with me my trusty Samsung SPH-A860 in one pocket and my iPod Touch in the other. It covers everything I need. Sure it would be nice to have access to the internet at all times on the iPod but seeing as I’m on a wireless network 90% of the time I think I’ll survive the other 10% without the access.

And that there is how I’m doing my part in not giving Rogers my $4,000 (give or take a bit) in iPhone and iPhone contracts. For the bit of inconvenience that the two devises will give me I think it’s worth it.

Red Hot Chili Peppers + Justice?

July 11th, 2008 | by: Neil

So I’m behind on the arrival of good news but I heard(read) through the grape vine that Justice is to produce the next Chili Peppers joint. I also read somewhere that Anthony, John, Flea and Chad (why are drummers always listed last?) will be “TAKING A HUGE GAMBLE” because Justice have never produced anything for anyone else.

Huh? Are you for real? Those Christian bastards can chop gold out of wood - how is that a gamble? I’m more concerned with the lack of Rubin. Scary yet mysteriously curious times, I say…

respec