Read my book

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

Friday, May 27, 2011

Using PHP to Generate Static Websites

This time I'll show you how to use a bit of PHP to generate static websites based on given templates. The cool thing about this kind of approach is that you may use features provided by your templating engine (inheritance, variables, whatnot) while not depending on PHP at the server side.

It is easy to translate this idea to other languages. I'll just stick to PHP in this post since that's what I ended up using. In case you need something more advanced, you might want to check out a pre-made solution such as Jekyll.

Monday, May 16, 2011

Using JSShaper to Provide Operator Overloading for JavaScript

In this post I'm going to show you how to use JSShaper to implement operator overloading for JavaScript. It's one of those features I've missed a lot.

I tried something similar previously by writing a primitive JavaScript precompiler using Python. JSShaper provides more reasonable way to achieve the same result by directly modifying JavaScript AST. Code-wise the solution is more than adequate as you shall see.

The current approach has still some limitations. I believe it should provide a good starting point for some further experiments, though.

Saturday, May 14, 2011

My iOS 5 Wishlist

I discussed my issues with iPad earlier, around five months ago. Since then some of the flaws mentioned have been fixed in current revision of the device, iPad 2. Most notably there should be now enough hardware for cool Augmented Reality applications to appear. They also managed to trim the weight and size of the device a bit.

I don't own an iPad 2 yet as I'm more than happy with the first version. In my mind it was more of an evolutionary update rather than revolutionary one. Perhaps iPad 3 will manage to make a bigger impact, especially if it introduces a Retina display.

In this post I'll present my wishlist for iOS 5 due later this year. It is best known as the operating system of iPhone, iPad and co. I've mentioned some of the gripes in my earlier posts discussing iPad but recapping them cannot hurt.

Tuesday, May 10, 2011

Functional Tools - Map, Filter and Reduce

In this post I'm going to introduce three highly useful concepts borrowed straight from functional programming. These concepts, namely map, filter and reduce, allow you to transform given input in a variety of ways. In addition I'll show you how to wrap these three in a nice, chaining environment to make it cooler to use them.

Thursday, May 5, 2011

Skribit - Your Way to Suggest What to Write

As it's difficult for me to know what kind of posts you people like to read, I set up a Skribit thinger. You can find it at right just below "Recent Comments". You can use it to suggest topics and vote on existing ones. Simple as that! Let's see how this works out...

Wednesday, May 4, 2011

Runner Pattern for JavaScript

While developing chaining assert a bit further at GitHub I came by an interesting testing pattern I would like to share. I use it primarily for testing my assert statement. Pretty cyclic, eh?

Sunday, May 1, 2011

Chaining Assert for JavaScript

Sometimes it's really handy to be able to assert various states. Even though JavaScript does not provide a native statement for this purpose, it's really easy to implement one as this example shows.

I took the syntax a bit further and ended up with a chaining version. The current version provides following features:

  • Chaining syntax (d'oh). Example: assert(a).is('number').between(0, 10);
  • "equals" method. Example: assert(a).equals('supercow');
  • "between" method. Example: assert(a).between(10, 20);. This means "a" should be within given range, ends included.
  • Basic type checks borrowed from RightJS. Example: assert(a).is('number', 'array'); meaning "a" should be either a number or an array.
  • "isDefined" method. Example: assert(a).isDefined() meaning "a" should not be "undefined".
  • Special "not" method that inverts the result of the following method. Example: assert(a).not().is('number'); . I admit it does not read that well in this case. It's way better with something like "between" or "equals".
  • Extensible architecture. It should be quite easy to tweak it to fit your tastes.