Gitweb configuration, the easy way

Ok if you have juste one git repository, git instaweb is for you. This command automatically generate the config to connect with a webserver installed on your server. I recommand you to try, it’s impressive as it’s simple. For me the best config is :

git instaweb -d webrick

Now if you have several git projects as I am, you want to use gitweb. In fact instaweb uses the gitweb script but configured for one specific repository. The script is in .git/gitweb/gitweb.cgi .

On Ubuntu, install the script with the command:

apt-get install gitweb

I’m going to assume you have apache2 and mod_perl installed. So in the config file


add this config at the end of the VirtualHost block:

ScriptAlias /git “/usr/lib/cgi-bin/gitweb.cgi”
<Directory “/home/git/”>
Options Indexes FollowSymLinks ExecCGI
Order allow,deny
Allow from all

Now you just have to configure gitweb by setting the directory containing your git projects in the file:


Finally, restart apache and you should be able to browse your projects on this url:


XML to NSDictionary Converter

I found recently a nice lib easily converting XML to NSDictionary. The code is now on GitHub.

Here are the key ideas:

  1. XML elements map to key names in the dictionary
  2. Each element corresponds to a child dictionary
  3. Attribute key-value pairs are added to the element’s child dictionary
  4. Strings from text nodes are assigned to the child dictionary’s “text” key
  5. If an element name is encountered multiple times, the value of the element is set to an array of children dictionaries

For a more detailed presentation.

A detailed example:

The XML to parse:

//    <items>
//        <item id=”0001″ type=”donut”>
//            <name>Cake</name>
//            <ppu>0.55</ppu>
//            <batters>
//                <batter id=”1001″>Regular</batter>
//                <batter id=”1002″>Chocolate</batter>
//                <batter id=”1003″>Blueberry</batter>
//            </batters>
//            <topping id=”5001″>None</topping>
//            <topping id=”5002″>Glazed</topping>
//            <topping id=”5005″>Sugar</topping>
//        </item>
//    </items>

The Code:

NSString *testXMLString = @”<items><item id=\”0001\” type=\”donut\”><name>Cake</name><ppu>0.55</ppu><batters><batter id=\”1001\”>Regular</batter><batter id=\”1002\”>Chocolate</batter><batter id=\”1003\”>Blueberry</batter></batters><topping id=\”5001\”>None</topping><topping id=\”5002\”>Glazed</topping><topping id=\”5005\”>Sugar</topping></item></items>”;

// Parse the XML into a dictionary
NSError *parseError = nil;
NSDictionary *xmlDictionary = [XMLReader dictionaryForXMLString:testXMLString error:&parseError];

// Print the dictionary
NSLog(@”%@”, xmlDictionary);

The result

// xmlDictionary = {
//    items = {
//        item = {
//            id = 0001;
//            type = donut;
//            name = {
//                text = Cake;
//            };
//            ppu = {
//                text = 0.55;
//            };
//            batters = {
//                batter = (
//                    {
//                        id = 1001;
//                        text = Regular;
//                    },
//                    {
//                        id = 1002;
//                        text = Chocolate;
//                    },
//                    {
//                        id = 1003;
//                        text = Blueberry;
//                    }
//                );
//            };
//            topping = (
//                {
//                    id = 5001;
//                    text = None;
//                },
//                {
//                    id = 5002;
//                    text = Glazed;
//                },
//                {
//                    id = 5005;
//                    text = Sugar;
//                }
//            );
//        };
//     };
// }

Install Rmagick on Mac OS X

I like to use the standard ruby tools when developing with Rails. So if I have a gem to install, I won’t use ‘apt-get install’ or ‘port install’, I will use ‘gem install’. To install Rmagick the command is:

sudo  gem install rmagick

And the result is :

Building native extensions.  This could take a while…
ERROR:  Error installing rmagick:
ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb
checking for Ruby version >= 1.8.5… yes
checking for gcc… yes
checking for Magick-config… no
Can’t install RMagick 2.13.1. Can’t find Magick-config in /usr/local/bin/:/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin/:/usr/bin:/bin:/usr/sbin:/sbin

*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:

Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/rmagick-2.13.1 for inspection.
Results logged to /usr/local/lib/ruby/gems/1.8/gems/rmagick-2.13.1/ext/RMagick/gem_make.out

It seems there are dependencies not installed. To solve this problem, I will use macport and install the necesary libs with the command:

sudo port install tiff -macosx imagemagick +q8 +gs +wmf

After a bunch of compilation, I relaunch my gem command :

sudo gem install rmagick

And “Voila!” it works. Now have fun with RMagick functionalities.

Killer tool to develop on iPhone: ack-grep

When developing for iPhone, the IDE coming in mind is XCode and it’s a good thing cause XCode is a good piece of software. I use XCode everyday but I never found the search functionality good enough. That’s why I switched to ack-grep. It’s a little perl script way faster than grep or any other search functionality. And the result presentation is clear and efficient.

Recently, I had to work on an complex iPhone application developed by another company. ack-grep helped me a lot to dig in the hairy code. Since I’m using this tool I can’t work without it.

The installation is easy, it’s worth a try.

iPhone essential performance tools list

Once your iPhone application is done, it is good to check the possible memory leaks who could cause your application to crash. So here is a the list:

  • Leaks application that can be found in Xcode: run -> Start with Performance Tool -> Leaks
  • Apple’s Instruments utility that can be found in /Developer/Applications/Performance Tools
  • Clang, an static code analyzer to find bugs in objective-c code: