New How-Tos in my new blog “”

Here are List of new How-Tos I posted on my new blog

Things I learn while using git and github

June 15, 2013 10:29 AM

After my git nightmare, I decided to make post like Things I Learn. To create a branch and switch to that branch. Simply switch to another branch You made some changes to your exiting files, to commit those changes You … Continue reading

Test Your Website’s Features In Firefox, Safari And Chrome Using Rspec and Capybara With Selenium.

March 27, 2013 4:20 PM

First setup you mac as mentioned in Check Your Web-App’s Functionality Using Rspec, Cucumber And Capybara With Selenium. As of writing this post you can use firefox version 19 and chrome version 26 with selenium-webdriver (2.31.0). I hope you installed … Continue reading

Things I Learned While Working With Capybara

March 15, 2013 8:05 PM

I have been testing a website with help of Rspec, Cucumber and Capybara with Selenium. Mainly I am using Capybara for selecting and filling up textfields. It is very easy finding any element with Capybara’s find because it looks for … Continue reading

Check Your Web-App’s Functionality Using Rspec, Cucumber And Capybara With Selenium

March 7, 2013 8:37 PM

Sometime it is not possible or even feasible too check each functionality of your website/web-app. Or you added a new feature in you site/app – now you want check that if the new functionality breaks old one’s. Now you can … Continue reading

Setup Homebrew, Perlbrew, Ruby, RVM, Perl, cpanm, nginx in Mountain Lion

February 19, 2013 6:58 PM

This is a quick tutorial or run down to setup Homebrew, Perlbrew, Ruby, RVM, Perl, cpanm on Mountain Lion. All the softwares/programs/packages mentioned are very popular. I don’t think I have to give any description on these. I recently installed … Continue reading

How-To Handle expired access tokens for Facebook App

January 23, 2013 7:05 PM

Since Facebook removed offline_access – manageing access tokens has been quite difficult. I have developed a web app for Facebook pages and twitter accounts. While devloping the app i have face the expired access tokens problem. I will discuss … Continue reading

Update Profile Background Image of Twitter Account

January 4, 2013 3:11 PM

From Twitter REST API v1.1, APP can update user’s Profile Background Image. The details of the API is here. First of all download tmhOAuth from github. To uodate background we will need oauth_token, oauth_token_secret. Here is an exampl to get … Continue reading

Use reCAPTCHA in CakePHP App

January 2, 2013 5:28 PM

reCAPTCHA is a free ANTI-BOT service from google. This service is pretty good and very easy to implement. I have implemented this on my recent CakePHP app. First you should do is sign up and register you domain for private … Continue reading

Parse Emails Using IMAP

November 23, 2012 4:33 PM

Recently I have worked on project where I had to parse incoming emails and find out who send it and depending on the message run certain DBMS tasks. PHP’s IMAP Functions are quite efficient. You can can retrive emails using these functions in no time. To Get emails we first need to make a connection […]

Customize CakePHP’s Error Messages With Component

November 8, 2012 6:42 PM

CakePHP has wonderful way to show error messages after validating Form fields. It shows two types of error messages. One is at the top which says some thing liek this “User can not be saved. Please try again.”. another type of error messages shows bellow the input fields Like ‘Name can not be empty’. In […]

Citrix’s GoToWebinar PHP Library

Citrix’s GoToWebinar is revolutionary product for online marketing. It has wonderful email management system and custom tempting system for the front end. You can find out more about Citrix Online also has multiple of APIs for GoToWebinar. You can see all the APIs on Citrix Online supports OAuth 2.0 for authentication of user […]

Custom Segue Animation left to right Using CATransition

Storyboarding is very cool feature. When I started developing iOS apps I some how felt at home because of my Visual Basic background. Any way using Segue you can build an app and going from one view to another view and the animation is handel by iOS. The best thing is you subclass the Segue […]

CakePHP Helper To Generate Two Different Link For Canvas APP And Web App Depending On signed_request

I am developing a Facebook App for Canvas and Web. When a user comes to canvas app all of the link of app will start with “” and when users comes web app all link start with the web url. This impotant for user expericne in canvas app. As app the canvas apps are iframe […]

Managing Conference Calls With twilio API in Cakephp

Recenetly I worked on a project where I have make Conference call with multiple user. Add users or remove users to a conference on the fly. After certain time all calls in a conference had be dropped. At first I was bit lost how to do this. Then I found out about twilio. They have […]

Implementing MySql View in CakePHP For Typeahead Search

