Author Archive for Pepijn de Vos


[Update] Peer To Peer Social Networker

Many of you have experienced issues where the xmlrpc module was not installed with PHP, since the documentation lists it as experimental.

My SQL server stopped working, so I did very little testing, but here is a new version that uses plain XML and Curl to get the message across. I also found the point where the warnings are generated. It seems feeds are not saved properly. When my server is running again I’ll fix that as well. It’s a pain to work over FTP…


Chromium for Mac install script

Chrome isn’t officially out for Mac yet, but in the mean time you can get Chromium — the open source version — to give it a try. It is not recommended to use Chromium for daily browsing at this stage! (although you can of course, but don’t transfer money with it okey?)

For me the problem is that it gets developed quite fast, so instead of downloading it every day I wrote this installer to make it easy to get the latest version:

curl$(curl >
killall Chromium
rm -R /Applications/
cp -R chrome-mac/ /Applications/
rm -R chrome-mac
open /Applications/

All you need to do is paste this in a file and run that file by dragging it into You might just as well open Automator and add the ‘Run Shell Script’ action to it with this code, or make a crontab/initd to run it automatically.


Webkit feature test

The last few days I’ve been writing a 3D game.

  • Not just a game, an online multiplayer game.
  • Not just a 3D game, but one run in my browser.
  • Not just in my browser, but only with CSS and HTML(and some JS and server side stuff of course).
  • Not just AJAX, but Comet.
  • Not just PHP+MySQL, but only ±30 lines of Bash.

Don’t believe me? Watch this:

It started out a few days back when I read about Comet. I found out about the new EventSource support in Webkit, but I was in doubt how to implement this on the server. My first thought was throwing some PHP+MySQL at it, but I decided otherwise.

Normal Ajax is pull data transfer. You push data to the server, but every time you need data you request it and PHP in turn requests it with the database.

Doing Comet with PHP+MySQL would make the server push data to the client, but the server still does pull transfer with the database.

Then I came up with named pipes, and because named pipes are the easiest in Bash I used that. Now every listening transfer creates a FIFO and all new data is just written to them. This system creates on big U-turn where everything submitted is instantly sent back to all the clients.

This is all the bash code I’m using:


echo "Content-type: text/plain"
echo ""

cd data
echo -e "event:message\ndata:$QUERY_STRING\n" | tee -a $(ls -1)

cd data

if [ $(ls -1 | wc -l) -lt 5 ]
    echo "Content-type: text/event-stream"
    echo ""

    mkfifo data$$
    trap rm\ data$$ SIGTERM SIGKILL EXIT

    while [ -p data$$ ]
        cat data$$
    echo "Content-type: text/plain"
    echo "Status: 503"
    echo ""
    echo "Sorry, server to busy!"

For the client side all I had to do is set up an AJAX form submitting player information and move players when an event occurred. The 3D part is done entirely with Webkit 3D transforms. The only downside about using EventSource and -webkit-transform is that you can only play my game with a nightly of Webkit(if you’re unsure if you have one you don’t).

I would love to share my game, but my host refuses to run it. It’s using gzip compression so all events are queued up until the request times out. You can however throw from the widget in your cgi-bin and try it yourself.


“Hacking your own Twitter widget” for beginners

In the last few days I received 2 questions about how to get a Twitter widget on your site to display some data other than a user timeline. Since I love writing stuff I know that people like instead of what I think they will like, I’m going to write a short howto on getting your custom widget.

Getting your user timeline in a widget is easy; Go to Twitter and grab the code from this page:

If you look at the code you’ll see a link like this Go ahead and click it! It’s a JSON file with my latest tweets.

The cool part is that Twitter has a whole API of urls you can use to get your data. The default widget is using statuses/user_timeline. Note the XML structure at the bottom. We can replace this url with any public url that returns the same structure, that means statuses containing a user, not users containing a status.

Here is a list of a few API calls you could use:

An example using my favorites would look like:

<div id="twitter_div">
<h2>Twitter Updates</h2>
<ul id="twitter_update_list">
<a href="" id="twitter-link" style="display:block;text-align:right;">follow me on Twitter</a>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>

You can now paste this html code anywhere you want it to appear!


[updated] Mobile Safari better then Safari 4?

[update]: The latest Webkit does support 3D transitions! Examle

Screen shot 2009-10-11 at 3.20.07 PM

Today I was reading about developing web apps for my iPod touch. While reading this article about CSS animations I downloaded the example. To my surprise the example said it required iPhone simulator to run. Stubborn as I am I tried to open it with Safari 4… This gave the following result(try for yourself!):

Picture 11

Surprised as I was I opened it with the iPhone simulator, which yields this result:

Picture 13

It seems that the iPhone supports 3D and perspective css statements that Safari 4 does not support. Isn’t it strange that a mobile device can do things a full sized computer can’t(except for trowing with it while holding a drink in your other hand)? My first thought was that the Mobile Safari was released after Safari 4, so it might have a newer version of Webkit(that’s what powers Safari and Chrome). But the oposite is true, Safari 4 runs Webkit 530.18 and my iPod Touch runs  528.18. I’m to lazy to compile a nightly build of Webkit to see if it works, but until then I got no clue why Safari 4 can’t do this CSS magic.

Here are 2 screenshots of the browser string of both:

Picture 12IMG_0007


PyMouse 0.3

Hey there!

Some great stuff has happened to PyMouse since 0.2

  • It has been listed on Softpedia.
  • Mac Snow Leopard should be working.
  • Linux now works via xlib instead of the non-default xtest extension, which I admit was a burden.
  • Support for separate click and release, screen size and mouse position.
  • PyMouse is no longer an one-man-project, has made xlib possible and is now an official commiter 😀

So that means you should download the latest version and I should notify Softpedia that they’re lagging behind.


PyML(Python Markup Language) template engine

I know it’s been a while since my last post. I’ve been busy with setting up and pulling down I decided to go for another blog system), I’ve spend a good deal of time working on PyMouse and worked on some projects for myself and for clients.

