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


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”)

Get your APE up-to-date

After developing an APE application for quite some time now, it was time for me to install an APE server on the future production environment.

Since it created some hassle for me, not doing THIS every day, here’s a small log that might help you (or me some time later) to do the same, Upadate your APE server to the latest git version

I’m doing this on a debian 32 bit.

Since I am lazy, I will first install the deb package so I get all the nice entries in /etc/init.d, have the lib files placed in the correct directories…
And in a second step replace the ape version with the current one from github.

1: Install the “old” 1.0 package from the website

Download your package (like APE_Server-1.0.i386.deb) from to the machine.

Run dpkg -i APE_Server-1.0.i386.deb

In case this already fails, you might need to check if there are any libraries missing (see below)

2: Get the latest version

To get the latest version from github, I usually do

svn co
git clone

This will create a APE_Server.git directory in your current location. Now compile it:

3: Compile the new version

cd APE_Server.git

You can have different types of errors here, most of them related to the fact that you might not have all compilers or libraries installed. If this happens, try:

aptitude install make
aptitude install gcc
aptitude install g++
aptitude install python
aptitude install zip
aptitude install mysql

To be honest, I am not sure which libraries are required exactly – but this did the job for me. And if I could have installed the specific required libraries only I don’t care… as long as I get what I need.

After a finished compile (it can take a couple of seconds/minutes, warnings flying by…) you are ready to replace the existing ones.

4: Replace old files

Basically have to replace two files:

aped and

If running, stop your ape

/etc/init.d/ape-server stop

Copy the new files from your compile dir to their designated locations:

cp bin/aped /usr/bin/aped
cp modules/lib/ /usr/lib/ape/

(Paths may vary depending on system and linux distribution)

Restart your ape

/etc/init.d/ape-server start

If you connect to your ape server (e. g. with your browser, it should show you the version info with current build time

Corrections, additions, suggestions and comments welcome