How the heck do shims work in AMD/CommonJS?

What is a shim?

It is used to integrate “old” libraries, that use a global variable, to load it in requirejs/browserify environments.

You have your own or old library or plugin that is registering itself as

var MY_UTIL = function(){};
MY_UTIL.prototype.doSth = function(sth) {};

Now you want to require/define this in AMD/CommonJS env:

will fail.

That’s why you create a shim of this kind:

Whenever I require “myutil”, please provide me with the stuff that’s inside the MY_UTIL variable of the file src/js/external/myUtil.js

(yes, different cAseS are on purpose here to explain the difference of what refers to what)

paths: {
    "myutil": "src/js/external/myUtil.js"
shim: {
    "myutil": {
        exports: "MY_UTIL"

Again, this will give you the window.MY_UTIL variable of the file src/js/external/myUtil.js, but now you can referto it as "myutil"

Some quick notes on docker volumes

I’m a docker n00b. And working through the different manuals and tutorials, I came to take notes on these basic conclusions (might be obvious for the experienced whale rider)

If you start a container without volumes and change files, the changes will be kept within that container.
If you stop and restart, the changes will still be there
If you stop and rm and then start a new container of the image, the changes will be gone

If you add a “volume” to your conainer at a mountpoint, two things happen:
1) the initial data of the IMAGE at that path will be COPIED to the new volume in /var/lib/docker/volumes/*heregoestheverylogndockerid*/_data
2) the data you edit in that mountpoint will be visible/editable there
The volume itself will not have a name and will not automatically be shared with other containers of the same image, but you CAN reference it into another container by doing

docker run -it --name dataaccessor --volumes-from runningcontainerwithvolumes ubuntu bash

You’ll be in a new container, running a bash, and have the same mounts/mappings as the “runningcontainerwithvolumes” has. So you can edit the data.

This is basically the same concept as using “data volume containers”
This is not something special, but basically we are “abusing” a named, STOPPED container WITH volumes as a reference for mounting its volues into other containers

Clean up unused images

docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes --dry-run

Obviously, you can remove the --dry-run if it looks OK

Symfony2 and me – let’s be friends – Part 5

Today, I spent a lot of time figuring out, why my tables did not want to relate and adding a new entry resulted in errors with KEY CONSTRAINTS.

In the end, I believe it was because my tables where using differen MySQL DB enginges. THe existing tables where InnoDB, but the newly created fos_user table was using default MyISAM.
Manually switching the fos_user to InnoDB as well made it possible to have the relations being set up correctly.

Damn, took a while to figure it out. Ideally, the propel:reverse as well as the existing FOSBundle schema files would create/contain the corresponding entries so it would be more obvious… Pull Request anyone?

Anyway… after looking at my exisitng DB design again and again, I decided… NO, I’ll change everything. There is not much use in trying to adopt to the old design.
I’d rather redesign the tables and then, for the migration of the old data, create a script to bridge and convert.

So, I played with my schema.xml again and again and then migrated and now my tables are mostly empty, to start from scratch… let’s fill them next week

Symfony2 and me – let’s be friends – Part 4

Been some time… but I want to move on now.
Last thing I wanted to understand and solve is how to create relations between my existing tables (with relations) and the User table/class create by FOS User Bundle.
The whole “problem” is: I’m creating my own bundle where my app should be in, and I already recreated a propel schema from the existing db in that bundle.
FOSUserBundle has it’s own schema (and model classes) in it’s schema directory, and now the question: How to relate them so I can benefit from the generated code of propel.

Is it as simple as setting the relations “like always” only in two different files? Let’s see. In my case, I have “users” that can have “events”, so this would be a relation.
To make it a little more complex, I was not using “simple” ids, but “ident_ids”, which are a long random string that was stored in a cookie to provide an easy (not so secure) type of identification.

Means: My FOS-User needs an additional column, being the “ident_id” – and this should be relating to the ident_id of the events table…
Let’s give it a try and add a column to the FOS User schema.xml

<column name="ident_id" type="varchat" size="255" required="true" />

And now add the relation in my schema.xml of my bundle

<foreign-key foreignTable="fos_user" name="user_FK_1">
<reference local="ident_id" foreign="ident_id"/>
<index name="user_FI_1">
<index-column name="ident_id"/>

I decided I might have to use “fox-User” as the foreign table, not the PhpName user. We’ll see.

Well, my first php app/console propel:model:build failed, because I wrote “varchat” as column type, but I managed to solve this. And then the build succeeded. Did I get what I wanted?

When thinking about how to test it, I managed to realize that I don’t even HAVE a fos_user table in my DB yet, so it’s time for some propel migrations.

php app/console propel:migration:gen creates a migration file for me that reveals it is going to prepare a fos_user table (including an idend_id column), a fos_group and a fos_user_group table. All right, migrate!

So, I need some data and I register on my website using the /register path created by the FOSUserBundle. Then, with phpmyadmin, I wanted to relate this new user (by adding an ident_id) to my related table – and mysql responds with “key constraint failed”…. hmpf, somethings wrong. What? We’ll see next time

Symfony2 and me – let’s be friends – Part 3

So far, I have a base project with Propel as my ORM, connected to an exisitng DB, re-engineered the schema and could start to do something with it, now.

My next goal is to create a user authentication. After a lot of thoughts on if/yes/no I decided to use the FOSUserBundle – hoping it will provide some features I could use and still would integrate if I want to use OPTIONAL ALTERNATIVE Facebook and Twitter login…

Step 7: Add FOSUserBundle

I’m following the steps in the docs and add the line to composer and do an update. It suggests Doctrine, BTW, but I ignore that, thank you. But, for Propel, it says I need to move my schema.xml to app/Resources/FOSUserBundle/config/propel/schema.xml. Well, my schema already contains a User (which is unused atm) that contains an id – so it might work?!
Now did the configurationa steps of the doc (including installation of the typehintable behaviour) and reran my propel-build… SUCCESSFULLY, so I really could see a page on /app_dev.php/login. Impressive!

Well, no, it did not… First: I missed that I should copy the schema.xml of the bundle to “app/……”. Second: Looks like I got mislead with my expectations about schema.xml, where to put it, and where Models will be generated… Can I have FOSBundle generate it’s User class into my Bundles folders? How can I create relations between the User Class of FOSBundle and my app?

Questions to be answered later, I hope

Symfony2 and me – let’s be friends – Part 2

I have a running, blank symfony2 project now, with Propel instead of Doctrine – but no DB or bundle yet

Step 5: Gimme a bundle

I know there is this bundle generator, so let’s see it:
app/console generate:bundle
I chose my namespace and hit some [Return]s – and I’m good to go – WOW, yes it’s there! Not much in there, yet, but I’ll check later.

Step 6: The database

Nice so far! Now I’d like to connect to my exisitng database and use Propel’s magic database reverse-engineering
Thanks to composer I don’t have to deal with namespace and prefix configurations, so I can go to the db- connection settings directly
So I add the basic propel config with parameters ( to my app/config.yml; then I need to set the paramters in parameters.yml
No, how can I check if the connection works? Why not run the reverse-engineering process directly?
app/console propel:reverse “No generated files” Hmmm, my connection might not work – but there is no error 🙁
SO, I manually check the permissions again (quickly dumping an adminer into the web dir) and YES, there is a problem with the permissions. SO I fix this, then run app/console propel:reverse again – and I have a file!!!

Step 7: Adjust the db schema

For the time being, the schema looks quite ok, so I’ll just move it from the generated-schemas folder to a more appropriate destination, being the Resources/config folder of my bundle.
To run propel:build now, I only need to add a namespace=”my\bundle\namespace” to the database tag of the xml, and it generates my models!

Enough preparational stuff, more coding next days!

Symfony2 and me – let’s be friends – Part 1

My journey, starting a rewrite of an exisitng project from scratch with Symfony2

Step 1: Get the framework:

composer.phar create-project symfony/framework-standard-edition path
After giving my VM some more RAM (512MB wasn’t enough) it succeeded.

Step 2: Get rid of Doctrine and grab Propel

So I edit the composer.json file and delete the two doctrine lines (if someone other lib needs doctrine/common for annotations, they will solve the dependency, right?
Then add "propel/propel-bundle": "1.1.*" to the file instead, as stated on
Then I run “composer.phar update” and it updates my monolog, removes doctrine and installs propel, its bundle and phing.
After that, however, the symfony cache update fails – if course, I removed Doctrine which is configured somewhere in the the Kernel.

So I remove the Doctrine line from app/AppKernel.php and all doctrine stuff from app/config/config.yml – and HOORAY, my app/console is green again

Step 3: Does it work?

My webserver is already configured to check for an app.php in the web subfolder, so it works – but first I’ll add my IP to app_dev.php so I can see all the debug beauty of Symfony2
Checking the Debug toolbar I notice Propel is missing – of course, I need to add it to the kernel where I kicked out Doctrine
So I add new Propel\PropelBundle\PropelBundle(), to app/AppKernel.php where I commented Doctrine befor, and app/console knows some good old Propel commands now.

Step 4: Freeze this into git

This is a good start, so I want to get this status into git. I’m surprised to see that there IS already a lot of git-information in the directory, being the symfony2 history.
Quick fix, rm -rf .git and git init again, here I come. On the plus side, I already have a nice .gitignore 😀
git add .; git commit -m “Fresh start”

How to trace down a memory leak in APE with valgrind

How to trace down a memory leak in APE with valgrind


You already have a working/compiled APE server running and you still have the sources.

Rebuild (don’t use with the following steps

Enter your APE source code directory and then do

cd deps/js/src/
./configure --enable-debug --enable-valgrind
cd ../../../

Now copy your rebuilt libape and aped to it’s default locations (see

Now run your ape with valgrind as a wrapper (I prefer to cd to /etc/ape so I don’t have to specify the ape.conf)

valgrind --leak-check=full --log-file=/path/to/mem.log /usr/bin/aped

pkill aped

All leaks will be written to the log and can be analyzed

Note: valgrind is slowing down the application dramatically in terms of CPU

(Thanks to Anthony @paraboul, all the information is coming from a chat with him)

Symfony Day 2011 in Cologne

Symfony Day was amazing!!!

I love the community and it was great fun to see all the guys I already met during the last years and this year’s Symfony Live in Paris.

Again, a big THANK YOU to all organisers and of course all the people that make Symfony2 happen!

I just wanted to quickly paste my (sparse) notes that I took for myself – in case they help out someone else as well.

Basically, they are just some reminders for me of stuff that I wanted to check out.


  • Silex routes can use value() and assert() to be enhanced
  • Silex needs cookbook contributions
  • Silex can easily be functional tested (and require “” can have a return value!)


A shame, I never really looked at it before!? So take a closer look at and SPL in general

Links to follow/read

Pragmatic Programmer:


Check out – adminbundle

See, if it’s really that complicated as the talk made it seem

I did not note so much else, either because I already knew it, wanted to take a look at the presentations later, or player #sfdayjeopardy (thanks to Jeremy “Rick Astley” Mikola for that)

There’s one more thing

Actually, there were two things: Fabpot is a visionary! And his vision, of looking at Symfony2 not (only) as a framework but as a collection of several, individual and powerful components is great. MAYBE not for the developer looking for “a thing that does all the magik™” but for the more experienced one that can pick the best of a wide variety of components. Like some other PHP projects do now…

AND: Me, being a big fan of Propel, was happy to see all the momentum propulsion it got recently, including development support from inside sensio.

Hope to see you all again in June(?) in Paris and in November(?) in Berlin?


Quick post: I finished a bookmarklet, based on this years April Fool’s Day fun of

Klick this, it’s a JS call that will make some random letters of this website move.

Why I did it? Because it works!

You can save it as a bookmark(let) and use it on every webpage out there

1) Press the bookmark
2) Press multiple times for additional fun
3) Click one of the flying letters to make them go back where they belong.

Like it?

PS: “Fluchstaben” is a combination of the German words for “flying” and “letters” (“Flug” & “Buchstaben”)