I want to share one of those projects with you. I decided to make a CMS like Jekyll and Hyde(not the book!), since I liked neither of the previous systems. So like a lot of people who like reinventing wheels I started to look for a nice markup language for the user and a nice template language for the designer.

I choose for Markdown right away, end of story here…

Because of the little experience I have with Pylons I looked ad Genshi and Mako initially(can’t help the Chinese feeling these names give me). Personally the ugly tags in most template languages make me run away, so I threw Make out of the window, together with all the other ugly-tag-based languages.

I like the idea of working with valid XML attributes for templating, so I started of with Genshi initially, especially since speed isn’t a major point for a static blog!

Days later I came across this wiki page on the Python website:

Looking at Dirty I remembered my own attempts to write a template language implemented as Python objects(extending dict, for free functionality).

The problem with writing such a thing is described in the code below, I mailed the developer of Dirty about how he solved the problem — he didn’t.

>>> def div(*content, **attributes):
...     pass
>>> div("hello world!", id="test") # Doesn't html have the attributes first!? Ugly!
>>> def div(**attributes, *content): # Not allowed!
  File "", line 1
    def div(**attributes, *content):
SyntaxError: invalid syntax
>>> def div(atributes, *content):
...     pass
>>> div({'id':'test'}, "hello world!") # Even uglier!

But then I came up with this slightly brilliant solution:

When you define __call__ on a class it allows you to call the class, no big deal, eh? Wrong! It allows you to write this:

    head( # No atributes
        title("Hello world")
            "Hi", br(),
            "How are you?"
        img(src="test.img", alt="just a test") # No content
            *[li(c) for c in xrange(10)] # Now that is cool!

In short PyML is a pure Python combination of a string and a dict looking like html when written and printed!

You can do all sorts of things with this that you normally do with dictionaries, strings and lists, like sorting and filtering them, change a p into a div or getting/setting attributes later with square brackets. You could define functions to return a snippet or you could include templates into others. If you’re finished with them, just print the object!

Oh, about the speed? Quite good for my hobby project! (Unreliable micro benchmark ahead!)

Render time Engine
0.03160 PyML
0.50618 Genshi
0.01813 Mako

You can get it here if you want! Or wait for my complete CMS of course…

My blog has moved!

My blog has permanently moved to a self hosted Wordpress at

This blog will stay around for accidental search engine visitors.


This is me

Blog Stats

  • 22,921 hits