Wednesday, April 24, 2013

How to migrate from SVN to GIT

Currently, Git is getting popularity as a distributed version control system. Many Subversion repository is moving from SVN to Git. I have recently moved a SVN repository under GIT version control system.

Git has come up with built in support for svn switching. We will us the git svn command in this regard. First we will get the codebase from SVN with the below command
git svn clone http://path_to_repository folder_name

With the below command you will see all the log history are also carried to the Git repository

git log

To remove svn tags to be more proper tags on git:
git for-each-ref refs/remotes/tags | cut -d / -f 4- | grep -v @ | while read tagname; do git tag "$tagname" "tags/$tagname"; git branch -r -d "tags/$tagname"; done

Next, we will move the remaining references to /remote/references
git for-each-ref refs/remotes | cut -d / -f 3- | grep -v @ | while read branchname; do git branch "$branchname" "refs/remotes/$branchname"; git branch -r -d "$branchname"; done

Now, we will add the origin to the Git URL
git remote add origin https://path_to_git_repo

Finally, you need to push your changes to the remote repository:
git push origin --all



See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Saturday, April 20, 2013

How to install nginx

Nginx is a very lightweight and highly scalable server. If we don't want to use all of the modules of Apache, then we can go for nginx.

To install nginx, we will follow the below ways:
  • From apptitude: We can get nginx from the ubuntu package distribution. At the moment, we will get nginx 1.3.12. we need to add the ppa. you will find the ppa information here. To add the ppa, type this command:
    sudo add-apt-repository ppa:nginx/development[stable]
    

    Now, we add the sources to the source list file: /etc/apt/sources.list.
    deb http://ppa.launchpad.net/nginx/development/ubuntu quantal main 
    deb-src http://ppa.launchpad.net/nginx/development/ubuntu quantal main 
    

    Here, we will update the apptitude and install nginx:
    apt-get update 
    apt-get install nginx
    

  • From source: we can also get it from source.


See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

Monday, April 15, 2013

How to compress a website with gzip

Gzip compression is one of the way to optimize site performance. A client browser sends a header request of Accept-encoding: gzip, deflate. Then server knows that his client is gzip enabled. It compresses it's contents and sends back Content-encoding: gzip, deflate.

    There are several ways to gzip compress a website.
  • Using .htaccess: We can enable gzip compression with .htaccess file. For that we need to enable mod_deflate or mod_gzip. It's pretty simple to work with mod_deflate. To enable it, please uncomment the load module line in httpd.conf file.
    LoadModule deflate_module modules/mod_deflate.so
    

    Now restart apache. You are all set to go with deflate module.
    Please open your .htaccess file and add the below code block:
    
    # compress text, html, javascript, css, xml:
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    
    # remove browser bugs
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    Header append Vary User-Agent 
    
    

    First of we set the file content types which will be process with deflate module to compress. we compress text, html, javascript, css, xml and css files.
    Then, we add some exceptions. like for Mozila version 4, we only compress text files. And also for IE, we will not gzip our contents. Because there is some bug with compression in those user agents.
  • If we don't have mod_deflate enabled or we don't have proper permission to write .htaccess files, then we can compress files using php ob_gzhandler function.

    
    

    We check the "Accept-encoding" header and return a gzipped version of the file; otherwise the regular version.


See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide

HTML classes are removed in CKeditor 4.1

Recently, I was working with ckeditor 4.1. It has some security updates. I was posting some HTML contents using the editor. When I go to Design mode from Source mode, and then again come back to Source mode, I found the class attached to the HTML elements were missing.

Ckeditor 4.1 introduces Advanced Content Filter. This filter outs suspicious HTML elements with CSS class, JS attributes. To disable ACF, we need to add the allowedContent property to true on the configuration file.

There are two configuration file in Drupal module. One is the config.js under ckeditor/ckeditor folder and another one is ckeditor.config.js under ckeditor folder. In my case, the later one worked. I have added the below line into the config file

config.allowedContent = true;


See the book OpenCart 1.4 Template Design Cookbook.
See the book Joomla Mobile Development Beginners Guide




List of my works:

Opencart Extensions:

  1. Product Based Quantity Wise Shipping: Find it here.
  2. OpenSSLCOMMERZ: integrate SSLCOMMERZ with opencart: Find it here.
  3. Fine Search v.1.0 - Improves Opencart search feature to find relevant: Find it here.
  4. Opensweetcaptcha - An easy way to generate attractive captcha for your system!: Find it here.
  5. Custom Field Product - add unlimited custom fields to the product form: Find it here.
  6. Formcaptcha - add captcha on the register page: Find it here.

My Books:

  1. OpenCart 1.4 Template Design Cookbook.
  2. Joomla Mobile Development Beginners Guide