Forkme

ramblings

wrench - tiny javascript web app framework

01 Jun, 2010 (2 comments)

I worked on a single page evented JavaScript app, at work recently. For that application I created a small framework for routing URL fragments to functions. Similar to Sammy (but without jQuery) or Ruby’s Sinatra.

I made it use able to route to several functions from 1 URL fragment. For instance if your URL was “foo;bar” that could route to foo() and bar() or what ever they had been mapped to.

Here is a small example:

In this example both app.users.list and app.users.show would get executed from the following URL fragment: “#users/list/;users/show/321”

Wrench is fully standalone. I haven’t tested all browsers tho.

Check out the github page for more info: http://github.com/hojberg/wrench

On age verifications

25 Mar, 2010 (1 comment)

I don’t get age verifications.

You must have seen them. I encounter them a lot watching game trailers. Often there is some sort of pixel blood in the video and that means you need to verify that you are 18+.

I am sure they only exist to help possible law suits or uphold some law. The problem is that it’s not really a safeguard in any way, I mean it must be rare that an underaged kid, does not bypass the verification in some way.

The worst part is that it seems they go out of they way to make it as annoying as humanly possible to tell them you are old enough.

Typically they confirm your age, using 3 drop down boxes to enter you age. This is from gametrailers.com

Sometimes they are a tad better and you can actually enter you birthday instead of using drop downs. This is from ign.com

But why not just have a single field where you can enter you age

Or better yet just a button to verify that you are over 18?

Now i am no lawyer, but this should be good enough to avoid a lawsuit? Maybe I am wrong, what do you think?

To give them some credit, it is worth mentioning that you usually avoid the age verification if you register with the site.

Javascript anonymous function sandbox unit testing

12 Feb, 2010 (1 comment)

So was doing a piece of JS that needed to have a small public API, but do a lot of stuff in the back that the developer using the script wouldn’t need.

I wrapped everything in the (function () { /* … */ })(); anonymous function sandbox, that is widely used.
In here, I could create loads of variables and functions that wasn’t accessible to the user of the script. All fine and dandy.

This example shows a public and a PrivateAPI. Only the PublicAPI variable lives in globalspace and is available to the user.

Problem was that i needed a really solid test suite, that tested both the PublicAPI and the PrivateAPI.
I am using the excellent QUnit, but i had no way of testing the PrivateAPI.

I ended up having to make some test specific code that would attach the PrivateAPI to window
to allow testing. This of course means that I have to remove the test hooks in production.

It ended up something like this:

So far this seems to be the best solution, but i seems ugly somehow, to have to make code for your tests like this. If anyone have a better solution please let me know. I guess you could just not use the sandbox method in a testing environment.

PDF Prototypes with Omnigraffle

11 Jan, 2010 (1 comment)

I recently started doing a lot of wireframes with Omnigraffle (previously i sketched on paper and went straight to code). This gives me a better overview of the interaction to create, and a nice way to get manager sign-off and in the end user testing.

I found out that you could easily make an Omnigraffle wireframe into a Interactive PDF Prototype.

Found this video showing how to do this. He uses a older version of Omnigraffle, but the process is pretty much the same.

Creating prototypes with Omnigraffle

Don't worry

07 Dec, 2009 (1 comment)

If you can solve your problem, then what is the need of worrying? If you cannot solve it, then what is the use of worrying? — Shantideva

I am blown away by this quote. You can’t argue with it at all. I really hope i can live my life with this in mind.

Worrying just makes you unhappy, and there is never a point in doing so. You should instead just accept the situation at hand, and/or act arcordingly. Don’t spend mental energy on being worried or sad.

It’s hard to live by this in everyday life. You naturally worry about stuff all the time, but i think it’s worth trying to remember this to be a little more happy :)

Welcome to the madhouse

06 Dec, 2009 (2 comments)

So this is my first post on the new site. Ditches the Wordpress, thought it be more fun to roll my own. Excited to see where this goes, and if I can find something clever to write about.

Anyways welcome and have fun :)