I finished the “M101P: MongoDB for Developers” course from MongoDB University with a 100% score.

Posted on by mrgierer | Leave a comment

L’Hymne à l’amour

Posted in Misc | Tagged | Leave a comment

What A Wonderful World – Trombone Arrangement

Posted in Misc | Tagged | Leave a comment

Bootstrap themed forms with Silex – UPDATE

In a side-project using Silex I wanted to have forms being styled with Bootstrap. I did not want to write the theming code myself. Since I couldn’t find a solution for Silex itself I thought about re-using a Symfony solution.

Here is what I am using now:

First I added the Braincrafted/BootstrapBundle to the composer.json:

"braincrafted/bootstrap-bundle": "2.0.0"

In my apps bootstrap.php I added a path to the Twig configuration and registered a Twig extension:

$app->register(new Silex\Provider\TwigServiceProvider(), array(
    'twig.path' => array(
        __DIR__.'/views',
        __DIR__.'/../vendor/braincrafted/bootstrap-bundle/Braincrafted/Bundle/BootstrapBundle/Resources/views/Form'
    )    
));
...
$app['twig'] = $app->share($app->extend('twig', function($twig) {
    $twig->addExtension(new \Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapIconExtension);
    $twig->addExtension(new \Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapLabelExtension);
    $twig->addExtension(new \Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapBadgeExtension);
    $twig->addExtension(new \Braincrafted\Bundle\BootstrapBundle\Twig\BootstrapFormExtension);
    return $twig;
}));

In the forms template the theme is registered:

{% form_theme form 'bootstrap.html.twig' %}

From now on the form on the page is rendered nicely in Bootstrap-style.

UPDATE (24.4.2014): As mentioned in the comments – with the latest updates – now some more extensions are needed. The code example has been updated (hat tip gcrico).

Posted in PHP | Tagged , , | 2 Comments

Twitter Bootstrap – no more excuses

Twitter Bootstrap is a very well structured set of CSS classes paired with some JavaScript components which makes it easy to create good looking websites. By default it has a Twitteresque look but it can be customized very extensively.

Besides all that, it is very well documented and brings instant results. I just reworked a small internal web project which was put together with some years ago with totally no UI love and therefore had only minimal CSS applied to it. To be honest – not something to be proud of looking at it from a design perspective.

After an evening of removing the old CSS and bringing in Twitter Bootstrap the application is not to be recognized. It looks like a modern web application even with some responsive design elements which makes it good looking and – even better – usable on mobile devices.

So far I am really exited about the results and plan to use it in more projects. With Twitter Bootstrap even engineers have no excuse why a web application should not have at least a minimum of visual appeal.

Posted in Misc | Tagged , , | Leave a comment

phing: Publish PEAR package to channel

Publishing a PEAR package via a PEAR channel is normally done by uploading the package in the channels admin interface.
While not a being very complicated task it asks for automation when releasing regularly.

So I created a small phing task which uploads a package to a channel server:

   <target name="deploy" description="Upload package to channel server">
    <input propertyname="version" defaultValue="" promptChar="?">Version</input>
    <input propertyname="username" defaultValue="" promptChar="?">Channel-Benutzer</input>
    <input propertyname="password" defaultValue="" promptChar="?">Channel-Passwort</input>
    <property name="channel">http://my-channel-server.com/pearfrontend.php</property>
    <property name="uploadFile">_build/PACKAGENAME-${version}.tgz</property>
    <exec command="curl -d "login=Submit&password=${password}&user=${username}" --cookie-jar /tmp/deployCookie -s ${channel} > /dev/null"></exec>
    <exec command="curl -F release=@${uploadFile} -F submitted=1 -F f=0 -F filename=${uploadFile} --cookie /tmp/deployCookie ${channel} > /tmp/deployCheck"></exec>  
  </target>

I realize that this task lacks any error handling, so you might want to check your channel server afterwards. However so far this worked very well for me.

Pro tip: This is especially nice at the end of a Jenkins Build Pipeline.

Posted in PHP | Tagged , | Leave a comment

XDebug with Zend Server CE on MacOS X Snow Leopard

After (finally) upgrading my Mac to Snow Leopard (a little late – I know) the xdebug module stopped working.
I got “Failed loading /usr/local/zend/lib/php_extensions/xdebug.so: (null)” when launching php in Terminal (e.g. with running phpunit).

Reinstalling xdebug did not help and I eventually found the solution in the Zend forums.

Here are the steps I used to get the current xDebug version (2.1.1) installed:

sudo -s 
ftp http://pecl.php.net/get/xdebug-2.1.1.tgz
tar zxvf xdebug-2.1.1.tgz
cd xdebug-2.1.1
export CFLAGS="-arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp" 
export CCFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" 
export CXXFLAGS="-arch i386 -arch x86_64 -g -Os -pipe" 
export LDFLAGS="-arch i386 -arch x86_64 -bind_at_load"
/usr/local/zend/bin/phpize
./configure --with-php-config=/usr/local/zend/bin/php-config
make
cp modules/xdebug.so /usr/local/zend/lib/php_extensions/xdebug.so
Posted in PHP | Tagged , , , | Leave a comment

Interesting article on references in PHP

Johannes Schlüters wrote a very interesting article on references in PHP. Already its title “Do not use PHP references” hints on its main conclusion:

References in PHP are bad. Do not use them. They hurt and will just mess with things and do not expect to be able to outsmart the engine with references!

Posted in PHP | Tagged | Leave a comment

Ubuntu: Diff tool with file browser integration

Having installed a new Ubuntu VM (for testing purposes) I was looking for visual diff tool with nice UI integration.
Windows users: think of WinMerge being launched by selecting two files in Explorer and compare them from the context menu.

This is what I came up with:
Install Meld – a visual diff tool:

sudo apt-get install meld

To be able to launch Meld from the file browsers context menu install “Nautilus Actions” (Nautilus is the name of the Ubuntu file browser). Nautilus Actions is an extension to add custom entries to the context menu.
To install it type:

sudo apt-get install nautilus-actions

Launch it from System -> Settings -> Nautilus Actions
and add a new action with these settings:

  1. Label: Compare
  2. Icon: /usr/share/pixmaps/meld.png
  3. Path: /usr/bin/meld
  4. Parameters: %M
  5. Conditions tab: Group “Appears if selection contains” select “Both”
  6. check “Appears if selection has multiple files or folders”

Restart the file browser:

nautilus -q

Then you can select two files, right click, and select “Compare” and Meld will show you the differences between the selected files.

Posted in Misc | Tagged , , | 3 Comments

Interruptions

Throughout the last weeks and month I made experiences by myself to that subject. Lately I found two very nice statements about this topic:

First an article title “The Number One Developer Productivity Tool” (via @weierohpinney) which refers to an article by Joel Spolsky.

And secondly David Heinemeier Hansson sums it up in my favorite-tweet-of-the-month:

How many people have you interrupted today by IM or phone or in-person where an email would have done just fine?

Posted in Misc, Quotes | Leave a comment