Latest Publications

Testing a restful JSON API

Back in blog business, first I want to start with a very few personal words. I left the gaming industries, now I’m working for Digital Pioneers N.V. there we do rapidly prototyping of new ideas with cool, new shiny techniques!

At the moment I work on the backend for Stuffle, the client-server communication is done via a restful json api. And here the challende begun. Symfony2 luckily offers very cool techniques to build a restful HTTP api. But as the client is written in a strongly typed language we have to make sure to meet the specified api. And when I say meet I’m fucking serious, a “date” must be and timestamp, nothing easier then that right? But when we as PHP developers take almost everything as a valid timestamp:

Nor in a strongly typed language, there we’ll already come into trouble with the second example. So we have to find a way to make the API very stable even during the development process, because the two parts were developed at the same time. So we decided to develop the API test driven. But have you ever written tests with for stuff like this, I did not before! Luckily we use symfony2 so the first step was to implement a service that transfroms our MongoDB documents (with some other extra dataproviders) into a json string which met the specifications. So almost all of our actions ends like

Now we’ll come to the tricky part. Because if we want to test the whole response including the types and it’s correct we would end in test methods containing around 200 assertions. NO WAY!

So we splinted up the whole thing into it’s parts. First of all we wrote normal UnitTests for the “api.response.json” service, and honestly mocking MongoDB documents sucks hard! And I swear next time I need some thing like that I’ll write an plugin for that. Anyway, that UnitTests make sure that the response is always valid when we’re using this service for the response content.

The other and even bigger part are the integration tests (Symfony WebTestCase). We use fixtures, lots of ‘em. And due to that fact the the UnitTests for this “api.response.json” service make certain that the response is valid regarding the api specs. We just have to check the HTTP response code and maybe some smaller fractional checks for the data in the response.

And yeha, that’s basically it. So the magic is to bundle all the responses to the service. And a little side note when you’re interested in how we’re developing and deploying my college florian wrote a few articles on his blog[GER].

Search Monster

Just the results of an sick idea, implemented quickly and dirty.

There’s also a cli version in PHP
Next step should be and npm package :D

My InnoGames GameJam Story

This weekend there was a big event at my employer InnoGames: The InnoGames GameJam Volume 2!
It was the second Jam InnoGames organized, but the first time for me attending. So there were tons of new experience and fun for me.

The countdown started Friday at 6 P.M. GMT + 1 and holds 48 hours of hardcore programming for us. At the beginning Michael, our organizer, hold a little (not well prepared) keynote and announced the topic of the jam: Space
(more…)

Game of Life with JavaScript and Canvas

Hey there! I’m back!

After a long time of silence here in this Blog, I’ll post some new stuff. This time just a little test or example from my labs. I wrote Conways Game of Life in JavaScript and rendered it on a Canvas element.

And yeha, i just like simple like this:

You can find the pages here. It’s only client-side code and not obfuscated or some thing, so feel free to take a look on the uncommented source.

Next step maybe is replace the canvas rendering with divs and dom, cuz … yeha … canvas is just too slow and maybe i’ll post this here again.

Profiling with WebKit

Hello again!
If you follow me on twitter you’ve already noticed that I took a look into the Chromium source.
I was searching for a way to profile specific code snippets.
I asked google for the WebKit Inspector Profile API with no result.
So i digged around in the WebKit Inspector code and found out how it works.

console.profile("Hard Calculations");
// the script you want to profile
console.profileEnd();

Pretty easy, huh? “Hard Calculations” is the name of the profile that will be created.
Btw. if you run this in the console itself you’ll only see injection functions so try it in your project.

Hope this was helpful for you.
Have a nice day!

Change URL without reload

Hello and welcome to the show ;)

I’m the new guy in the hood, i’ll also mostly talk about javascript development, maybe some server-side stuff and, if somebody cares, also 3D related stuff. Alright lets hit it.

We all know and use it, facebook. As a webdeveloper you may have noticed that the “main content area”(where the posts are) is the only part that reloads. It’s AJAX, damn you already knew that?! Ok, but you may asked your self how they’re changing the URL without a reload. I can tell you,this it not the all so mighty web 2.0 ajax magic thing. The stuff we are talking about is cooler, a lot cooler, it’s this experimental stuff, this “you can do everything, and more, in the browser without plugins” – HTML5.

