Blog and portfolio of Patrick Zahnd

Gitflow

gitflow

As I am personally using Gitflow and I found the graphics by nvie (http://nvie.com/posts/a-successful-git-branching-model/) very useful, I created an own version of them. Feel free to use them.

the big picture

feature branches

Gitflow feature branches

master and develop

gitflow main branches

hotfix branches

scrum sprint

git (vs. svn) data transport commands

For some git presentations I wanted to print an overview of the git (and svn) data transport commands. I found several nice visualisations in the web, but none with a high resolution. This is why I took some time to create an own version of it. Feel free to use it yourself. Also I am happy about feedbacks.

svn data transport commands:

svn data transport commands

git data transport commands:

git data transport commands

other resources

An interactive git cheat sheet: ndpsoftware.com/git-cheatsheet.html

Learn git by github: try.github.io

PHP OpenID library

In the last days I played around with SSO (Single Sign On) and the Google OpenID provider. Therefore I used the LightOpenID library found on gitorious (https://gitorious.org/lightopenid).

What I found after some hours was that my requirements were bigger than what the library was made for. I then decided to fork the library (https://github.com/paza/LightOpenID) and started restructuring it a bit. This is what is new:

Changes

Composer support

You can now use Composer to add the repository. The library is automatically added to the autoloader.

{
    "repositories": [
        {
            "type": "vcs",
            "url":  "https://github.com/paza/LightOpenID"
        }
    ],
    "require": {
        "paza/lightopenid": "*"
    }
}

Removed logic from __construct

I removed logic from the class __construct method. This was mainly about gaining flexibility and to be able to pass GET/POST parameters from outside.

Further changes

  • Added a namespace to the library
  • Public variables removed
  • Added public getter and setter methods
  • Removed the magic methods __get and __set
  • Updated and moved examples

Usage example

Get the Openid URL

//
// Example path http://www.patrickzahnd.ch/login
// 

$openid = new Paza\OpenID\LightOpenID('www.patrickzahnd.ch');

$authUrl = $openid
    ->setReturnUrl('/openidcallback')
    ->setIdentity('https://www.google.com/accounts/o8/id')
    ->setRequired(array('contact/email'))
    ->setOptional(array('namePerson', 'namePerson/friendly'))
    ->authUrl();

echo '<a href="' . $authUrl . '">Login with google</a>';

Handle the Openid provider login response

//
// Example path http://www.patrickzahnd.ch/openidcallback
// 

$openid = new Paza\OpenID\LightOpenID('www.patrickzahnd.ch');

$authUrl = $openid
    ->setReturnUrl('/openidcallback')
    ->setIdentity('https://www.google.com/accounts/o8/id');

$openid->setData($_GET);

// Check if it is in the response state (response received from the OpenID provider)
if (!$openid->isResponseState()) {
    throw new Exception('The response set is not a correct Openid response');
}

// Check if the user has cancelled the OpenID Auth
if ($openid->checkUserCancelled()) {
    throw new Exception('The user cancelled the request');
}

// Validate the response
if ($openid->validate()) {
    // Logged in

    // Get the unique user ID
    $id = $openid->getClaimedId();

    // Get User attributes
    $attributes = $openid->getAttributes();

    echo sprintf('<b>User ID</b>: %s', $id);
    echo '<br /><b>Attributes:</b></a>';
    echo '<pre>';
    print_r($attributes);
    echo '</pre>';
} else {
    throw new Exception('The request could not be validated');
}

Conclusion

With the updates I did it is now easy to use the library with frameworks like Symfony2 for example. Mainly the change to pass the GET/POST variables from outside makes the library much more flexible.

A more detailed description and usage examples you can find on Github (https://github.com/paza/LightOpenID).

ZiviSuche.ch

Around three months ago I released my private project ZiviSuche.ch. The goal of the website is simplifying the civil service search for the persons doing community service in lieu of the army in Switzerland.

Swiss community service

In Switzerland every year several thousand men apply for doing community service, which most of are approved. Currently there are more than 23’000 active persons doing community service.

The civil service lasts 1.5 times longer than the military service, which makes a total of around 1.5 years. A normal service takes 26 days and everyone has to perform a so called long service of 180 days.

On the other hand, there are around 2’500 service hosts which provide around 8’000 places of employment every year.

Statistics: http://www.zivi.admin.ch/…/index.html

The official platform

The official platform EIS (Einsatzinformationssystem) contains a search, extended search and a detail page for each position. The new EIS introduced in August 2012 consists of a redesign and some new features, like the collapsed search list which allows to view some additional informations for each entry by toggling.

Official EIS: https://www.eis.zivi.admin.ch

Why create an alternative search?

After talking to others performing community service and after my own experience with the current search, I had a list with points which could be improved. To give you an overview, I list some of the main ideas:

  • Having fewer outdated entries
  • Simplifying the search form
  • Possibility to mark interesting entries
  • Reminder for new matching search entries

After checking the legal requirements within my topic IT Law at university, I started collecting the data and creating the page, which took me several months to finish.

The result

Today, three months after releasing the page, it has an average of hundred people browsing the entries every day and several members getting a weekly or monthly reminder, containing new interesting results. Also I got some feedback, which I try to implement most of.

For the future I hope to make it easier to find a matching service and also enjoy having an alternative search for myself.

More feedback – of course – is welcomed warmly :)