22 October 2012

Cloning a specific GIT branch from a repository


Step 1 : Clone the master branch
git clone <repo master>
Step 2 : Clone the specific GIT branch
git fetch origin +branchname:branchname
Step 3 : Switch to the branch
git checkout branchname
Step 4 : Check the file difference between the master and the branch 
git diff --name-status master..sibos

28 September 2012

Migrating code from SVN to GIT

Install git-svn on ubuntu or linux

Simple command to begin with
$ git-svn clone <svn repo link> --no-metadata -s my_project

You need to do a bit of post-import cleanup. For one thing, you should clean up the weird references that git svn set up. First you’ll move the tags so they’re actual tags rather than strange remote branches, and then you’ll move the rest of the branches so they’re local.

To move the tags to be proper Git tags, run

$ cp -Rf .git/refs/remotes/tags/* .git/refs/tags/
$ rm -Rf .git/refs/remotes/tags

This takes the references that were remote branches that started with tag/ and makes them real (lightweight) tags.

Next, move the rest of the references under refs/remotes to be local branches:

$ cp -Rf .git/refs/remotes/* .git/refs/heads/
$ rm -Rf .git/refs/remotes

Now all the old branches are real Git branches and all the old tags are real Git tags. The last thing to do is add your new Git server as a remote and push to it. Here is an example of adding your server as a remote:

$ git remote add origin git@my-git-server:myrepository.git

Because you want all your branches and tags to go up, you can now run this:

$ git push origin --all

11 August 2012

Fix Readline error Ubuntu

Fix readline error with Ruby

sudo apt-get install libreadline-dev

cd ~/.rvm/src/ruby-1.8.7-p249/ext/readline

ruby extconf.rb && make && make install


Thanks

10 August 2012

Capistrano + GIT : Too many arguments while deployment

Issue : shell command failed with return code 33024

It's a ruby + git clone + windows issue.

If I chain commands with && while calling system(cmd) from ruby, chaining "git clone" with other commands is not fine. Git clone perceives the chained commands as its own continuation, i.e. as a destination directory, unless I run it from the command line.
As I couldn't find any references or solutions to this problem on the internet, I put a hack to capistrano code, so "git clone" is executed separately. 

In <ruby directory>\lib\ruby\gems\1.8\gems\capistrano-2.5.18\lib\capistrano\recipes\deploy\strategy\base.rb after the line 53 (cmd = cmd.split...)
add the following lines:
if cmd =~ /\s\&\&\s/ && cmd =~ /^git\s+clone/
   cmd1, cmd = cmd.split(" && ", 2)
    super(cmd1)
end

it checks if it's a chained command and the first command is "git clone", and if such it executes it separately. It may not work for all possible cases.

Also you can try using ubuntu from your local.

 

09 August 2012

Installing RMagick with Imagemagic on Windows 7/Vista


2. Install Imagemagick
Use the 32 bit version, 64bit is not working.
http://www.imagemagick.org/download/binaries/ImageMagick-6.7.6-1-Q16-windows-dll.exe (2012-03-22)
Install dev headers (Check!)
Install into C:\opt\

3. Restart the console/cmd prompt/IDE/.. or just restart windows to make Imagemagick commands available

4. Install rmagick
gem install rmagick --platform=ruby -- --with-opt-lib=C:/opt/ImageMagick-6.7.6-Q16/lib --with-opt-include=c:/opt/ImageMagick-6.7.6-Q16/include

13 June 2012

Installing Ruby on Mac OS

STEP 1 Installing XCode


Please install XCode + Developer Tools from the App Center.
XCode is needed to install the Developer tools used in compilation of the Ruby packages for installation on the system.

STEP 2 Install RVM


Install RVM using the command
  • curl -L get.rvm.io | bash -s stable
This will install RVM on your system.
Please close and open the terminal again to load RVM.
To verify the RVM installation , open Terminal and type
  • rvm requirements
This will show a help doc.

Step 3 Installing required RVM packages before installing Ruby


Open Terminal and run the below mentioned commands one after the another
  • rvm pkg install zlib
  • rvm pkg install openssl
  • rvm pkg install iconv
  • rvm pkg install readline
  • rvm pkg install autoconf

Step 4 Installing Ruby


Open the Terminal and type the following command
  • rvm install 1.8.7 --with-gcc=clang
Here 1.8.7 reflects the Ruby version 1.8.7 and the latest patch, so to install any specific version or path you specify it by altering the above mentioned command eg.
  • rvm install 1.8.7-p334 --with-gcc=clang
  • rvm install 1.9.3 -C --with-gcc=clang

Step 5 Verify the installation


Open a new Terminal window and type
  • rvm list This will display the list of the different rubies installed on the system.
    To use a specific Ruby version use the following command
  • rvm use 1.8.7
  • rvm use 1.8.7-p334
  • rvm use 1.9.3 To make a Ruby version default for the system use the command
  • rvm alias create default 1.8.7
  • rvm alias create default 1.8.7-p334
  • rvm alias create default 1.9.3
This Ruby version will be the default version of Ruby on the system , to change to other versions of Ruby use the above mentioned commands.
To use default incase of switching use
  • rvm use default
To remove RVM from the system use the command
  • rvm implode

Installing Ruby on Ubuntu

Step 1 Verifying


Verify the system is update and then run a sudo apt-get update on the terminal.

Step 2 Installing RVM on Ubuntu


Open terminal and type
  • curl https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer | bash -s stable
This will install RVM on your system.
Please close and open the terminal again to load RVM.
To verify the RVM installation , open Terminal and type
  • rvm requirements
This will show a help doc.

Step 3 Installing required RVM packages before installing Ruby


Open Terminal and run the below mentioned commands one after the another
  • rvm pkg install zlib
  • rvm pkg install openssl
  • rvm pkg install iconv
  • rvm pkg install readline
  • rvm pkg install autoconf

Step 4 Installing Ruby


Open the Terminal and type the following command
  • rvm install 1.8.7 -C --with-openssl-dir=$rvm_path/usr --with-zlib-dir=$rvm_path/usr
Here 1.8.7 reflects the Ruby version 1.8.7 and the latest patch, so to install any specific version or path you specify it by altering the above mentioned command eg.
  • rvm install 1.8.7-p334 -C --with-openssl-dir=$rvm_path/usr --with-zlib-dir=$rvm_path/usr
  • rvm install 1.9.3 -C --with-openssl-dir=$rvm_path/usr --with-zlib-dir=$rvm_path/usr

Step 5 Verify the installation


Open a new Terminal window and type
  • rvm list This will display the list of the different rubies installed on the system.
    To use a specific Ruby version use the following command
  • rvm use 1.8.7
  • rvm use 1.8.7-p334
  • rvm use 1.9.3 To make a Ruby version default for the system use the command
  • rvm alias create default 1.8.7
  • rvm alias create default 1.8.7-p334
  • rvm alias create default 1.9.3
This Ruby version will be the default version of Ruby on the system , to change to other versions of Ruby use the above mentioned commands.
To use default incase of switching use
  • rvm use default
To remove RVM from the system use the command
  • rvm implode

Installing Ruby on Windows

Step 1 :

Download Ruby from http://www.ruby-lang.org/en/.

Versions Available :
  • Ruby 1.8.6
  • Ruby 1.8.7
  • Ruby 1.9.1
  • Ruby 1.9.2
  • Ruby 1.9.3 *Recommended
Run the installer to install Ruby like any other windows application.
After install verify the installation by opening the command prompt
( Win Key + R : Type CMD : Press Enter )
Type
  • ruby -v
This should display the Ruby version which has been installed

Step 2


Extract the Devkit in a directory.
Open command prompt and navigate to the the directory where you extracted Devkit.
Type
  • ruby dk.rb init
  • ruby dk.rb install
    Now Devkit is configured on your system.

Step 3

Download Mysql/any other DB installer and install it on the machine to be used as a database for your Rails application

Creating a native iOS application !

Step 1 Installing XCode on the system

  • Download and install XCode from the App Center alongwith the Developer Tools

Step 2 Download the Phonegap SDK

  • Download and unzip the Phonegap SDK.
  • Now navigate to the iOS directory in the extracted source and run the Cordova-1.7.0.dmg and install it.

Step 3 Creating a XCode Project

Run XCode and create a new Project
Select the template
  • Cordova-based Application
This will create the a new project and include the neccesary Phonegap API Files.

Step 4 Changing the default compiler

  • Click on the application name and select BUILD SETTINGS tab in the center pane
  • Change the compiler in the BUILD OPTIONS from APPLE LLVM COMPILER to LLVM GCC

Step 5 Build and Run the Project

  • Click on the left top of the XCode window selecting the default device as iPad/iPhone Now run the Project. This would invoke the simulator and run the application on it.
  • Once the application runs a error will Popup stating the index.html is not found. Close the simulator and return back to the XCode project window.

Step 6 Include www folder in the project to start with application development

  • Right click the project name and select Show in Finder
  • Drag the www folder from the Finder to the Project
  • A window pop's up , select to create references to the files.

Step 7 Again BUILD & RUN

  • Now again build and run the project in an iPad/iPhone simulatore
  • This time it would show up the index.html which is located in the www folder. Also it would show up the Dialog stating that Phonegap was successfully integrated in the application

Step 8 Download JQuery Mobile bundle

Download the latest build of JQuery Mobile from http://jquerymobile.com/ Unzip the contents and add the files in the www folder categorizing the folders as
  • javascripts
  • stylesheets
  • `images'

Step 9 Including the JQuery mobile in the application

  • Open index.html and create references to the javascript and css files located in the www folder using the html tags

Step 10

Add a few lines of HTML to the index page and use the JQuery classes and the Phonegap api function calls to implement the features of the native application as desired
More Documentation available at

Step 11 * not tested though

  • Once the application is complete or for on Device testing a Apple's Developer License is required to sign the applications.
  • After signing it , push the application to PhoneGap Build https://build.phonegap.com/.
  • Download the build package and deploy to th Device.

11 February 2012

Setting up RHODES with an Android Emulator

Setting up the system

1. Installing Ruby. Please follow the sequence of commands given below to install ruby on ubuntu using RVM.

$ sudo apt-get install git
$ sudo apt-get install curl
$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
$ rvm pkg install zlib
$ rvm pkg install openssl
$ rvm install ruby-1.8.7-p334
$ rvm alias create default ruby-1.8.7-p334
2. Download Android-sdk for linux
Android SDK Download
3. Download Android-ndk for linux
Android NDK Download
4. Extract both the zip files in two different folder's.

5. Java is needed to be installed in the system.If not then download the Java SDK zip files from
Java SDK 7 Download
6. Open the terminal and install the rhodes gem.
 gem install rhodes 
the installation of the gem will take time as the size of the gem is < 50 MB

7. After the gem installation ,type
$ rhodes-setup

at the terminal .The screen should come up something like this ..


Now type in the directories where you extracted the
1.Java SDK
2.Android SDK
3.Android NDK
8. Setting up the environment is complete.


Now we will generate a demo application using rhodes to test the emulator.


1.Setting up Android SDK to host an emulator of a specific android version.

2.Go to the directory where you extracted the sdk .Then go into the tools folder in the sdk and click on a file name "android".A window opens up :

3. Click on the checkbox Android 3.0 , this selects all the checkboxes in this group.Now click on install wait for a few minutes.

4. Now open your terminal and generate a new rhodes application.
rhogen app Demo
cd Demo
5. Edit the built.yml file in any text editor to change the android version to 3.0 instead of default 2.1 and add an emulator name.


6. Now go back to the terminal and type :
rake run:android
7. The android emulator will show up in a few minutes and load the rhomobile application .


Now we can go forward designing the mobile application.Happy coding :)