So if you’re developing with browser compatibility in mind, take a second look at the url on facebook. It has a questionmark in the beginning, so PHP will parse these URL too. On the one hand it’s to be compatible with those other browsers on the other hand you need this for users who are browsing directly to one of those subpages.

Stop talking and show me how it works!

Alright!

You may think it has something to do with the window.location object. Sorry, it’s not! The object we’re looking at now is the window.history object.

window.history.pushState(
{
'test':"oh i am a test text :O",
'stuff':"some stuff here"
},"History title","/?changed");

So what do we have here?

The first parameter is an object which we’ll parse later, the second one is simply the name of the state and the third and last one is the new url. You can also change the whole url by starting with “http://” but same origin policy will prevent you from doing malicius stuff with it.

So lets go one step further and parse this object and also detecting and reacting on state changes.

window.onpopstate = function(event){
alert(event.state.test);
alert(event.state.stuff);
}

So i think this is pretty self explanatory, the onpopstate event get triggered if you move forward or backward in your browser history.
The state object contains the stuff you pushed in there. You’ll also find the state name somewhere in the event object.

I hope you enjoyed the read and we’ll see us again.
Follow me @twitter if you want to get news about WebGL and gamedevelopment related topics
and stay tuned to this blog for bleeding edge web technology informations.

see ya!

Life’s changing … Blog’s changing

After I did my last oral exam last weeks, this blog title shouldn’t be longer about trainee ship.
So the blog title change, but the topics will stay the same!

Ohh and I forgot to mention … The “Download” section will close in near future. Because that’s so 2000-style. I’ll host all interesting code on github :)

RauteMusik.FM goes live!

Hey there,

After about only 3 Month of developemnt time, my newest project goes live: www.RauteMusik.FM
That´s also the reason why it was so damn quiet the last month. And I hope, that I now have more time for this blog.

RauteMusik.FM Homepage

RauteMusik.FM Homepage

Hope you all like this site. It tooks a lot of work for my and my friends (Tom, Martin and Mike).

Now I can also write about the daily work from time to time. Because its not top secret anymore =)

There is also a YouTube video where you can watch us during the release.

RauteMusik Developers during the release! Yep! I’m in there too ^^

Hope you all like it, and please leave a comment if you do so :) If not just stfu!

Bye!

Calculate age with PHP DateTime

Hey there,

First of all I want to say sorry, that I don’t write anything for such a long time, but I’ve a really big project running and this is why I have no time for blogging at the moment. BUT I want share a little codesnippet with you. The project I mentioned is a big community site and therefor I needed a cool way to get the age from a user, but we only have his birthday. And nearly all solutions google shows me don’t respect the leap-years. So I have to look for a solution on myself. And yeah it’s pretty easy with the “new” PHP DateTime. Take a look:

$oDateNow = new DateTime();
$oDateBirth = new DateTime($sDateBirth);
$oDateIntervall = $oDateNow->diff($oDateBirth);
/* @var $oDateIntervall DateInterval */
echo $oDateIntervall->y;

That’s it. Easy, huh?

The next post in abount two weeks hopefully will announce the “big” project I’m working on. So stay tuned…

Themes for Netbeans

Hey folks,

It’s weekend, so there’s time for own projects and if you do like me, you already programmed the first five days before weekend. So its time for a variety!

While I clicked through the NetBeans wiki (Do you know that NetBeans 7 will come with git support?), I discovered that netbeans can also handle some kind like themes, called Look and Feel in Java. And you can easily switch between a few themes without any download anything, all the look and feel’s came with the JDK. I tried a few, but most of the things I downloaded are broken in any kind. So I will show you the inbuild ones. take a look!

GTK - NetBeans IDE 6.9.1

GTK - NetBeans IDE 6.9.1

Metal - NetBeans IDE 6.9.1

Metal - NetBeans IDE 6.9.1

Nimbus - NetBeans IDE 6.9.1

Nimbus - NetBeans IDE 6.9.1

And you can also download a variety of others.

You can try these themes with a single parameter on you netbeans call, like:

$ /bin/sh "path/to/netbeans/bin/netbeans" --laf com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel

You want to keep these theme? Just set it in your netbeans.conf, its located in your NetBeans etc folder. Just add the –laf parameter to netbeans_default_options

If you want to see more screens or need more help with the config. Take a look at The NetBeansPHP Blog, they put a lot more screens on their page. I think I will go on with Nimbus, or Metal, don’t really know:)

Happy coding!