Monday, October 3, 2011

Wordpress, Git and Switching between Environments

As a developer we always want to make sure that we can freely move between local development environment and the production environment. And when its time to move the files between the environments, it should be a very painless and streamlined process.

While working on Wordpress, Initially, I had to struggle to maintain two distinct environments. When ever I used to move the files over, I used to encounter broken links,
missing images and host of other issues. Till the time I mastered the art.

I am attempting to write the best practices I learnt and if you find any I would appreciate if you can comment on it.

Version Control
  • I used GIT Version control to save my regular checkins. It works like a charm
  • I also checked in the .sql file regularly to Github, backup of my local database.

First Release : Once site was Production
Now, its time to Updated Pages, Switching from Production to Dev Environment
  • Created a new local database and Imported the latest SQL file. (Make sure you checkin the latest snapshot from Production)
  • I synced up the changes from GitHub
  • Update the Database and Permalinks (as described above)
I have found this as simplest way to move between servers seamlessly.

Readers, if you finding anything interesting, do let me know too

Happy Developing!!

Thursday, March 10, 2011

Create a Git Branch at a commit, Cherry-pick a commit

Git is very powerful and flexible. I simple love GIT

To create a new branch at a specific commit, is very simple

step1 : find out the Commit Point

$git log –oneline –decorate –graph

* 5da8d22 (HEAD, origin/master, origin/HEAD, master) adding the amazonfps versio
* 249e8f2 Remote the views and controllers files from plugin, first official rel
* 1859484 add some comments
* 51510a3 Moved the .git directory to inside from outside The plugin is now work
* ef5f694 initial checkin for amazonfps plugin
* 316cc21 removed mail.jar and mail jndi for morp support
* a7c2694 changed grailsplugin to comment jndimailsession, which was causing pro
* 9e9aab2 add the morph deploy jars
* b5c1b31 initial checkin
* 0ad0cd6 first commit

Step2 : BranchOut

git branch devbranch ef5f694

Will create a gitbranch at that commit point

Wednesday, March 9, 2011

Integrate Captivate Files With Adobe Flex

Adobe Flex came to rescue when we hit the wall with Captivate, need some customizations in the Captivate UI.  Had to struggle to find a good documentation on access Captivate Variables and Events in Adobe Flex

Following are the Steps

Step1 : Setup

Download and Copy the classes Actionscript classes to your project..events and helper classes from http://code.google.com/p/widgetfactory/downloads/list

Create package (com.widgetfactory) and copy the events and helpers to your project

Step 2: Access Captivate Variables and Events

Create a Flex Project and add Image comp for Captivate File,Captivate  Access Events and variables

   1: <s:Application>
   2: <fx:Script>
   3:     <![CDATA[
   4:         import com.widgetfactory.events.QuestionWidgetEvent;
   5:         import com.widgetfactory.events.WidgetEvent;
   6:         import com.widgetfactory.helpers.CaptivateEventsToWidgetEvents;
   7:   
   8:         private function loadCaptivateFile( url:String):void {
   9:               if( !contentLoader.hasEventListener( Event.COMPLETE ) ) {
  10:                         contentLoader.addEventListener( Event.COMPLETE, handleCaptivateLoadComplete );
  11:                }
  12:               contentLoader.load( url ); //url points to the swf file
  13:         }
  14:  
  15:      private function handleCaptivateLoadComplete( event:Event = null ):void {
  16:             var captivateMovie:MovieClip = MovieClip(contentLoader.content);            
  17:             CaptivateEventsToWidgetEvents.registerEventsWithWidgetEvent( this, captivateMovie);
  18: //Access captivate events
  19:             if( !captivateMovie.hasEventListener( WidgetEvent.ENTER_MOVIE ) ) {
  20:                 captivateMovie.addEventListener( WidgetEvent.ENTER_MOVIE, movieStartedEvent, false, 0, true );
  21:             }
  22:      }
  23:  
  24:     private function movieStartedEvent(event:WidgetEvent):void{
  25:           var captivateMovie:MovieClip = MovieClip(contentLoader.content);
  26:           captivateMovie.cpCmndMute = 1            //acccess cpativate variables
  27:     }
  28:  
  29: <s:Application>

Gotchas


Captivate variables take a little time 10-20ms to take into effect, so if you set it and right away try to access it, you will still see the old value.


Ideally, I feel, if the project is getting too complex, it better to your Flex directly and create a database centric application instead of Using Captivate and doing workarounds. But again this is case by case.


Happy Flexing!!