View works like a table, but it is not a table. It never exists; it is only a prepared SQL statement that is run when you reference the view name. A programmer can write VIEWs that limit the dataset both horizontally and vertically, ensuring that only the data that is required is queried for. Recently […]

ISPConfig 3 setup on Ubuntu

There are number of Hosting Control Panel Softwares. The cPanel is best but it cost 10$ per month. Plesk also need licensing cost. Webmin is free but it interface is not user friendly. THe ISPConfig – Hosting Control Panel Software has user friendly interface with a lot of functions and it totally free. They charge […]

Mail Server Installation on Ubuntu

As a beginner to linux it took about almost 10 days of goggling for me for proper installation of mail server and fixing necessary problems. Before you start this you should look into these post Some Important Linux commands for Newbies and Setup LAMP With Ubuntu In 10 Minutes. We will setup Postfix (Mail Transfer […]

Some Important Linux commands for Newbies

January 20, 2012 2:58 PM

My first experience with Linux started when i setuped a server for one my client. It was monumental task for me at that time. I was very happy mouse driven windows user. When I came to the world of putty I was lost. So I had to search for certain commands. I recently written the […]

jQuery, JSON and jTemplates For Ajax driven Web app

December 18, 2011 11:35 PM

jQuery is one best and easy JavaScript Library. There are thousand of plug-in to do endless thing to do on the web-page. The best thing is you don’t have to worry about will this code you written run on ie/opera etc. The Best way to make a web app or website is using Ajax. Obviously […]

Ubuntu Linux Setup and Configure a Domain Name Server Using BIND

December 18, 2011 2:42 PM

Recently i had to setup a LAMP server for one of client. As usual I chose Ubuntu. I setup the The LAMP. You can view the Setup LAMP With Ubuntu In 10 Minutes. Then my client wanted to setup domain on that server. So start searching for easy to setup domain name on Ubuntu server.So […]

Add Your Own Validation in model On CakePHP

Thursday, October 27, 2011 1:27 AM

CakePHP has many validation rules that can make model data validation much easier. There are 26 core validation rules. You can see here. These 26 rules almost covers all the validation. You can also add multiple validation to one field. But some time you need your own validation or you need to check a value […]

Setup LAMP With Ubuntu In 10 Minutes

Tuesday, October 18, 2011 2:10 PM

I love debian/ubuntu based linux because of this command apt-get. As a starter knowing this one command, It is so easy to install packages and you dont need to worry about package dependency and configuration. I first come use Ubuntu when i start using Amozon’s ec2. I was amazed how easily i can build up […]

How To Setup SSL On Ubuntu

Monday, October 10, 2011 4:09 PM

This the second part of the SSL setup tutorial. Before reading this make sure you have followed the step shown How To Create A Certificate Signing Request (CSR) For SSL. In This tutorial i am assuming you have only one domain and no sub-domains on the server. By now you have, and file. […]

How To Create A Certificate Signing Request (CSR) For SSL

Tuesday, October 04, 2011 12:24 PM

Secure Sockets Layer (SSL), are cryptographic protocols that provide communication security over the Internet. SSL creates a secure connection between a client and a server. From 1st October all the Facebook app have to support SSL. For that I had to setup up SSL on many clients server. This “how to” is two part – […]

How To Adjust Position Of FB.ui Dialog On Long Page

Thursday, September 29, 2011 11:52 AM

Facebook’s FB.ui Dialog is nice and easy to use. Recently I added FB.ui dialog box to send apprequests to user friends. It worked fine on my test account and my account. So we go live. I was happy. But At night i checked my mail and i got bad news. The FB.ui pop was not […]

Implementing Facebook Event API With fql.multiquery and With Graph Api

September 16, 2011 10:21 PM

Facebook is our part of lifestyle and people are using this to create event so that friends can easily RSVP. Facebook Event is getting quite popular. Many Facebook application and website are using Facebook event api to show users events on their site and apps. Recently I added Facebook event functionality in In this […]

Tuning / Optimizing my.cnf file for MySQL

Saturday, September 10, 2011 5:24 PM

MySQL is a popular choice of database for use in web applications, and is a central component of the widely used LAMP web application software stack—LAMP is an acronym for “Linux, Apache, MySQL, Perl/PHP/Python”. MySQL is used in some of the most frequently visited web sites on the Internet, including Flickr,, YouTubeand as previously […]

Should I Use Database For Storing sessions in CakePHP

Wednesday, August 24, 2011 3:09 PM

Session handling is a important part of any web app. CakePHP offers 4 storage facilities for session storage. I will go through all of them and discuss advantages and disadvantages of 3 of them. They are cake (Saves the session files in your app’s tmp/sessions directory.), database(Uses CakePHP’s database sessions), php(The default setting. Saves session […]

Prevent Your CakePHP App From XSS Attacks

By default Cakephp will protect app against SQL Injection if you use CakePHP’s ORM methods (such as find() and save()) and proper array notation (ie. array(‘field’ => $value)) instead of raw SQL. But this does not potect you from XSS attacks. To Understand XSS attack, i will show a simple example. Create a php code […]

CakePHP and facebook SDK as Vendor

Thursday, July 28, 2011 2:20 PM

For most of the application on Facebook is simple but sometimes you have such a big application to develop you need to use a php framework. As I am a CakePHP developer, I like to use CakePHP for these type of applications .In this How-To, I will show how you can add Facebook SDK in […]

Disable Browser Cache in Cakephp

When developing web apps, sometimes it is better to disable browser cache. We can do it in php by following code So how do we set these in cakephp? Very simple This will produce headers like this I recommend calling this function in certain function rather than calling it beforeFilter() function in app_controller.php

How To Get The Pages The Facebook User is Admin Of

Saturday, July 16, 2011 1:27 AM

Some times you need the Facebook pages of a user. You can get it by simple fql. Here is how $user_pages will have the information about the pages that the user admin of

Uploading a Video to Facebook User’s wall or Page’s wall

Monday, July 11, 2011 4:44 PM

In this post I will show how you can post a image to user’s wall and to a page’s wall. To post image to page’s wall- the user logged must be admin of the page. Suppose Zakir is user of you admin. Now you want Zakir to post a image to a page (name of […]

Scroll To a Specific Location In The Iframe of Your Facbook App’s Canvas Page

Thursday, July 07, 2011 2:18 AM

After Facebook introduce iframe in their platform – many issues have risen. On of them was scroll bar and to scroll to top. To understand scroll to top problem- suppose the first page of you application has 800px height. then your second page is 400px. when your user goes from first page to second, he/she […]

Adding Google’s Data APIs to CakePHP – include_path Problem Fix

Saturday, June 11, 2011 12:56 AM

I recently developed a web app with youtube api. In this app I submit comment on any video, like or favorite any video. I used the zend gdata library. So i put them in the vendor folder and add it to my the controller. But i found the famous include_path problem. So i will share […]

Easy Way to Checking User’s Permission, Using Rest Api in Graph Api and Getting Facebook App Friend With Fql

Friday, June 10, 2011 5:52 AM

It was very easy to get app friends using Facebook’s legacy rest api. It is still easy to get app friends with graph api. The very good side og the graph api is that you can call the rest api with in graph api. In this post i will show you use rest api in […]

json_encode() json_decode() working with UTF-8

Sunday, May 22, 2011 1:04 AM

Working with different locale is very important now a days. But to work with different languages you face some problems – like all of a sudden some function will not work like it supposed to. For instance json_decode/json_encode. The problem is not with the functions cause in php manual they said it works with utf […]

Migration to OAuth 2.0 + HTTPS and Upgrade to Facebook’s PHP SDK v3.0.0

Saturday, May 21, 2011 2:34 PM

As Facebook’s new roadmap all Facebook app have to have HTTPS or SSL certificate. Facebook also updated their sdk to meet the changes they will do. Here i will show how easily you can use their new sdk. First download the new sdk. now If you’re currently using the PHP SDK (v2.2.x) for authentication, you […]

IE Blocking iFrame Cookies

Friday, May 20, 2011 12:08 AM

Recently one of my facebook applications was not running correctly from inside an iFrame in IE. I tried it out and it looked like everything worked great in Safari and Firefox but not IE6 or IE7. The problem was i was not getting a session value on page. I was puzzled why would it do […]

Using the Graph API to Get Permissions Granted By Facebook user

Thursday, May 05, 2011 12:46 PM

Before Graph Api you could very easily get the permissions that the user granted the App. It was not available in Graph Api. Recently Facebook added new functionality to do this in graph api. Here is code to get the permissions of a use or if you use the php sdk, you can use this […]

Simple Way to Create Captcha in CakePHP

Monday, May 02, 2011 3:25 PM

When i start developing site using CakePHP, I was at wits end about how to implement capcha. I found couple ways using google but all of them seemed hard to implement. Now i am going to show you can do it in an easy simple way.There are many ways to add captcha to your CakePHP […]
Posted in PHP | Leave a comment

Using the Graph API to Get Permissions Granted By Facebook user

Go to fior updated code.

Before Graph Api you could very easily get the permissions that the user granted the App. It was not available in Graph Api. Recently Facebook added new functionality to do this in graph api. Here is code to get the permissions of a use

  $app_id = "FACEBOOK_APP_ID";
  $app_secret = "FACEBOOK_SECRET_KEY"; 
  $my_url = "YOUR_POST_LOGIN_URL"; 

  $code = $_REQUEST["code"];
  if(empty($code)) {
    $dialog_url = "" 
    . $app_id . "&redirect_uri=" . urlencode($my_url) . "&scope=email";

    echo("<script>top.location.href='" . $dialog_url . "'</script>");

  $token_url = ""
    . $app_id . "&redirect_uri=" . urlencode($my_url) 
    . "&client_secret=" . $app_secret 
    . "&code=" . $code;

  $access_token = file_get_contents($token_url);
  echo "graph_url=" . $graph_url . "<br />";
  $user_permissions = json_decode(file_get_contents($graph_url));

or if you use the php sdk, you can use this code sinnept

$facebook = new Facebook(array(
  'appId'  => FACEBOOK_APP_ID,
  'secret' => FACEBOOK_SECRET_KEY,
  'cookie' => false,

$session = $facebook->getSession();

$loginUrl = $facebook->getLoginUrl(
		'canvas'=> 1,
		'fbconnect' => 0,
		'req_perms' => 'manage_pages,offline_access,user_likes,read_stream'		

$me = null;
if ($session) {

	try {
		$uid = $facebook->getUser();
		$me = $facebook->api('/me');
		$permissions = $facebook->api('/me/permissions');

	} catch (FacebookApiException $e) {
if (!$me or $chk==1) {
	echo "<script type='text/javascript'>top.location.href = '$loginUrl';</script>";
Posted in Facebook, Graph Api, PHP | Tagged , , | Leave a comment

Simple Way to Create Captcha in CakePHP

Go here for updated code and files.

When i start developing site using CakePHP, I was at wits end about how to implement capcha. I found couple ways using google but all of them seemed hard to implement. Now i am going to show you can do it in an easy simple way.There are many ways to add captcha to your CakePHP site. I am going to show a easy way to do it. First Lets create a folder named “captcha” in vendor folder. Lets develop the vendor code.

class captcha {
	public function show_captcha() {
		if (session_id() == "") {

		$path= VENDORS.'captcha';
		$imgname = 'noise.jpg';
		$imgpath  = $path.'/images/'.$imgname;

		$captchatext = md5(time());
		$captchatext = substr($captchatext, 0, 5);

		if (file_exists($imgpath) ){
			$im = imagecreatefromjpeg($imgpath);
			$grey = imagecolorallocate($im, 128, 128, 128);
			$font = $path.'/fonts/'.'BIRTH_OF_A_HERO.ttf';

			imagettftext($im, 20, 0, 10, 25, $grey, $font, $captchatext) ;

			header('Content-Type: image/jpeg');
			header("Cache-control: private, no-cache");
			header ("Last-Modified: " . gmdate ("D, d M Y H:i:s") . " GMT");
			header("Pragma: no-cache");

			echo 'captcha error';

This code actually very simple. First i check for session. Then i check for a noise image. Then i create the image. I added the cache control here for any caching problem.

Now we implement it on our site. to do that we have to add a function the controller or we can add it to our pages controller.

    function captcha_image(){
		App::import('Vendor', 'captcha');
		$captcha = new captcha();

Then we call it in our view.

<img id="captcha" src="<?php echo $this->Html->url('/pages/captcha_image');?>" alt="" />

Simple right. Now if your user doesn’t understand current captcha he will want another one. How you do that?
here is how

    <a onclick="javascript:document.images.captcha.src='<?php echo $html->url('/pages/captcha_image');?>?' + Math.round(Math.random(0)*1000)+1" href="javascript:void(0);">
 <img src="<?php echo $this->webroot;?>css/images/tst_reset_button.jpg" alt="reset" border="0" />

To check the captcha in controller we will use this one.

	$this->Session->setFlash(__('Please enter correct captcha code and try again.', true));

So as you can see you add this to you site very easily and it is very much customizable. You can download the vendor files along with image and font HERE.

Posted in CakePHP, PHP | Tagged , , , | 4 Comments

How to Add the Facebook’s new Send Button

You can get the latest from my new site

The Send button can be easily added to existing Like buttons or as a standalone feature. Developers currently using the XFBML Like button can include the send=”true” attribute in their Like button code to generate a combined button, and those using an iFrame version of the Like button will need to upgrade to XFBML to display a Send button. The following code will generate a combined Like and Send button:

<div id="fb-root"></div>
<script src=""></script>
<fb:like href="" show_faces="true" width="450" send="true">

Developers can add a standalone Send button with the following code:

<div id="fb-root"></div>
<script src=""></script>
<fb:send href=""></fb:send>

You can create your own send plug-in here You can also create like and send plug-in togather here

Also, it is strongly recommend using Open Graph meta tags on your web pages to control the title, description and image displayed when people use the Send button.

Posted in PHP | Leave a comment

Embedding videos in the News Feed and Improved News Feed story for Comments Box

You can get the latest from my new site

Some times you want to share video on Facebook from you site. Previous it was not possible, now Facebook introducing some META tag for this.

og:video – e.g., “;

and optionally, you can add additional metadata

og:video:height – e.g. “640”

og:video:width – e.g. “385”

og:video:type – e.g. “application/x-shockwave-flash”

Now When any visitor share a video will show in the feed.

Comments Box is a very good tool for any website. A visitor can use it even if he/she does no have or use Facebook. Hotmail ,AOL and Yahoo! is third party options people may choose for commenting. More over Facebook added new colorscheme for this tool. Now you can have dark background.

For dark background

<div id="fb-root"></div>
<script src="
<fb:comments colorscheme="dark" href="[YOUR_URL]" num_posts="5" 

You can access all comments on your site from here{YOUR_URL}

Or if you add the app id in META tag. then you can edit/ modarate the comments on the site. You can also do it on here

<meta property="fb:app_id" content="{YOUR_APPLICATION_ID}">

For better feed just use og:image, og:title, og:url, og:description, and og:site_name then you will have a feed like this

The META tags looks like this for this page

<meta property="og:site_name" content="site name Like TechCrunch"/>
<meta property="og:title" content="Title of webpage"/>
<meta property="og:image" content="Absolute image url "/>
<meta name="description" content="descriptions of you webpage" />
Posted in Facebook | 5 Comments

Easy Way to Change Facebook’s Share Image and Title

Go here for updated code.

Now a days, every one wants to share every thing on Facebook. Sometimes there are no image on the page so Facebook will not show any image or you want to change the title of what you want to share.

For example you have a page on you site that shows a YouTube video or Vimeo video. Now you want to show the thumbnail of the video as the Facebook share’s image. How you do it? First we add the Share code on the page.

<a type="button" name="fb_share">Share</a>
<script src="" type="text/javascript"></script>

Now you add the image url and title in the meta tag.

<meta property="og:image" content=""/>
<meta property="og:title" content="The Title"/>

You can add couple of other things on the meta to change the way the share shows information. You can find it HERE. You can see example of the share HERE.

You can also check page using this tool HERE. This tool also can be used as cache clear. For example, YOu had page where you show a image now you want to show a new image. But share is show old image. Just put the page url here and lint.

Posted in Facebook, General | Leave a comment

Styling File Inputs with CSS and the Dom

You can get the latest from my new site


styling file inputs with css and the dom

File inputs (input type=”file” ) do not look good on beautiful form/html design. But you can hide on your design and keep beautiful html design. Recently i had to devlop a site with out file inputs but user must be able to upload file. i found many developers use flash or use complex JavaScript to do this but I found a easy solution HERE. I will show how you can keep the functionality of file input without using a lot of JS code or Flash.

First let develop the html. Here is the code

<label class="lable_holder">
    <input class="file_upload" type="file" />

The file input is given a class of file_upload and wrapped in an element with a class of lable_holder.

Now the CSS

.SI-FILES-STYLIZED label.lable_holder
    width: 79px;
    height: 22px;
    background: url(btn-choose-file.gif) 0 0 no-repeat;

    display: block;
    overflow: hidden;
    cursor: pointer;

.SI-FILES-STYLIZED label.lable_holder input.file_upload
    position: relative;
    height: 100%;
    width: auto;
    opacity: 0;
    -moz-opacity: 0;

Now You add Javascript file to your html

<script src="/path/to/si.files.js" type="text/javascript"><!--mce:0--></script>

Now you can call either in your onload event handler or at some point after your file inputs appear in the source




This solution is known to work in:

IE 5.5+
Firefox 1.5+
Safari 2+

It is known to degrade gracefully in:

IE 5.01

You can download JS file from HERE

Posted in CSS, DOM, HTML, JavaScript | Leave a comment