Super Simple Git Guide

I loved the simplicity of the following Git online guide. I might use this website to present for future Git training sessions.


Posted in Git, Version Control Systems | Leave a comment

Git — How to merge a file from another branch

Everyone knows how to merge a branch using Git. Take it a step further and squash the commits upon merging.

The question was recently on how to cherry pick a file from another branch or a commit from another branch generic viagra australia reviews. This was a very interesting scenario that has a high chance of happening during software development. I wanted to find a easy way to accomplish this.

Here is the suggested method:

git checkout featureBranch filename


git checkout 9e402a458 filename

Both of these methods will fetch a snapshot of the file from the branch head or the commit.

Posted in Git | Leave a comment

Integrating Propel ORM with CakePHP

I have worked with Propel in the past and it has helped me generate the ORM layer for applications effortlessly. I know that CakePHP has its own ORM layer. However, upon evaluating my options, I have considered not to use the Cake ORM layer. Here is my justification.

I am migrating an existing application to CakePHP. Existing database tables and fields do not match CakePHP’s database conventions.  If I modify my tables and fields, all code accessing the database would need to be modified and re-tested. There is quite a bit of code in the current application’s libraries and cron jobs that I don’t have the luxury to re-write.  While I am considering moving the application to CakePHP, I plan on using Propel to provide the ORM layer. In the future, I could consider migrating to CakePHP ORM.

CakePHP does not support composite primary keys. Moreover, I like my model objects to have explicit getters and setters to facilitate my IDE’s code completion. Don’t get me wrong, I love associative arrays. However, not for defining my object models.

Here is how I integrated Propel 1.5.6 with CakePHP 1.3.8.

1) Create a folder called “propel” under “vendor”.

2) Place the propel runtime files under the newly created “propel” folder. As far as I can tell, the only folder needed from propel generator is the “lib” folder.

3) Place the generated Propel configuration files “conf.php” and “classmap-conf.php” under your Cake’s “config” folder.

4) If you wish to have database configuration live in one place, then perform the highlighted modifications below to propel’s “conf.php” file. That way you do not need to modify database settings in 2 places. Here is what my conf.php file looks like:

// This file generated by Propel 1.5.6 convert-conf target

include_once 'database.php';

$dbConfig = new DATABASE_CONFIG();

$conf = array (
 'datasources' =>
 array (
 'iv' =>
 array (
 'adapter' => 'mysql',
 'connection' =>
 array (
 'dsn' => 'mysql:host=localhost;dbname=' . $dbConfig->default['database'],
 'user' => $dbConfig->default['login'],
 'password' => $dbConfig->default['password'],
 'default' => 'iv',
 'generator_version' => '1.5.6',
$conf['classmap'] = include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'classmap-conf.php');
return $conf;

5) Now place all you generated model files under the “model” folder.

If you plan to use Cake model files along-side Propel model files, then I would suggest generating Propel models file with a package name specified. That way, propel model files will live in a separate folder inside the Cake model folder.

If the databases table name are not following cakePHP conventions, then specify the table with “useTable” as follows:

var $useTable = "mySpecialTable";

6) Lastly, load Propel in your cake’s bootstrap.php as follows:

// Include the main Propel script
App::import('Vendor', 'Propel', array('file' => 'propel' . DS . 'lib' . DS . 'Propel.php')); 

// Initialize Propel with the runtime configuration

// Add the generated 'classes' directory to the include path
set_include_path(ROOT . DS . APP_DIR . DS . "models" . DS . PATH_SEPARATOR . get_include_path());


Hope this helps anyone who is planning on using Propel with CakePHP.



Posted in CakePHP, Propel | Leave a comment

Enable Smarty Debug Console with CakePHP

Smarty is a great templating engine. I decided to use Smart with my CakePHP application.

To integrate Smarty with CakePHP, I following the instructions by tclineks: Then, I implemented the blog tutorial application using Smarty. Unfortunately, I found that working with Smarty without the Smarty Debug Console was inefficient. Here are the steps that I followed to enable Smarty Debug Console:

1. In the function display_debug($obj) of class  Smarty_Internal_Debug, modify

echo $_template->getRenderedTemplate();
$smarty->left_delimiter = $ldelim;
$smarty->right_delimiter = $rdelim;


//echo $_template->getRenderedTemplate();
$debugStuff = $_template->getRenderedTemplate();
$smarty->left_delimiter = $ldelim;
$smarty->right_delimiter = $rdelim;
return $debugStuff;

2. In SmartyView.php add the following method to the class SmartyView:

function renderLayout($content_for_layout, $layout = null) {
  $layoutRender = parent::renderLayout($content_for_layout, $layout);
  $smartyDebug = Smarty_Internal_Debug::display_debug($this->Smarty);
  return $layoutRender . $smartyDebug;

3. Make sure that you have debug.tpl in vendor/smarty folder.

4. In Smarty.class.php, change

public $debug_tpl = null;


public $debug_tpl = SMARTY_DIR;

5. Comment out the following line in smarty_internal_debug.php

//$_template->assign('assigned_vars', $_assigned_vars); 

The reason we need to comment out the above line is because it will generate too many nested variables. Smarty will report an error and stop rendering. If someone knows a way to overcome this problem, kindly share that with me. My quick resolution for the time being is to disable this line.

6. In SmartyView contructor, add the following line:

$this->Smarty->debugging  = true;

Now, your Smarty Debug Console will show up.

Enjoy Smarty with CakePHP!

Smarty Debug Console


Posted in CakePHP, Debugging, Smarty Templating Engine | Leave a comment

Ajaxifying Existing Web Applications and Portals

JavaOne — Session ID: TS-4645

Track: Services Web 2.0 Scheduling Track; Services: Web 2.0, Next Generation Web, and Cloud Services Platform.

This talk was presented at JavaOne on June 2nd, 2009 in room E307 of the Mascone Center, San Francisco, CA.

Estimated number of attendees was about 500+.


Rich Internet applications offer richer user experiences than non-RIA applications and are considered for many new projects, but existing non-RIA applications do not get much attention. Technically, these applications’ back ends were designed to serve HTML content. Business users often do not anticipate the benefits of improving an interface that already delivers some business value. However, Ajaxifying existing Web applications to deliver greater value can be straightforward.

Almost all business applications must report tabular data. This session, for Web developers, describes how to incorporate ExtJS’s rich data grids into these applications to present tabular data, with sorting and paging capabilities find. It covers the design and implementation of Java™ technology-based server-side applications to provide data payload, sorting, and pagination for the rich data grid.

Portals must enforce security on all portlet-based Ajax calls. The session presents an appropriate design approach to facilitate the easy addition of Ajax handlers and to provide portlet-level security on Ajax calls. The Ajax handlers will use the Spring MVC framework.

Attendees will learn how to

• Incorporate ExtJS’s rich data grids into Web applications
• Design and implement Java technology-based server-side applications to provide data payload, sorting, and pagination
• Facilitate the addition of Ajax handlers and provide portlet-level security on Ajax calls

Presentation Slides

For the following projects, I have included the WAR file. Just drop the WAR under Tomcat or your preferred servlet engine.

Spring JSON Plugin project using ExtJS Grids

(If you wish to run the above project, please get the MySQL script from here.)

Struts2 JSON Plugin project

Jersey Framework Sample project

Please let me know if you run into any issues or need assistance with these demo projects.

Posted in Ajax, ExtJS, Jersey Framework, linkedin, MVC, Spring MVC, Struts | Tagged , , , , , , | Leave a comment