Wednesday, May 8, 2013

Installing memcached 1.4.4 on windows

Recently, I was working on memcached with windows machine. Memcached is built for linux platform. It's latest stable version is 1.4.15. But we haven't found the compatible windows binary file for the latest version. I have found binary for memcache 1.4.5, but it was providing errors while installing with the command:
memcache.exe -d install

It hung up on the window. I googled and found that '-d' option is no longer supported. They are suggesting to use memcache 1.4.4. Then I download memcache 1.4.4 from here.

    Now, follow the below steps:
  • 1.Extract the downloaded files and unzip it.
  • 2.Open CMD and go to the downloaded folder.
  • 3.Run memcache.exe -d install.
  • 4.Now go to Start->Administrative Tools->Services.
  • 5.Double click on the memcache list.
  • 6.Press the Start button.
  • 7.Now we need to download the .dll file for vc9 from here.
  • 8.We will put the .dll file under php/ext folder under xampp.
  • 9.Also we will write extension=php_memcache.dll on the php.ini file under php folder.
  • 10.Now we will restart Apache.


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

Friday, May 3, 2013

How to remove provisioning profiles

Some times you want to delete some old unused provisioning profiles from your mac osx. We can remove those files in several different ways. One way is delete manually using finder. The provisioning profiles are stored under the below file location

~/Library/MobileDevice/Provisioning Profiles

Remove the file from this folder.


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

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

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

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

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

Friday, March 8, 2013

How to manipulate JSON in Javascript?

We needed to manipulate JSON values on Client side. We searched the web. There are some very good options available for JSON manipulation.
We can use the stringify and parse function for this purpose.
json_flat = {"page":"1","total":"2","ids":[{"id":"3085"},{"id":"3086"}]}; // your flat json
json_object = JSON.parse(json_flat); //convert to an object

//Manipulation
json_object.page = 6; //change values
delete json_object.total; //delete a value

json_flat = JSON.stringify(json); //convert back to flat



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

Tuesday, February 19, 2013

How to convert .app file to .ipa file

I was working with Corona SDK. It generates .app files of applications for iOS devices. We might need the .ipa files for iOS application. To convert .app files into .ipa files, we need to follow the below simple steps:
  • 1. Extract the .app zip file
  • 2. Place the .app file under a Payload (case-sensitive) folder.
  • 3. Now zip compress the Payload folder and then rename it with .ipa extension.
  • 4. We are done. We get the equivalent .ipa files.


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

Thursday, January 31, 2013

!important is not working in outlook email

I was working with email templates and found that !important CSS property is not working in Outlook email template. It works correctly in Gmail and Yahoo!. So, it's better to remove !important property from the email template when we create one.
Again, Background-color CSS property is not working in Gmail. It works in Yahoo. We need to use Background property in this regard. Like below:
background:#fff;


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

Tuesday, January 29, 2013

How to remove missing files from svn?

I accidentally removed files from my local machine. But they are listed on SVN repository. Hence, those images are showing as '!' in svn status.
To remove those missing files, just run the below command:
svn status | grep '^\!' | cut -c8- | while read f; do svn rm "$f"; done

Then just commit your changes. Fixed.


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