Ubuntu Hour in Bangalore

Woo! After a while, the Ubuntu loco community is awakening in Bangalore again. I had announced a meet up on the mailing list a while back. I had my fingers crossed as to how many would turn up and how it would be. Most people assured me if there are 2 people and the other person isn’t your imaginary friend, its a success!

I’m glad to report that we ended up with 7 people coming in. It started out a bit slow with just me sitting alone in Cafe Coffee Day on Richmond Road. To be a little more noticeable I opened up the laptop and sat in such a way I could see everyone who walked in. Anyone who looked lost was definitely looking for the Ubuntu Hour (note to self: Sticker on laptop sounds like a good idea now).

Ganesh walked in first followed later by Harish and Arjun almost at the same time. We sat chatting for some time until I saw noticed another guy looking lost and Manish joined the party. Later on Venkatesh also joined us giving us more life!

We talked for quite a bit about what we do for a living and what we do for the free software community. All of the people seem to be contributing in one way or the other and it was fun to hear about what others do. We packed up at around 5 and walked out to run into a DD, Ritesh, who was planning on making it but got late.

And we ended up talking for some more time outside the coffe shop. Meeting geeks is fun! We’ve plan to meet up every on the last Saturday of every month with announces sent to ubuntu-in and ilug bangalore list. As soon as the venue for the next one’s confirmed I’ll blog and tweet about it! Thank you all for coming 🙂 The pictures are all on my flickr.

Web-based viewer for git

I’ve been looking for a simple to set up viewer for git that would list out all the git repositories that I have on my git server. It took a bit of a search and I finally discovered viewgit. So far, I’ve found it pretty nice. Setting up viewgit is very simple.

Download the tarball from sourceforge. Extract it to your htdocs or www folder. Make a copy of example-localconfig.php and rename it as localconfig.php. Comment out the line$conf['projects'] and uncomment $conf['projects_glob'] = array ('/path/to/repo/);. If like me, you store all your git repos in one folder, this is the best viewer for the amount of work I’ve had to do. Maybe I should write about how to store git repos in one folder. A story for tomorrow!

Automatic database backup

I use git extensively for version control. Its nice to use git since it backs up the code, but the database still remains unversioned. Well, thankfully, XAMPP has a script that does a database dump. So, I wrote a script to do the dump and then commit it to git.

Step 1

Create a directory in the home directory for the database dump

$ mkdir projectname-database $ cd projectname-database 

Step 2

Initialize git in the directory

$ git init 

Step 3

Do a database dump for the initial commit

$ /opt/lampp/bin/mysqldump -u root database-name > database.sql 

Step 4

Commit the database file

$ git add . $ git commit -am 'Initial database commit' 

Step 5

Now we’ll write a script to do the database dump and add commits. Open your favorite text editor and write the following script. Save the file as probably ‘database-project’ in your home folder

#!/bin/bash /opt/lampp/bin/mysqldump -u root database-name > /home/username/projectname-database/database.sql cd /home/username/projectname-database/ git commit -am 'Database dump at `date`' 

Save the script so that you can run it via a cron.

Step 6

Give the script executable permissions.

chmod a+x /home/username/database-project 

Step 7

Open crontab with the following command

$ crontab -e 

Step 8

Add the following line

00,30 * * * * /home/username/database-project 

This cron will run the script every 30 minutes.

Basically what happens here is the database dump will be taken every 30 minutes and the change will be committed to a git repository allowing you to keep track of the overwriting. I’ve found it quite useful and I hope you will too.

Baking on Ubuntu while using xampp

So, I’m a web developer working on Ubuntu. Since I don’t want to get into complications like pinning to have earlier versions of PHP (useful when developing on Drupal), I use XAMPP. Its a bit of a work to get php ready to bake while using XAMPP on Ubuntu. These instructions are probably generic to any bash shell, but tested and working on Ubuntu. Also note, I assume you install XAMPP in the expected directory at /opt/lampp.

  1. Add an alias for php in .bashrc. Open the ~/.bashrc file and add the following line:

     alias php='/opt/lampp/bin/php' 
  2. When running the bake script, run it as follows:

     php cake.php bake 

jQueryObject

CakePHP moved from Javascript helper to a Js helper and they decided to add support Prototype/Scriptaculous, Mootools/Mootools-more, and jQuery/jQuery UI.  Out of the 3, jQuery remains the one I like most so far. I’m not an expert in it (yet :p) but its pretty nifty to work with. Sometimes when working with one or more libraries, the jQueryObject which is $ by default tends to clash with other libraries. CakePHP of course has code to deal with this, only is not publicly mentioned how to do it. I spent around 5 hours to discover how, and here it goes drum roll

    $js->JqueryEngine->jQueryObject = '$j';     print $html->scriptBlock('var $j = jQuery.noConflict();',         array('inline' => false));

When you look at the code using firebug, you would now see the jQueryObject changed to $j. I’ve suggested a section to the book for this and I’ve also modified some of the documents for stuff that I found helpful.