Read my book

I wrote books about Webpack and React. Check them out!

Thursday, March 29, 2012

suite.js - A Minimalistic Testing Tool for Node.js

As it so often happens while developing ghw (the GitHub wiki to GitHub pages converter thingy) I came by a nice and light syntax to use for testing. I took the syntax and then pushed it a bit further. As a result I have something I can now use on my Node projects.

In this post I'm going to introduce suite.js to you and show its basic capabilities. It's still in a very early stages but does some interesting things already. Besides basic testing functionality I've implemented generative tests (QuickCheck). The package, as ghw too, is available via npm.

Tuesday, March 27, 2012

Announcing JSwiki.org - Skin for GitHub JSwiki

You never know which of your projects are going to become popular and grow and which not. I guess it comes down to persistence and luck to some extent. Anyway JSwiki is probably the best known project I'm currently involved with. It's something I started to maintain over a year ago by a chance. Since then it has grown quite a bit and still seems to be growing (reaches 1000 followers soon).

GitHub wiki has been a decent platform for this growth and probably will remain as such for the time being. The main problem with it is that it's not that customizable. You are pretty much stuck with the default user interface it provides you. I guess one could try to get employed by these guys and then change things within but that would be a bit much to ask.

Something interesting happened around two months ago. Guillermo Rauch of socket.io fame contacted me about an idea he had. He proposed that it would make sense to have a generator available that would take the wiki content and then transform that into something suitable to use at GitHub Pages. This would effectively solve the problem I just highlighted. Having this sort of generator available would give plenty of flexibility.

I took the bait and implemented a system that does this. As a result ghw was born. By default it uses Mustache templating system. Each generated page will be compiled against a base template you may freely define. ghw also injects various data to the template (ie. page sections) making it possible to implement various customizations. Study the project demo for more details.

You can see output from the tool at JSwiki.org. I've done some initial tweaks there (ie. it's possible to sort tables) and will continue to do those based on feedback. The theme used is based on Skeleton. I really like how light and responsive it is. The site seems to work quite well on various different resolutions.

Feedback is welcome on both projects. I'm sure there are some kinks there waiting to be resolved.

Friday, March 23, 2012

Implementing Generators in JavaScript Using Closures

Around a month ago I was invited to speak two hours for a bunch of newbie web developers. I mainly spoke about Python and Django. I also took a brief look at JavaScript while at it.

During the development of the JavaScript mini-presentation I came up with a nice and simple way to implement generators. And by this I don't mean "yield" introduced in JavaScript 1.7. Sure, it's a nice keyword but it won't work in every browser. In this post I'm going to show how to use closures to achieve the same effect.

Madeira - a Hiker's Paradise

I escaped the Finnish winter to Madeira for two weeks a while ago. I just felt like I needed a break. There was no any particular reason why I went to Madeira. It seemed like this is one of those places where you can enjoy walking in a great scenery. And it appears I wasn't wrong in that.

Madeira is particularly popular amongst the Europeans and it shows, sometimes in a bad way. The less touristy bits are great, though. The weather during my trip was excellent. The sceneries were stunning. And I enjoyed the food too. It feels like the two weeks went by too fast.

I'll go through some highlights of the trip in this post so read on if you want to know what Madeira is about.

Wednesday, March 14, 2012

Dealing with Navigation in Django

I've been pretty busy with a surprise project (more on that later). I thought it might be fun to share one handy snippet I came up with during its development. There's no one right way to implement navigation in Django.

My solution utilizes a class (navigation "model") and a minimal include (template within template) that defines the markup. It also makes it easy to use i18n. Instead of boring you further just have a look at the code and let me know what you think. I'm sure there's still some room for improvement. Perhaps this will inspire someone to write something truly superior, or not.

My views.py containing the navigation looks like this:

You'll need to inject an instance of that class to your template context like this: c = {'navi': Navi(request.path)}. You'll also need some template to render it out. Here's one way to do that (includes/navigation.html):

There we go! Now we should have a spiffy little navigation on our site. It's probably quite easy to extend the idea to support nested navigation and whatnot. That's up to you, though.

PS. If you read this via RSS, it's likely the code examples didn't show up. Surf to this post or check out this Gist for code examples.