<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>iPragmatech Solutions Pvt. Ltd.</title>
	<atom:link href="http://www.ipragmatech.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ipragmatech.com</link>
	<description>Pragmatic - Solutions - Integrity</description>
	<lastBuildDate>Sat, 19 May 2012 15:43:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Custom milestones timeline module for Phpfox</title>
		<link>http://www.ipragmatech.com/custom-timeline-milestone-phpfox.html</link>
		<comments>http://www.ipragmatech.com/custom-timeline-milestone-phpfox.html#comments</comments>
		<pubDate>Sun, 13 May 2012 05:16:21 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Phpfox]]></category>

		<guid isPermaLink="false">http://www.ipragmatech.com/?p=1033</guid>
		<description><![CDATA[Timeline has been powerful feature for every community as it display the events related to a user in chronological order. It shall help the community user to show photo albums, videos, musics or any event related to user event. We had been working on a community related to parents and their children. We had a [...]]]></description>
			<content:encoded><![CDATA[<p>Timeline has been powerful feature for every community as it display the events related to a user in chronological order. It shall help the community user to show photo albums, videos, musics or any event related to user event. We had been working on a community related to parents and their children. We had a requirement from our client to create a timeline feature for child activity.We decided to develop a custom timeline module which keeps track of milestones of the child.</p>
<p>At iPragmatech, we generally try to avoid building from scratch and tried to reuse the open source component. Our phpfox developers found a wonderful jquery&#8217;s plugin <a title="jquery-timelinr" href="http://www.csslab.cl/2011/08/18/jquery-timelinr/" target="_blank">jquery-timelinr</a> developed by <a title="CssLab" href="http://www.csslab.cl" target="_blank">csslab</a>. This jquery plugin is light, extensible and easy to use. We can easily add our custom style in timeline and just need to send data in it&#8217;s desired format. We shall show you how we used this plugin to customize phpfox for timeline milestones.</p>
<div id="attachment_1041" class="wp-caption alignleft" style="width: 610px"><a href="http://www.ipragmatech.com/wp-content/uploads/2012/05/milestones.gif"><img class="size-large wp-image-1041" title="phpfox milestones plugin" src="http://www.ipragmatech.com/wp-content/uploads/2012/05/milestones-883x1024.gif" alt="phpfox milestones plugin" width="600" /></a><p class="wp-caption-text">phpfox milestones plugin</p></div>
<ol>
<li>Include the jQuery library and this plugin:</li>
</ol>
<pre class="brush:js">&lt;script src="js/jquery-1.6.1.min.js" type="text/javascript"&gt;&lt;/script&gt;
&lt;script src="js/jquery.timelinr-0.9.js" type="text/javascript"&gt;&lt;/script&gt;</pre>
<p>2. Initialize-it with the default parameters:</p>
<pre class="brush:js">&lt;script type="text/javascript"&gt;

$(function(){

$().timelinr();

});

&lt;/script&gt;</pre>
<p>3.  HTML markup must be as follows:</p>
<pre class="brush:js">&lt;div id="timeline"&gt;

&lt;ul id="dates"&gt;

&lt;li&gt;&lt;a href="#"&gt;date1&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href="#"&gt;date2&lt;/a&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;ul id="issues"&gt;

&lt;li id="date1"&gt;

&lt;p&gt;Lorem ipsum.&lt;/p&gt;

&lt;/li&gt;

&lt;li id="date2"&gt;

&lt;p&gt;Lorem ipsum.&lt;/p&gt;

&lt;/li&gt;

&lt;/ul&gt;

&lt;a href="#" id="next"&gt;+&lt;/a&gt; &lt;!-- optional --&gt;

&lt;a href="#" id="prev"&gt;-&lt;/a&gt; &lt;!-- optional --&gt;

&lt;/div&gt;</pre>
<p>You can also configure lots of setting in timeline view with the initialization of timeline. Feel free to send you feedback for this article. We offer end-to-end phpfox expertise, including consultancy, building new modules, customize existing module features, migration from older versions and performance tuning.</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-timeline-milestone-phpfox.html&amp;linkname=Custom%20milestones%20timeline%20module%20for%20Phpfox" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-timeline-milestone-phpfox.html&amp;linkname=Custom%20milestones%20timeline%20module%20for%20Phpfox" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-timeline-milestone-phpfox.html&amp;linkname=Custom%20milestones%20timeline%20module%20for%20Phpfox" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-timeline-milestone-phpfox.html&amp;linkname=Custom%20milestones%20timeline%20module%20for%20Phpfox" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-timeline-milestone-phpfox.html&amp;linkname=Custom%20milestones%20timeline%20module%20for%20Phpfox" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-timeline-milestone-phpfox.html&amp;linkname=Custom%20milestones%20timeline%20module%20for%20Phpfox" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-timeline-milestone-phpfox.html&amp;linkname=Custom%20milestones%20timeline%20module%20for%20Phpfox" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-timeline-milestone-phpfox.html&amp;linkname=Custom%20milestones%20timeline%20module%20for%20Phpfox" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-timeline-milestone-phpfox.html&amp;title=Custom%20milestones%20timeline%20module%20for%20Phpfox" id="wpa2a_2"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/custom-timeline-milestone-phpfox.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Redirecting previous page using SocialDNA &#8211; Socialengine customization</title>
		<link>http://www.ipragmatech.com/socialdna-socialengine.html</link>
		<comments>http://www.ipragmatech.com/socialdna-socialengine.html#comments</comments>
		<pubDate>Sat, 05 May 2012 12:07:26 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Social Engine]]></category>

		<guid isPermaLink="false">http://www.ipragmatech.com/?p=1022</guid>
		<description><![CDATA[Social DNA plugin for SocialEngine is a wonderful plugin that allows your community to connect with multiple social networking sites like facebook, linkedin etc. We have been doing socialengine customization for one of our client and used this plugin for the community. The only issue with the plugin is that after validating the facebook credentials, [...]]]></description>
			<content:encoded><![CDATA[<p><a title="Social DNA Plugin for SocialEngine" href="http://www.socialenginemods.net/social-engine/plugins/8/openid-connect-facebook-myspace-google">Social DNA</a> plugin for SocialEngine is a wonderful plugin that allows your community to connect with multiple social networking sites like facebook, linkedin etc. We have been doing socialengine customization for one of our client and used this plugin for the community. The only issue with the plugin is that after validating the facebook credentials, it redirects user to the home page instead of the previous page. Our client wanted to modify this behavior and wanted to have a stream line experience for the users i.e. user should be redirected to the previous visited page rather than home page.</p>
<p>So problem was if a user is visiting some page which user can view only and decides to login in order to do any action on this page. So whenever user clicks on SocialDNA facebook connect button from the socialengine community site, It would open a dialog box in which user can enter facebok credentials. After authenticating the facebook credentials, it redirect user to the home page not the page where user came. This can be very annoying experience for the community user so we decided to change this behaviour. Our socialengine developers dig out the source code of SocialDNA plugin and found a way to customize the plugin. Our developers found that its pretty easy to change the behavior as only need to get the previous page referrer and that can be retrieved from Server&#8217;s Parameter. So we made changes in controlls AuthController.php and QuickSignupController.php  as below:<br />
Change</p>
<pre class="brush:php">return $this-&gt;_helper-&gt;_redirector-&gt;gotoRoute(array('action' =&gt; 'home'), 'user_general', true);</pre>
<p>to</p>
<pre class="brush:php">return $this-&gt;_helper-&gt;redirector-&gt;gotoUrl( $_SERVER['HTTP_REFERER']);</pre>
<p>With the above changes, plugin should able to work as desired behavior i.e. user should be redirected to the previous page on the socialengine.<br />
We offer end-to-end SocialEngine expertise, including consultancy, implementation, customization, migration from older versions of SocialEngine and performance tuning. Feel free to contact us if you have any query related to socialengine development.</p>
<h3>Resources:</h3>
<ul>
<li><a title="Create your own social network" href="http://socialengine.net" target="_blank">SocialEngine PHP Community Software – Create your own community website</a></li>
<li><a title="Social DNA Plugin for SocialEngine" href="http://www.socialenginemods.net/social-engine/plugins/8/openid-connect-facebook-myspace-google">Social DNA</a></li>
</ul>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialdna-socialengine.html&amp;linkname=Redirecting%20previous%20page%20using%20SocialDNA%20%E2%80%93%20Socialengine%20customization" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialdna-socialengine.html&amp;linkname=Redirecting%20previous%20page%20using%20SocialDNA%20%E2%80%93%20Socialengine%20customization" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialdna-socialengine.html&amp;linkname=Redirecting%20previous%20page%20using%20SocialDNA%20%E2%80%93%20Socialengine%20customization" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialdna-socialengine.html&amp;linkname=Redirecting%20previous%20page%20using%20SocialDNA%20%E2%80%93%20Socialengine%20customization" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialdna-socialengine.html&amp;linkname=Redirecting%20previous%20page%20using%20SocialDNA%20%E2%80%93%20Socialengine%20customization" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialdna-socialengine.html&amp;linkname=Redirecting%20previous%20page%20using%20SocialDNA%20%E2%80%93%20Socialengine%20customization" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialdna-socialengine.html&amp;linkname=Redirecting%20previous%20page%20using%20SocialDNA%20%E2%80%93%20Socialengine%20customization" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialdna-socialengine.html&amp;linkname=Redirecting%20previous%20page%20using%20SocialDNA%20%E2%80%93%20Socialengine%20customization" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialdna-socialengine.html&amp;title=Redirecting%20previous%20page%20using%20SocialDNA%20%E2%80%93%20Socialengine%20customization" id="wpa2a_4"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/socialdna-socialengine.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Monetize Socialengine communty with SMS plugin</title>
		<link>http://www.ipragmatech.com/monetize-socialengine-sms-plugin.html</link>
		<comments>http://www.ipragmatech.com/monetize-socialengine-sms-plugin.html#comments</comments>
		<pubDate>Sat, 28 Apr 2012 08:26:19 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Social Engine]]></category>

		<guid isPermaLink="false">http://www.ipragmatech.com/?p=954</guid>
		<description><![CDATA[We have been working on the phone module for socialengine and in the last article, we highlighted about the voice call feature for the phone plugin. In this article, we would highlight about the SMS plugin for the socialengine and discuss how you can monetize your socialengine community using this SMS plugin. The purpose of [...]]]></description>
			<content:encoded><![CDATA[<p>We have been working on the phone module for socialengine and in the <a title="Supercharge your socialengine with Voice Mail" href="http://www.ipragmatech.com/voice-message-socialengine.html" target="_blank">last article</a>, we highlighted about the voice call feature for the phone plugin. In this article, we would highlight about the SMS plugin for the socialengine and discuss how you can monetize your socialengine community using this SMS plugin.</p>
<p>The purpose of creating phone plugin was to connect the community and non-community users with each other and keep them updated about each other. The community owners can monetize their community by selling this feature to the community users. So it would be win-win situation for both the users and owners. This plugin allows the user to add non-community users in their contacts list and allow to send them SMS. The plugin also keep track of the SMS sent to the users so user shall be able to track the sent SMS.Currently SMS plugin uses <a title="SMS Gateway" href="clickatell.com" target="_blank">clickatell</a> and t<a title="Twilio SMS" href="http://twilio.com" target="_blank">wilio</a> SMS gateway to send out the SMS efficiently.</p>
<p><a href="http://www.ipragmatech.com/wp-content/uploads/2012/04/socialengine_sms.png"><img class="alignleft size-full wp-image-999" title="socialengine sms plugin" src="http://www.ipragmatech.com/wp-content/uploads/2012/04/socialengine_sms.png" alt="Phone Plugin" width="600" height="248" /></a></p>
<p>&nbsp;</p>
<p>Currently this SMS plugin is in still development phase as our client is looking for funding to complete this plugin. This plugin can be extended to support following features or any customize feature:</p>
<ul>
<li>Allow community users to send SMS to community friends</li>
<li>Send status updates to community friends</li>
<li>Receive SMS from the contacts</li>
<li>Integration with other popular SMS gateway like tropo, voxeo etc.</li>
<li>Admin control and reporting</li>
<li>Integration with payment gateway</li>
<li>Integration with credits plugin</li>
<li>Send notifications for events to the users</li>
<li>Send promotion coupons from the advertisers</li>
</ul>
<p>Feel free to contact us if you think this plugin would help your community to grow and we can discuss about the value proposition for this plugin.This plugin have also capability to record the voice message and send it to user&#8217;s mobile as voice mail.</p>
<h3>Demo:</h3>
<p>Please check the status of online plugin <a title="Socialengine communty with SMS plugin" href="http://www.ipragmatech.com/socialengine">here</a></p>
<p>user:sms@ipragmatech.com</p>
<p>pwd:123456</p>
<h3> Photo Gallery:</h3>

<div class="ngg-galleryoverview" id="ngg-gallery-11-954">


	
	<!-- Thumbnails -->
		
	<div id="ngg-image-118" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/sms_gateway_admin_settings.png" title=" " class="shutterset_set_11" >
								<img title="sms_gateway_admin_settings" alt="sms_gateway_admin_settings" src="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/thumbs/thumbs_sms_gateway_admin_settings.png" width="100" height="51" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-106" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/sms_compose.png" title=" " class="shutterset_set_11" >
								<img title="sms_compose" alt="sms_compose" src="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/thumbs/thumbs_sms_compose.png" width="100" height="52" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-112" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/sms_sentsms.png" title=" " class="shutterset_set_11" >
								<img title="sms_sentsms" alt="sms_sentsms" src="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/thumbs/thumbs_sms_sentsms.png" width="100" height="48" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-114" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/sms_viewmessage.png" title=" " class="shutterset_set_11" >
								<img title="sms_viewmessage" alt="sms_viewmessage" src="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/thumbs/thumbs_sms_viewmessage.png" width="100" height="46" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-113" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/sms_trash.png" title=" " class="shutterset_set_11" >
								<img title="sms_trash" alt="sms_trash" src="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/thumbs/thumbs_sms_trash.png" width="100" height="41" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-110" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/sms_favourite.png" title=" " class="shutterset_set_11" >
								<img title="sms_favourite" alt="sms_favourite" src="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/thumbs/thumbs_sms_favourite.png" width="100" height="52" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-116" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/sms_contactinfo.png" title=" " class="shutterset_set_11" >
								<img title="sms_contactinfo" alt="sms_contactinfo" src="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/thumbs/thumbs_sms_contactinfo.png" width="100" height="51" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-107" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/sms_comtactlist.png" title=" " class="shutterset_set_11" >
								<img title="sms_comtactlist" alt="sms_comtactlist" src="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/thumbs/thumbs_sms_comtactlist.png" width="100" height="49" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-111" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/sms_sbscription_plan.png" title=" " class="shutterset_set_11" >
								<img title="sms_sbscription_plan" alt="sms_sbscription_plan" src="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/thumbs/thumbs_sms_sbscription_plan.png" width="100" height="52" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-105" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/sms_admin_user_credit_setting.png" title=" " class="shutterset_set_11" >
								<img title="sms_admin_user_credit_setting" alt="sms_admin_user_credit_setting" src="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/thumbs/thumbs_sms_admin_user_credit_setting.png" width="100" height="44" />
							</a>
		</div>
	</div>
	
		
 		
	<div id="ngg-image-103" class="ngg-gallery-thumbnail-box"  >
		<div class="ngg-gallery-thumbnail" >
			<a href="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/sms_admin_currency_mode.png" title=" " class="shutterset_set_11" >
								<img title="sms_admin_currency_mode" alt="sms_admin_currency_mode" src="http://www.ipragmatech.com/wp-content/gallery/socialengine-sms-plugin/thumbs/thumbs_sms_admin_currency_mode.png" width="100" height="60" />
							</a>
		</div>
	</div>
	
		
 	 	
	<!-- Pagination -->
 	<div class='ngg-clear'></div>
 	
</div>


<h3>Resources:</h3>
<ul>
<li><a title="Create your own social network" href="http://socialengine.net" target="_blank">SocialEngine PHP Community Software – Create your own community website</a></li>
<li><a title="How to Monetize Social Media" href="http://www.inc.com/guides/201104/how-to-monetize-social-media.html" target="_blank">How to Monetize Social Media</a></li>
</ul>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmonetize-socialengine-sms-plugin.html&amp;linkname=Monetize%20Socialengine%20communty%20with%20SMS%20plugin" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmonetize-socialengine-sms-plugin.html&amp;linkname=Monetize%20Socialengine%20communty%20with%20SMS%20plugin" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmonetize-socialengine-sms-plugin.html&amp;linkname=Monetize%20Socialengine%20communty%20with%20SMS%20plugin" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmonetize-socialengine-sms-plugin.html&amp;linkname=Monetize%20Socialengine%20communty%20with%20SMS%20plugin" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmonetize-socialengine-sms-plugin.html&amp;linkname=Monetize%20Socialengine%20communty%20with%20SMS%20plugin" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmonetize-socialengine-sms-plugin.html&amp;linkname=Monetize%20Socialengine%20communty%20with%20SMS%20plugin" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmonetize-socialengine-sms-plugin.html&amp;linkname=Monetize%20Socialengine%20communty%20with%20SMS%20plugin" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmonetize-socialengine-sms-plugin.html&amp;linkname=Monetize%20Socialengine%20communty%20with%20SMS%20plugin" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fmonetize-socialengine-sms-plugin.html&amp;title=Monetize%20Socialengine%20communty%20with%20SMS%20plugin" id="wpa2a_6"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/monetize-socialengine-sms-plugin.html/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Tweaks to fix socialengine gifts (Hire-Experts) with MaxCDN</title>
		<link>http://www.ipragmatech.com/maxcdn-gifts-socialengine.html</link>
		<comments>http://www.ipragmatech.com/maxcdn-gifts-socialengine.html#comments</comments>
		<pubDate>Sat, 21 Apr 2012 10:46:58 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Social Engine]]></category>

		<guid isPermaLink="false">http://www.ipragmatech.com/?p=919</guid>
		<description><![CDATA[Everybody likes getting gifts. People often give and receive gifts at special occasions or as an expression of love, gratitude or friendship. As a social community user, it would be great if user can send/receive gifts from their friends and relatives. We have been building many social networking sites and always felt that this feature [...]]]></description>
			<content:encoded><![CDATA[<p>Everybody likes getting gifts. People often give and receive gifts at special occasions or as an expression of love, gratitude or friendship. As a social community user, it would be great if user can send/receive gifts from their friends and relatives. We have been building many social networking sites and always felt that this feature to be a part of every community.</p>
<p>Recently Hire-Experts comes up with the <a title="Virtual Gifts" href="http://www.hire-experts.com/social-engine/virtual-gifts-plugin" target="_blank">virtual gifts</a> plugin for the <a title="Social Network Platform" href="http://socialengine.net" target="_blank">socialengine</a> and its amazing plugin to send photo,audio and video gifts. The empower the community users to connect well with their friends.</p>
<p><em>&#8220;You can create as many Virtual Gifts as you would like and link them to any holiday. It can be not only a photo, but also a video or even a music. It automatically suggests members to send a gift on their friends birthday or on holidays &#8211; it is simple and fun.&#8221;</em></p>
<p>We also tried this plugin on one of our client&#8217;s community and it works fine with basic functionality. As soon we tried to test every feature of the plugin, we encountered issue while uploading a virtual photo gift. We were not able to upload the photo and progress bar for upload remains standstill on 0% event after few minutes.</p>
<p><a href="http://www.ipragmatech.com/wp-content/uploads/2012/04/create-gift.png"><img class="alignleft size-full wp-image-920" title="create-gift" src="http://www.ipragmatech.com/wp-content/uploads/2012/04/create-gift.png" alt="" width="610" height="382" /></a></p>
<p>We tried to upload the audio or video gifts to make sure that the issue is with only with photo gift but these features were also not working.  We tried features based on fancyupload in socialengine and concluded that there is definitely some issue with the plugin as other features on socialnegine works fine. So we decided to fix the issue our self as our client insisted us to launch this plugin as soon as possible.</p>
<p>We looked at the code and found that the template file from HE plugin doesn&#8217;t seem to set the cross-domain policy in the javascript function.  We removed the MAX-CDN reference from the socialengine and tried to test the upload.  The functionality worked this time and this verified that the plugin have cross-domain policy issues. We add following lines in the file &#8216;_FancyUploadPhoto.tpl&#8217; while initializing FancyUpload for the upload:</p>
<pre class="brush:php"> // set cross-domain policy file
 policyFile : '&lt;?php echo (_ENGINE_SSL ? 'https://' : 'http://')
        . $_SERVER['HTTP_HOST'] . $this-&gt;url(array(
          'controller' =&gt; 'cross-domain'),
          'default', true) ?&gt;',</pre>
<p>After the above changes, we were able to upload photo gifts. We applied the same changes in the audio and video templates and they worked as well.</p>
<p>We hope HE guys would incorporate this change in their plugin and come up with a patch to support uploading for cross domain. Feel free to give us your feedback and contact us if you wanted to build your own social community based on socialengine.</p>
<p>References:</p>
<ul>
<li><a title="Create your own social network" href="http://socialengine.net" target="_blank">SocialEngine PHP Community Software &#8211; Create your own community website</a></li>
<li><a title="Virtual Gifts" href="http://www.hire-experts.com/social-engine/virtual-gifts-plugin" target="_blank">Hire-Experts</a></li>
</ul>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmaxcdn-gifts-socialengine.html&amp;linkname=Tweaks%20to%20fix%20socialengine%20gifts%20%28Hire-Experts%29%20with%20MaxCDN" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmaxcdn-gifts-socialengine.html&amp;linkname=Tweaks%20to%20fix%20socialengine%20gifts%20%28Hire-Experts%29%20with%20MaxCDN" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmaxcdn-gifts-socialengine.html&amp;linkname=Tweaks%20to%20fix%20socialengine%20gifts%20%28Hire-Experts%29%20with%20MaxCDN" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmaxcdn-gifts-socialengine.html&amp;linkname=Tweaks%20to%20fix%20socialengine%20gifts%20%28Hire-Experts%29%20with%20MaxCDN" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmaxcdn-gifts-socialengine.html&amp;linkname=Tweaks%20to%20fix%20socialengine%20gifts%20%28Hire-Experts%29%20with%20MaxCDN" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmaxcdn-gifts-socialengine.html&amp;linkname=Tweaks%20to%20fix%20socialengine%20gifts%20%28Hire-Experts%29%20with%20MaxCDN" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmaxcdn-gifts-socialengine.html&amp;linkname=Tweaks%20to%20fix%20socialengine%20gifts%20%28Hire-Experts%29%20with%20MaxCDN" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmaxcdn-gifts-socialengine.html&amp;linkname=Tweaks%20to%20fix%20socialengine%20gifts%20%28Hire-Experts%29%20with%20MaxCDN" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fmaxcdn-gifts-socialengine.html&amp;title=Tweaks%20to%20fix%20socialengine%20gifts%20%28Hire-Experts%29%20with%20MaxCDN" id="wpa2a_8"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/maxcdn-gifts-socialengine.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Supercharge your socialengine with Voice Mail</title>
		<link>http://www.ipragmatech.com/voice-message-socialengine.html</link>
		<comments>http://www.ipragmatech.com/voice-message-socialengine.html#comments</comments>
		<pubDate>Sat, 14 Apr 2012 15:22:00 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Social Engine]]></category>

		<guid isPermaLink="false">http://www.ipragmatech.com/?p=903</guid>
		<description><![CDATA[How about sharing your emotions in audio rather than the traditional email message ? Socialengine allows you to upload a audio/video and send them in a message to other community user but is not of much help if you want to send and receive a voice message or song to your friend or family on [...]]]></description>
			<content:encoded><![CDATA[<p>How about sharing your emotions in audio rather than the traditional email message ? <img src='http://www.ipragmatech.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Socialengine allows you to upload a audio/video and send them in a message to other community user but is not of much help if you want to send and receive a voice message or song to your friend or family on their mobile phone.</p>
<div id="boxbox">
<div id="boxup"></div>
<div id="boxbg">
<div class="boxcontent">
<div class="sidep" style="padding: 10px;">
<div style="margin-bottom: 6px; border-bottom: 1px solid #dbdbdb;"><span style="font-weight: bold; color: #8ebe2d; font-size: 14px;">Voice Message</span></div>
<p><center><img class="alignleft size-full wp-image-912" title="&quot;Voice messages&quot; Message on Cell Phone Screen" src="http://www.ipragmatech.com/wp-content/uploads/2012/04/Voice-Message.jpg" alt="" width="220" height="147" /></center></p>
<ul>
<li>Monetize your community</li>
<li>Send and receive voice message</li>
<li>Easily customizable with any telephony vendor</li>
<li>Extensible support for SMS</li>
<li>No requirement for streaming server</li>
</ul>
</div>
</div>
</div>
<div id="boxdown"></div>
</div>
<p>We have been working on a module which allows socialengine community users to send recorded voice message on user mobile phone. In some countries there is limited access to internet due to their government policy though most of the people in those countries have access to mobile phone. So its easier for a community user to send voice message or song to their friends and relatives without requiring the access to internet.</p>
<p>We knew that it would be challenging job and the first task was to find out a solution to record the voice from a website. There were multiple solutions like implementing the client for audio streaming server like RED5 or Flash Media Server. Our client requirements was to record the voice message for 2-3 mins and adding audio streaming infrastructure was overkill. So we decided to use a very simple solution which allow us to record the voice and able to send it to our server. Luckily we found a wonderful open source <a title="jRecorder – jQuery plugin for audio recording" href="https://github.com/sythoos/jRecorder/" target="_blank">plugin</a> for voice recording by<a title="jRecorder – jQuery plugin for audio recording" href="http://www.sajithmr.me/jrecorder/" target="_blank"> sajith</a>. This plugin allow us to record the voice and also allow to review the recording.  This plugin also allow us to send the voice to the server in wave format. You can found many utilities for linux like <a title="FFmpeg is a complete, cross-platform solution to record, convert and stream audio and video. " href="http://ffmpeg.org/" target="_blank">ffmpeg</a> or  <a title="LAME is a high quality MPEG Audio Layer III (MP3) encoder" href="http://lame.sourceforge.net/" target="_blank">lame</a> which can easily convert the wav files to mp3.</p>
<p>There were some missing features &amp; bugs in the plugin. The main problem with the plugin was that it can&#8217;t work with any third party javascript&#8217;s framework other than jQuery. Since socialengine uses prototype as its javascript framework, the recording plugin didn&#8217;t worked at all.  The other major issue with the plugin was that you cannot add parameters on the fly to the server. The easy fix could be to make two calls, one for the file and other for other parameters. Also there was issue with this approach as callback for upload completion was not working properly. So we decided to fix those issues and contributed those fixes back to the project for the benefit of the socialengine community.</p>
<p><a href="http://www.ipragmatech.com/wp-content/uploads/2012/04/composemessage.png"><img class="alignleft size-full wp-image-906" title="Compose message" src="http://www.ipragmatech.com/wp-content/uploads/2012/04/composemessage.png" alt="Record your voice message" width="600" /></a></p>
<p>Now the next challenge was to send the voice message to the user&#8217;s actual device. There are many vendors which can provide telephony infrastructure to send the voice message to user&#8217;s device. So one can choose the appropriate vendor for the specific country. Our client decided to use <a title="Inicio" href="http://casiencuba.com/" target="_blank">casiencuba</a> to  send the voice message to the user&#8217;s device.</p>
<p>Now the last part of the challenge was to receive the voice mail from the user and publish it to socialengine. For this purpose, we exposed a service to vendor who can publish the voice message to the socialengine community. Once socialengine service gets the reply message from the vendor, voice mail plugin stores the information in the system. Community user is notified about the voice message and user shall be able to play the voice message.</p>
<p><a href="http://www.ipragmatech.com/wp-content/uploads/2012/04/listen-voice-mail.png"><img class="alignleft  wp-image-905" title="listen-voice-mail" src="http://www.ipragmatech.com/wp-content/uploads/2012/04/listen-voice-mail.png" alt="Listen to the voice message" width="600" /></a></p>
<p>This module is extensible enough to support the SMS feature as well. Feel free to contact us if you have any question or interested in customizing this module for your need.</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fvoice-message-socialengine.html&amp;linkname=Supercharge%20your%20socialengine%20with%20Voice%20Mail" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fvoice-message-socialengine.html&amp;linkname=Supercharge%20your%20socialengine%20with%20Voice%20Mail" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fvoice-message-socialengine.html&amp;linkname=Supercharge%20your%20socialengine%20with%20Voice%20Mail" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fvoice-message-socialengine.html&amp;linkname=Supercharge%20your%20socialengine%20with%20Voice%20Mail" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fvoice-message-socialengine.html&amp;linkname=Supercharge%20your%20socialengine%20with%20Voice%20Mail" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fvoice-message-socialengine.html&amp;linkname=Supercharge%20your%20socialengine%20with%20Voice%20Mail" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fvoice-message-socialengine.html&amp;linkname=Supercharge%20your%20socialengine%20with%20Voice%20Mail" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fvoice-message-socialengine.html&amp;linkname=Supercharge%20your%20socialengine%20with%20Voice%20Mail" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fvoice-message-socialengine.html&amp;title=Supercharge%20your%20socialengine%20with%20Voice%20Mail" id="wpa2a_10"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/voice-message-socialengine.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Configure Amazon Simple Email Service(SMTP/SSL) with Phpfox</title>
		<link>http://www.ipragmatech.com/phpfox-amazon-ses-smtp.html</link>
		<comments>http://www.ipragmatech.com/phpfox-amazon-ses-smtp.html#comments</comments>
		<pubDate>Sat, 07 Apr 2012 10:21:46 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Phpfox]]></category>

		<guid isPermaLink="false">http://www.ipragmatech.com/?p=889</guid>
		<description><![CDATA[In current post we are going to show you how to configure phpfox application to use amazon Simple Email Service as mail server. Recently we have been working on social community based on phpfox which is deployed on Amazon Elastic Compute Cloud. We shall be launching the community on 11th April 2012 and expected to [...]]]></description>
			<content:encoded><![CDATA[<p>In current post we are going to show you how to configure phpfox application to use amazon Simple Email Service as mail server. Recently we have been working on social community based on phpfox which is deployed on Amazon Elastic Compute Cloud. We shall be launching the community on 11th April 2012 and expected to receive fantastic response.We have been planning and getting prepared to get everything in place before launch day. We decided to use Amazon Simple Email Service (SES) for sending the email from phpfox system. This would allow use to delegate the email processing on different server and need not to maintain email server.</p>
<p>As the launch getting closer, we faced issues while configuring the SMTP server settings on phpfox. We entered the relevant information for mail server in the php mail settings but were facing issues like &#8216;AUTH not accepted from the server&#8217;.</p>
<p><a href="http://www.ipragmatech.com/wp-content/uploads/2012/04/SMTPError.png"><img class="alignleft size-full wp-image-892" title="SMTPError" src="http://www.ipragmatech.com/wp-content/uploads/2012/04/SMTPError.png" alt="" width="600" height="110" /></a></p>
<p><a href="http://www.ipragmatech.com/wp-content/uploads/2012/04/smtp_authentication-1.png"><img class="alignleft size-full wp-image-891" title="smtp_authentication-1" src="http://www.ipragmatech.com/wp-content/uploads/2012/04/smtp_authentication-1.png" alt="" width="600" height="400" /></a></p>
<p>We tried to find out the issue with phpfox documentation but could not found the solution though many people have complained about this solution.</p>
<p>So we decided to dig more into the source code and fix this issue. We were able to fix the issue by changing the source code of &#8216;class.phpmailer.php&#8217;. We just replaced the source</p>
<pre class="brush:php">public $SMTPSecure    = '';</pre>
<p>with</p>
<pre class="brush:php">public $SMTPSecure    = 'tls';</pre>
<p>After saving this change, we ere able to configure Amazon SES with phpfox. We think the same changes would also work with google smtp server.</p>
<p>We wish you have found this post useful and would help your community to use the power of SES for phpfox. Feel free to send us your suggestions or questions.</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox-amazon-ses-smtp.html&amp;linkname=Configure%20Amazon%20Simple%20Email%20Service%28SMTP%2FSSL%29%20with%20Phpfox" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox-amazon-ses-smtp.html&amp;linkname=Configure%20Amazon%20Simple%20Email%20Service%28SMTP%2FSSL%29%20with%20Phpfox" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox-amazon-ses-smtp.html&amp;linkname=Configure%20Amazon%20Simple%20Email%20Service%28SMTP%2FSSL%29%20with%20Phpfox" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox-amazon-ses-smtp.html&amp;linkname=Configure%20Amazon%20Simple%20Email%20Service%28SMTP%2FSSL%29%20with%20Phpfox" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox-amazon-ses-smtp.html&amp;linkname=Configure%20Amazon%20Simple%20Email%20Service%28SMTP%2FSSL%29%20with%20Phpfox" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox-amazon-ses-smtp.html&amp;linkname=Configure%20Amazon%20Simple%20Email%20Service%28SMTP%2FSSL%29%20with%20Phpfox" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox-amazon-ses-smtp.html&amp;linkname=Configure%20Amazon%20Simple%20Email%20Service%28SMTP%2FSSL%29%20with%20Phpfox" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox-amazon-ses-smtp.html&amp;linkname=Configure%20Amazon%20Simple%20Email%20Service%28SMTP%2FSSL%29%20with%20Phpfox" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox-amazon-ses-smtp.html&amp;title=Configure%20Amazon%20Simple%20Email%20Service%28SMTP%2FSSL%29%20with%20Phpfox" id="wpa2a_12"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/phpfox-amazon-ses-smtp.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>phpfox v3  performance optimization : Xcache or APC  or Memcached or File Cache</title>
		<link>http://www.ipragmatech.com/phpfox3-performance-xcache-apc-memcached.html</link>
		<comments>http://www.ipragmatech.com/phpfox3-performance-xcache-apc-memcached.html#comments</comments>
		<pubDate>Sat, 18 Feb 2012 15:03:42 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Performance Optimization]]></category>
		<category><![CDATA[Phpfox]]></category>

		<guid isPermaLink="false">http://www.ipragmatech.com/?p=839</guid>
		<description><![CDATA[Getting the best performance for website is always a challenge in the real time scenarios specially when you have hundreds of users on your website. As mentioned in our previous article, you loose potential users on website if your website doesn&#8217;t load with in few secs and very slow. We always try to get the [...]]]></description>
			<content:encoded><![CDATA[<p>Getting the best performance for website is always a challenge in the real time scenarios specially when you have hundreds of users on your website. As mentioned in our <a title="Optimize performance of your website" href="http://www.ipragmatech.com/optimize-performance-website.html">previous article</a>, you loose potential users on website if your website doesn&#8217;t load with in few secs and very slow. We always try to get the maximum performance of the website by fine tuning the configurations of the hardware resources, application platform and business logic (database queries) in the application.</p>
<p>In this article, we shall discuss about the opcode and caching solution for the phpfox v3 platform and performance of these solutions on constant user load. We have used apache&#8217;s benchmark tool for this purpose and results were eye opener.</p>
<div id="attachment_844" class="wp-caption alignleft" style="width: 630px"><a href="http://www.ipragmatech.com/wp-content/uploads/2012/02/performance-comparision-xcahce-apc-memcache.png"><img class="size-full wp-image-844" title="performance-comparision-xcahce-apc-memcache" src="http://www.ipragmatech.com/wp-content/uploads/2012/02/performance-comparision-xcahce-apc-memcache.png" alt="performance comparision xcahce apc memcache on phpfox v3" width="620" height="310" /></a><p class="wp-caption-text">performance comparision xcahce apc memcache on phpfox v3</p></div>
<p>For this Benchmark, we tested 1000 request on the home page with 10 concurrent users. We have run the apache&#8217;s tool at least 2-3 times and pick the best case for the particular scenario. We shall not cover the installation of these caching solutions in the article, If someone is interested then please take a look at our <a title="Increase performance and speed up socialengine using Memcached / APC /Xcache" href="http://www.ipragmatech.com/increase-performance-socialengine-memcache-apc-xcache.html" target="_blank">previous blog</a>. You can configure caching in phpfox3 as file cache and memcached as discussed in this <a title="How to enable Memcached" href="http://www.phpfox.com/kb/article/94/how-to-enable-memcached/" target="_blank">article</a>. Xcache and APC would be opcode caching solutions for phpfox v3.</p>
<p>For the testing purpose ,we kept the settings for apache webserver and mysql as default so result may be different in case these resources are optimized.Also there was minimal data on the website so result may also vary depending on the contents of the website.</p>
<h2>Testing Environment:</h2>
<ul>
<li>Operating System: 2.6.35.14-106.53.amzn1.x86_64</li>
<li>Web Server:  Apache/2.2.21 (Unix)</li>
<li>PHP: PHP 5.3.10</li>
<li>CPU: Intel(R) Xeon(R) CPU E5430  @ 2.66GHz</li>
<li>Main Memory: 7652592k</li>
</ul>
<h2>Test Results:</h2>
<p>Memcached</p>
<pre class="brush:shell">Concurrency Level:      10
Time taken for tests:   103.594 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      29972124 bytes
HTML transferred:       29559780 bytes
Requests per second:    9.65 [#/sec] (mean)
Time per request:       1035.940 [ms] (mean)
Time per request:       103.594 [ms] (mean, across all concurrent requests)
Transfer rate:          282.54 [Kbytes/sec] received</pre>
<p>APC</p>
<pre class="brush:shell">Concurrency Level:      10
Time taken for tests:   82.830 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      30110000 bytes
HTML transferred:       29696000 bytes
Requests per second:    12.07 [#/sec] (mean)
Time per request:       828.295 [ms] (mean)
Time per request:       82.830 [ms] (mean, across all concurrent requests)
Transfer rate:          355.00 [Kbytes/sec] received</pre>
<p>Xcache</p>
<pre class="brush:shell">Concurrency Level:      10
Time taken for tests:   86.303 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      30110000 bytes
HTML transferred:       29696000 bytes
Requests per second:    11.59 [#/sec] (mean)
Time per request:       863.026 [ms] (mean)
Time per request:       86.303 [ms] (mean, across all concurrent requests)
Transfer rate:          340.71 [Kbytes/sec] received</pre>
<p>Plain php</p>
<pre class="brush:shell">Concurrency Level:      10
Time taken for tests:   157.491 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      30110000 bytes
HTML transferred:       29696000 bytes
Requests per second:    6.35 [#/sec] (mean)
Time per request:       1574.913 [ms] (mean)
Time per request:       157.491 [ms] (mean, across all concurrent requests)
Transfer rate:          186.70 [Kbytes/sec] received</pre>
<h2>Conclusion</h2>
<p>As per our test cases, Both APC and Xcache provides a great performance boost to phpfox v3 than memcached/Simple File Cache (No Opcode) on a single machine. APC remain faster ~5% better than Xcache, ~25% better than memcached and ~90% better than plan php. So we think using either APC or Xcache shall boost the performance of your social community based on phpfox v3. If you have phpfox v3 running multiple servers then you should consider memcached as caching solution.</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox3-performance-xcache-apc-memcached.html&amp;linkname=phpfox%20v3%20%20performance%20optimization%20%3A%20Xcache%20or%20APC%20%20or%20Memcached%20or%20File%20Cache" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox3-performance-xcache-apc-memcached.html&amp;linkname=phpfox%20v3%20%20performance%20optimization%20%3A%20Xcache%20or%20APC%20%20or%20Memcached%20or%20File%20Cache" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox3-performance-xcache-apc-memcached.html&amp;linkname=phpfox%20v3%20%20performance%20optimization%20%3A%20Xcache%20or%20APC%20%20or%20Memcached%20or%20File%20Cache" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox3-performance-xcache-apc-memcached.html&amp;linkname=phpfox%20v3%20%20performance%20optimization%20%3A%20Xcache%20or%20APC%20%20or%20Memcached%20or%20File%20Cache" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox3-performance-xcache-apc-memcached.html&amp;linkname=phpfox%20v3%20%20performance%20optimization%20%3A%20Xcache%20or%20APC%20%20or%20Memcached%20or%20File%20Cache" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox3-performance-xcache-apc-memcached.html&amp;linkname=phpfox%20v3%20%20performance%20optimization%20%3A%20Xcache%20or%20APC%20%20or%20Memcached%20or%20File%20Cache" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox3-performance-xcache-apc-memcached.html&amp;linkname=phpfox%20v3%20%20performance%20optimization%20%3A%20Xcache%20or%20APC%20%20or%20Memcached%20or%20File%20Cache" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox3-performance-xcache-apc-memcached.html&amp;linkname=phpfox%20v3%20%20performance%20optimization%20%3A%20Xcache%20or%20APC%20%20or%20Memcached%20or%20File%20Cache" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fphpfox3-performance-xcache-apc-memcached.html&amp;title=phpfox%20v3%20%20performance%20optimization%20%3A%20Xcache%20or%20APC%20%20or%20Memcached%20or%20File%20Cache" id="wpa2a_14"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/phpfox3-performance-xcache-apc-memcached.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Email Newsletter Solution: Capture dynamic screenshots on server side</title>
		<link>http://www.ipragmatech.com/capture-screenshots-dynamic-server-rails.html</link>
		<comments>http://www.ipragmatech.com/capture-screenshots-dynamic-server-rails.html#comments</comments>
		<pubDate>Mon, 13 Feb 2012 15:34:00 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.ipragmatech.com/?p=814</guid>
		<description><![CDATA[Recently we were working on a dynamic contents generation for an email for one of our client in mobile advertisement domain. As we all know that every email client(MS Outlook,Mac Mail, Gmail etc) have their own support for the styles and html elements. Dynamically Captured Image Better Solution for news letter Used ImgKit Gem for [...]]]></description>
			<content:encoded><![CDATA[<p>Recently we were working on a dynamic contents generation for an email for one of our client in mobile advertisement domain. As we all know that every email client(MS Outlook,Mac Mail, Gmail etc) have their own support for the styles and html elements.</p>
<div id="boxbox">
<div id="boxup"></div>
<div id="boxbg">
<div class="boxcontent">
<div class="sidep" style="padding: 1px;"><center><img style="padding-bottom: 0px; padding-top: 0px; width: 235px;" src="http://www.ipragmatech.com/wp-content/uploads/2012/02/capture-screenshots-dynamic-server-rails.jpg" alt="Capture dynamic screenshots on server side" /></center></p>
<ul>
<li>Dynamically Captured Image</li>
<li>Better Solution for news letter</li>
<li>Used ImgKit Gem for rails</li>
</ul>
</div>
</div>
</div>
<div id="boxdown"></div>
</div>
<p>We found an <a href="http://www.campaignmonitor.com/css/">article</a> on google , which have detailed out the list of supported css/style in different email clients. There are some css support information which seems incorrect but overall conclusion is that it is very time consuming exercise to get proper/desired design of email content or sometime you might not get the desired results at all e.g. &#8216;radius&#8217; or &#8216;gradients&#8217; parameters are supported only in html5/css3/webkit.</p>
<p>As email is very crucial part of advertisement campaign as advertiser need to send their ad or deals through email newsletter. This requirement require some out of the box thinking skills so we started to find out some alternative of this css/style based ad. We heavily use webkit css/styles for advertisement components and those displayed perfectly fine on browsers like Firefox,Chrome or Safari but might not work on email clients. After lots of discussion among the team, we got an idea that to take the screenshots on the runtime and send this image in email content easily.</p>
<p>As we were working on <strong>ruby on rails</strong>, we got a gem <a title="IMGKIT" href="https://github.com/csquared/IMGKit" target="_blank">IMGKit</a>, which creates JPGs using plain old HTML+CSS. Imgkit uses <a href="http://github.com/antialize/wkhtmltopdf">wkhtmltoimage</a> on the backend which renders HTML using Webkit. ImgKit heavily based on <a href="http://github.com/jdpace/pdfkit/">PDFKit</a> . IMGKit is a great tool to convert HTML file/string into image and also supports css file/inline. You need to install wkhtmltoimage with IMGKit so we shall guide you to install the prerequisites and use the gem to generate image by rendering the html on the fly.</p>
<p><strong>Install:</strong></p>
<p>1. IMGKit:</p>
<pre class="brush:shell">gem install imgkit</pre>
<p>2. wkhtmltoimage:</p>
<p>Automatic:</p>
<pre class="brush:shell">sudo imgkit --install-wkhtmltoimage</pre>
<p>install latest version into /usr/local/bin</p>
<p>Manually : If you face any problem with install wkhtmltoimage by command then you can take latest binary from<br />
http://code.google.com/p/wkhtmltopdf/downloads/list and copy at location /usr/local/bin</p>
<p><strong>How To Use:</strong></p>
<pre class="brush:ruby"># IMGKit.new takes the HTML and any options for wkhtmltoimage
# run `wkhtmltoimage --extended-help` for a full list of options
kit = IMGKit.new(html, :quality =&gt; 50)
kit.stylesheets &lt;&lt; '/path/to/css/file'

# Get the image BLOB
img = kit.to_img
# New in 1.3!
img = kit.to_img(:jpg)      #default
img = kit.to_img(:jpeg)
img = kit.to_img(:png)
img = kit.to_img(:tif)
img = kit.to_img(:tiff)

# Save the image to a file
file = kit.to_file('/path/to/save/file.jpg')
file = kit.to_file('/path/to/save/file.png')

# IMGKit.new can optionally accept a URL or a File.
# Stylesheets can not be added when source is provided as a URL of File.
kit = IMGKit.new('http://google.com')
kit = IMGKit.new(File.new('/path/to/html'))

# Add any kind of option through meta tags
IMGKit.new('&lt;html&gt;&lt;head&gt;&lt;meta name="imgkit-quality" content="75"...

# Format shortcuts - New in 1.3!
IMGKit.new("hello").to_jpg
IMGKit.new("hello").to_jpeg
IMGKit.new("hello").to_png
IMGKit.new("hello").to_tif
IMGKit.new("hello").to_tiff</pre>
<p><strong>Rails Controller Actions</strong></p>
<pre class="brush:ruby">@kit = IMGKit.new(render_to_string) # we can use also Html string

format.jpg do
send_data(@kit.to_jpg, :type =&gt; "image/jpeg", :disposition =&gt; 'inline')
end</pre>
<p>&nbsp;</p>
<p>After doing all this set up, IMGKIT was working fine and generating great image from html.But for some cases it was showing an error <strong>&#8220;QPixmap: Cannot create a QPixmap when no GUI is being used&#8221;</strong>. Then we tried to find the reason and got that it was happening only for those html which have translate-gradiant(css property). This issue is also listed at <a href="http://code.google.com/p/wkhtmltopdf/issues/detail?id=730#makechanges " target="_blank">here</a> and several people are facing this issue. Then we got that there is an issue with binary of wkhtmltoimage(V 0.11.rc1), we recompiled the latest <a href="http://code.google.com/p/wkhtmltopdf/downloads/list" target="_blank">source code</a> and this time it was working fine for all cases. You can also try wkhtmltoimage(V 0.10.0_rc2) ,this binary also have this fix and works fine.</p>
<p>We would like to have your feedback and would like to answers your query.</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcapture-screenshots-dynamic-server-rails.html&amp;linkname=Email%20Newsletter%20Solution%3A%20Capture%20dynamic%20screenshots%20on%20server%20side" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcapture-screenshots-dynamic-server-rails.html&amp;linkname=Email%20Newsletter%20Solution%3A%20Capture%20dynamic%20screenshots%20on%20server%20side" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcapture-screenshots-dynamic-server-rails.html&amp;linkname=Email%20Newsletter%20Solution%3A%20Capture%20dynamic%20screenshots%20on%20server%20side" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcapture-screenshots-dynamic-server-rails.html&amp;linkname=Email%20Newsletter%20Solution%3A%20Capture%20dynamic%20screenshots%20on%20server%20side" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcapture-screenshots-dynamic-server-rails.html&amp;linkname=Email%20Newsletter%20Solution%3A%20Capture%20dynamic%20screenshots%20on%20server%20side" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcapture-screenshots-dynamic-server-rails.html&amp;linkname=Email%20Newsletter%20Solution%3A%20Capture%20dynamic%20screenshots%20on%20server%20side" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcapture-screenshots-dynamic-server-rails.html&amp;linkname=Email%20Newsletter%20Solution%3A%20Capture%20dynamic%20screenshots%20on%20server%20side" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcapture-screenshots-dynamic-server-rails.html&amp;linkname=Email%20Newsletter%20Solution%3A%20Capture%20dynamic%20screenshots%20on%20server%20side" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fcapture-screenshots-dynamic-server-rails.html&amp;title=Email%20Newsletter%20Solution%3A%20Capture%20dynamic%20screenshots%20on%20server%20side" id="wpa2a_16"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/capture-screenshots-dynamic-server-rails.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tweaks to resolve xcache and fastcgi issue for socialengine</title>
		<link>http://www.ipragmatech.com/xcache-fastcgi-apache-socialengine.html</link>
		<comments>http://www.ipragmatech.com/xcache-fastcgi-apache-socialengine.html#comments</comments>
		<pubDate>Sat, 11 Feb 2012 09:54:18 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Performance Optimization]]></category>
		<category><![CDATA[Social Engine]]></category>

		<guid isPermaLink="false">http://www.ipragmatech.com/?p=789</guid>
		<description><![CDATA[We have been constantly working on performance optimization of social community based on socialengine platform. The community was optimized by fine tuning Webserver (Apache) and database (Mysql) along with the caching(APC). Our client was really happy with the performance of his social community website.Client&#8217;s community is amazing and becoming very popular (growing 1000+ users/week) so [...]]]></description>
			<content:encoded><![CDATA[<p>We have been constantly working on performance optimization of social community based on socialengine platform. The community was optimized by fine tuning Webserver (Apache) and database (Mysql) along with the caching(APC). Our client was really happy with the performance of his social community website.Client&#8217;s community is amazing and becoming very popular (growing 1000+ users/week) so we have to fine tune the site further in order to take up the load of growing users. So we decided to boost the site using more optimized alternatives.</p>
<div id="boxbox">
<div id="boxup"></div>
<div id="boxbg">
<div class="boxcontent">
<div class="sidep" style="padding: 1px;"><center><img style="padding-bottom: 0px; padding-top: 0px; width: 235px;" src="http://www.ipragmatech.com/wp-content/uploads/2012/02/xcache-performance-e1328967414538.jpg" alt="SocialEngine Performance with Xcache and fastcgi" /></center></p>
<ul>
<li>Authentication issue with xcache using fastcgi on apache2</li>
<li>Simple hack to resolve the issue</li>
</ul>
</div>
</div>
</div>
<div id="boxdown"></div>
</div>
<p>We configured the apache server with fastcgi module and powered it with the alternative FastCGI processor manager PHP-FPM.Socialengine community performance improved and was able to take up 200 concurrent users without any glitches or without compromising the loading time. We decided to replace the APC with Xcache(1.3.2-2) as later caching performs better than the earlier caching solution. Please feel free to take a look at our previous <a title="Increase performance and speed up socialengine using Memcached / APC /Xcache" href="http://www.ipragmatech.com/increase-performance-socialengine-memcache-apc-xcache.html" target="_blank">blog</a> which helps you to install APC, Xcache and MemCache for your socialengine.</p>
<p>Social Community had no issues once it was configured with Xcache but there were issues while editing the language phrases in the Admin control panel.The page kept on prompting for the authentication for Xcache Administration even if we entered the correct credentials. We even tried to set the authentication flag(<em>xcache</em>.<em>admin</em>.auth=off) but it kept on prompting for the authentication. We found the temporarily work around to resolve this issue by putting socialengine in development mode while making the changes for phrases. Well the issue was that the community have many online users all the time and putting socialengine on development mode would have affected the site&#8217;s performance.</p>
<p>So we decided to dig further and found that the xcache, for some reason, doesn&#8217;t validate the credentials for fastcgi module. We found a little post on google in which some user mentioned the hack to get rid of the Xcache authentication. So we wanted to share that with you guys as well.</p>
<p>You need to download latest xcache from the site (Assuming you already have installed Xcache)</p>
<pre class="brush:shell">yum remove php53u-xcache
wget http://xcache.lighttpd.net/pub/Releases/1.3.2/xcache-1.3.2.tar.gz
tar xzvf xcache-1.3.2.tar.gz
cd xcache-1.3.2
vi xcache.c</pre>
<p>and change the code from</p>
<pre class="brush:cpp">/* auth disabled, nothing to do.. */
        if (!XG(auth_enabled)) {
                return 1;
        }</pre>
<p>to</p>
<pre class="brush:cpp">/* auth disabled, nothing to do.. */
        if (1 || !XG(auth_enabled)) {
                return 1;
        }

Once you are done with the changes, then you need to recompile and install it again</pre>
<pre class="brush:shell">phpize
./configure --enable-xcache
make
make install
cd /etc/php.d/
mv xcache.ini.rpmsave xcache.ini</pre>
<p>Now you need to add basic authentication in the apache configuration file to make Xcache administration more secure. Please google and found a way to add basic authentication.<br />
Feel free to send us your questions or issues related to socialengine, we would be happy to answer them.</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fxcache-fastcgi-apache-socialengine.html&amp;linkname=Tweaks%20to%20resolve%20xcache%20and%20fastcgi%20issue%20for%20socialengine" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fxcache-fastcgi-apache-socialengine.html&amp;linkname=Tweaks%20to%20resolve%20xcache%20and%20fastcgi%20issue%20for%20socialengine" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fxcache-fastcgi-apache-socialengine.html&amp;linkname=Tweaks%20to%20resolve%20xcache%20and%20fastcgi%20issue%20for%20socialengine" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fxcache-fastcgi-apache-socialengine.html&amp;linkname=Tweaks%20to%20resolve%20xcache%20and%20fastcgi%20issue%20for%20socialengine" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fxcache-fastcgi-apache-socialengine.html&amp;linkname=Tweaks%20to%20resolve%20xcache%20and%20fastcgi%20issue%20for%20socialengine" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fxcache-fastcgi-apache-socialengine.html&amp;linkname=Tweaks%20to%20resolve%20xcache%20and%20fastcgi%20issue%20for%20socialengine" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fxcache-fastcgi-apache-socialengine.html&amp;linkname=Tweaks%20to%20resolve%20xcache%20and%20fastcgi%20issue%20for%20socialengine" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fxcache-fastcgi-apache-socialengine.html&amp;linkname=Tweaks%20to%20resolve%20xcache%20and%20fastcgi%20issue%20for%20socialengine" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fxcache-fastcgi-apache-socialengine.html&amp;title=Tweaks%20to%20resolve%20xcache%20and%20fastcgi%20issue%20for%20socialengine" id="wpa2a_18"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/xcache-fastcgi-apache-socialengine.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Customize signup process for socialengine 4</title>
		<link>http://www.ipragmatech.com/custom-user-signup-socialengine.html</link>
		<comments>http://www.ipragmatech.com/custom-user-signup-socialengine.html#comments</comments>
		<pubDate>Mon, 21 Nov 2011 15:28:37 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Social Engine]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=426</guid>
		<description><![CDATA[We encountered many challenges while migrating the older socialengine version to latest socialengine version specially when the previous code was developed by novice developers team. We had the challenge to display users fields in wizard rather than a single page. Also since the previous developers didn&#8217;t break the fileds in steps and user data was already populated, [...]]]></description>
			<content:encoded><![CDATA[<p>We encountered many challenges while migrating the older socialengine version to latest socialengine version specially when the previous code was developed by novice developers team. We had the challenge to display users fields in wizard rather than a single page. Also since the previous developers didn&#8217;t break the fileds in steps and user data was already populated, we could n&#8217;t create new steps for user signup.We had to fix the issue with the minimal changes. We added new steps for the user signup and customize them according to the requirements.We had customized user signup using the &#8216;order&#8217; property of the fields and displayed the fields in each steps according to the requirements.</p>
<p><strong>1. Default Sign up module:</strong> Socialengine has five default steps for signup and you can find them in engine4_user_signup table in DB . Here is the default table data:</p>
<div id="attachment_658" class="wp-caption aligncenter" style="width: 432px"><a title="The steps with the sequence displayed to new user" href="http://www.ipragmatech.com/wp-content/uploads/2011/11/signup.png" rel="lightbox"><img class="size-full wp-image-658" title="User Signup Steps" src="http://www.ipragmatech.com/wp-content/uploads/2011/11/signup.png" alt="The steps with the sequence displayed to new user" width="422" height="111" /></a><p class="wp-caption-text">The steps with the sequence displayed to new user</p></div>
<p>2. <strong>Add or Remove steps from Db</strong>: We can disable any default step by changing value in &#8216;enable&#8217; column. We have added two new steps after first step as:</p>
<div id="attachment_660" class="wp-caption aligncenter" style="width: 431px"><a title="Custom steps with the sequence displayed to new user" href="http://www.ipragmatech.com/wp-content/uploads/2011/11/newsignup.png" rel="lightbox"><img class="size-full wp-image-660" title="Custom signup steps" src="http://www.ipragmatech.com/wp-content/uploads/2011/11/newsignup.png" alt="" width="421" height="146" /></a><p class="wp-caption-text">Custom steps with the sequence displayed to new user</p></div>
<p><strong>3. Create Plugins for new steps :</strong> Now we jump into the source code and do the real work.We just need to create two new plugins for two new steps, we have created two new plugins:<br />
a. User_Plugin_Signup_KidspotFields<br />
b. User_Plugin_Signup_MumsSaysFields</p>
<p>In user -&gt; Plugin -&gt; Signup. You can take the code from default plugin User_Plugin_Signup_Fields and just need to change upper declaration of form and page.</p>
<p>We used:<br />
<strong>a. User_Plugin_Signup_KidspotFields: </strong></p>
<pre class="brush:php">protected $_formClass = 'User_Form_Signup_KidspotFields';

protected $_script = array('signup/form/kidspotfields.tpl', 'user');</pre>
<p><span style="font-family: monospace;"><br />
</span></p>
<p><strong>b. User_Plugin_Signup_MumsSaysFields: </strong><br />
<code></code></p>
<pre class="brush:php">protected $_formClass = 'User_Form_Signup_MumsSayFields';

protected $_script = array('signup/form/mumssayfields.tpl', 'user');</pre>
<p><code><br />
</code><br />
Rest of the part of code would be same as User_Plugin_Signup_Fields.</p>
<p><strong>4. Create new forms and Pages:</strong> we need to create new forms and view pages for it.<br />
Forms: &#8216;User_Form_Signup_KidspotFields’ and &#8216;User_Form_Signup_MumsSayFields&#8217;</p>
<p>View Pages: &#8216;signup/form/kidspotfields.tpl&#8217; and &#8216;signup/form/mumssayfields.tpl&#8217;</p>
<p>You can implement view(.tpl) file according to your need or just add &#8211;</p>
<pre class="brush:php">form-&gt;render($this)</pre>
<p><span style="font-family: monospace;"><br />
</span> to show only form part.</p>
<p><strong>5. Final step:</strong> Now, we want to implement form for new steps.We need to create our own generate function instead of default generate function.</p>
<p>Here we wanted to show to total 80 profile fields into two pages. First page(&#8216;User_Form_Signup_KidspotFields) would have 48 fields and second page(&#8216;User_Form_Signup_MumsSayFields) would have 48-80 fields.</p>
<p>Here is the generate function for &#8216;User_Form_Signup_KidspotFields:<br />
<code></code></p>
<pre class="brush:php">public function generate()
{
$struct = $this-&gt;getFieldStructure();

$orderIndex = 0;

foreach( $struct as $fskey =&gt; $map )
{

$field = $map-&gt;getChild();

// Skip fields hidden on signup
if( isset($field-&gt;show) &amp;&amp; !$field-&gt;show &amp;&amp; $this-&gt;_isCreation ) {
continue;
}

// Add field and load options if necessary
$params = $field-&gt;getElementParams($this-&gt;getItem());

//$key = 'field_' . $field-&gt;field_id;
$key = $map-&gt;getKey();

// If value set in processed values, set in element
if( !empty($this-&gt;_processedValues[$field-&gt;field_id]) )
{
$params['options']['value'] = $this-&gt;_processedValues[$field-&gt;field_id];
}

if( !@is_array($params['options']['attribs']) ) {
$params['options']['attribs'] = array();
}

// Heading
if( $params['type'] == 'Heading' )
{
$params['options']['value'] = Zend_Registry::get('Zend_Translate')-&gt;_($params['options']['label']);
unset($params['options']['label']);
}

// Order
// @todo this might cause problems, however it will prevent multiple orders causing elements to not show up
$params['options']['order'] = $orderIndex++;

$inflectedType = Engine_Api::_()-&gt;fields()-&gt;inflectFieldType($params['type']);
unset($params['options']['alias']);
unset($params['options']['publish']);

//********************************************************
// here is the line where we would add a check for numbers of fields
if($orderIndex &lt; 48) {

$this-&gt;addElement($inflectedType, $key, $params['options']);

$element = $this-&gt;getElement($key);

if( method_exists($element, 'setFieldMeta') ) {
$element-&gt;setFieldMeta($field);
}

// Set attributes for hiding/showing fields using javscript
$classes = 'field_container field_'.$map-&gt;child_id.' option_'.$map-&gt;option_id.' parent_'.$map-&gt;field_id;
$element-&gt;setAttrib('class', $classes);

//
if( $field-&gt;canHaveDependents() ) {
$element-&gt;setAttrib('onchange', 'changeFields(this)');
}

// Set custom error message
if($field-&gt;error){
$element-&gt;addErrorMessage($field-&gt;error);
}

if( $field-&gt;isHeading() )
{
$element-&gt;removeDecorator('Label')
-&gt;removeDecorator('HtmlTag')
-&gt;getDecorator('HtmlTag2')-&gt;setOption('class', 'form-wrapper-heading');
}
}
}

$this-&gt;addElement('Button', 'submit', array(
'label' =&gt; 'Continue',
'type' =&gt; 'submit',
'order' =&gt; 10000,
));
}</pre>
<p><code><br />
</code></p>
<p>You can check the highlighted line of function <strong>if($orderIndex &lt; 48)</strong>, here we added to show first 48 fields.<br />
You need to add this function in &#8216;User_Form_Signup_MumsSayFields also, but we need to change a line to show fields from 48 to 80. Here is code:</p>
<p>&nbsp;</p>
<pre class="brush:php">if($orderIndex &gt;= 48 &amp;&amp; ($orderIndex &lt; 80)</pre>
<p><span style="font-family: monospace;"><br />
</span></p>
<p>So this is the procedure we followed and were able to show signup wizard with minimum changes in the socialengine platform. Here are the screenshots after the customizing the signup steps.</p>

<a href='http://www.ipragmatech.com/custom-user-signup-socialengine.html/signup-step1-2' title='Default step of user sign up in socialengine'><img width="106" height="150" src="http://www.ipragmatech.com/wp-content/uploads/2011/11/signup-step11.png" class="attachment-thumbnail" alt="Default step of user sign up in socialengine" title="Default step of user sign up in socialengine" /></a>
<a href='http://www.ipragmatech.com/custom-user-signup-socialengine.html/signup-step2-2' title='First part of our custom user sign up process'><img width="37" height="150" src="http://www.ipragmatech.com/wp-content/uploads/2011/11/signup-step21.png" class="attachment-thumbnail" alt="First part of our custom user sign up process" title="First part of our custom user sign up process" /></a>
<a href='http://www.ipragmatech.com/custom-user-signup-socialengine.html/signup-step3' title='Second part of our custom user sign up process'><img width="82" height="150" src="http://www.ipragmatech.com/wp-content/uploads/2011/11/signup-step3.png" class="attachment-thumbnail" alt="Second part of our custom user sign up process" title="Second part of our custom user sign up process" /></a>

<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-user-signup-socialengine.html&amp;linkname=Customize%20signup%20process%20for%20socialengine%204" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-user-signup-socialengine.html&amp;linkname=Customize%20signup%20process%20for%20socialengine%204" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-user-signup-socialengine.html&amp;linkname=Customize%20signup%20process%20for%20socialengine%204" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-user-signup-socialengine.html&amp;linkname=Customize%20signup%20process%20for%20socialengine%204" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-user-signup-socialengine.html&amp;linkname=Customize%20signup%20process%20for%20socialengine%204" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-user-signup-socialengine.html&amp;linkname=Customize%20signup%20process%20for%20socialengine%204" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-user-signup-socialengine.html&amp;linkname=Customize%20signup%20process%20for%20socialengine%204" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-user-signup-socialengine.html&amp;linkname=Customize%20signup%20process%20for%20socialengine%204" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-user-signup-socialengine.html&amp;title=Customize%20signup%20process%20for%20socialengine%204" id="wpa2a_20"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/custom-user-signup-socialengine.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Event Calendar : SocialEngine</title>
		<link>http://www.ipragmatech.com/event-calendar-socialengine.html</link>
		<comments>http://www.ipragmatech.com/event-calendar-socialengine.html#comments</comments>
		<pubDate>Sat, 19 Nov 2011 10:24:56 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Social Engine]]></category>

		<guid isPermaLink="false">http://www.ipragmatech.com/?p=435</guid>
		<description><![CDATA[Events module is vital part of the socialengine and gives members the ability to easily invite members of the community to their events, and track their attendance.The only thing missing in the social engine module is displaying the events in the monthly Calendar.We customized the event module and created the Calendar interface for the events. [...]]]></description>
			<content:encoded><![CDATA[<p>Events module is vital part of the socialengine and gives members the ability to easily invite members of the community to their events, and track their attendance.The only thing missing in the social engine module is displaying the events in the monthly Calendar.We customized the event module and created the Calendar interface for the events.</p>
<h3>Features</h3>
<ul>
<li>Displays events as a list or within a calendar grid</li>
<li>Calendar grids can have the ability to change the month displayed</li>
<li>Accessibility to for events</li>
</ul>
<div id="attachment_638" class="wp-caption aligncenter" style="width: 530px"><a title="Displays events as a list or within a calendar grid" href="http://www.ipragmatech.com/wp-content/uploads/2011/11/SocialEngine-Event-Calendar.png" rel="lightbox"><img class="size-full wp-image-638" title="SocialEngine-Event-Calendar" src="http://www.ipragmatech.com/wp-content/uploads/2011/11/SocialEngine-Event-Calendar-e1321692498545.png" alt="Displays events as a list or within a calendar grid" width="520" height="431" /></a><p class="wp-caption-text">Displays events as a list or within a calendar grid</p></div>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fevent-calendar-socialengine.html&amp;linkname=Event%20Calendar%20%3A%20SocialEngine" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fevent-calendar-socialengine.html&amp;linkname=Event%20Calendar%20%3A%20SocialEngine" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fevent-calendar-socialengine.html&amp;linkname=Event%20Calendar%20%3A%20SocialEngine" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fevent-calendar-socialengine.html&amp;linkname=Event%20Calendar%20%3A%20SocialEngine" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fevent-calendar-socialengine.html&amp;linkname=Event%20Calendar%20%3A%20SocialEngine" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fevent-calendar-socialengine.html&amp;linkname=Event%20Calendar%20%3A%20SocialEngine" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fevent-calendar-socialengine.html&amp;linkname=Event%20Calendar%20%3A%20SocialEngine" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fevent-calendar-socialengine.html&amp;linkname=Event%20Calendar%20%3A%20SocialEngine" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fevent-calendar-socialengine.html&amp;title=Event%20Calendar%20%3A%20SocialEngine" id="wpa2a_22"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/event-calendar-socialengine.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Power mobile app using native iOS with HTML5</title>
		<link>http://www.ipragmatech.com/mobile-iOS-html5.html</link>
		<comments>http://www.ipragmatech.com/mobile-iOS-html5.html#comments</comments>
		<pubDate>Sat, 12 Nov 2011 18:23:08 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[iPhone & iPad]]></category>

		<guid isPermaLink="false">http://www.ipragmatech.com/?p=608</guid>
		<description><![CDATA[Many times we need integration between native iPhone application and a web application. This could be due to several reasons. One possibility is that you already have a web application and you can build a native application much quickly by leveraging some part of it. Second is that the web application has been built by [...]]]></description>
			<content:encoded><![CDATA[<p>Many times we need integration between native iPhone application and a web application. This could be due to several reasons. One possibility is that you already have a web application and you can build a native application much quickly by leveraging some part of it. Second is that the web application has been built by a third party and you would like to use it in your application. Example of this is the twitter application, where you can view a link directly inside the twitter application.<br />
Third very interesting case is when some third party just provides you a JavaScript API and no direct HTTP calls, for example routes between two places using Google Maps API. So the only way out is to call the JavaScript API from native application.</p>
<h2>Open Browser from App</h2>
<p>The simplest case is when you just want to open the browser from your application. You can do this by the function</p>
<pre class="brush:c++">// Create the URL string
NSString* urlString = [NSString stringWithFormat:@"http://maps.google.com/
maps?q=%@", @"india"];

// Launch the browser!
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];</pre>
<p>This is a very simple approach, however with several disadvantages. One is that your application is no longer running in the foreground. Also your application does not have any control over the web application that has been opened.</p>
<h2>Open link within app</h2>
<p>The next way is opening a link within the application. It is easily achieved by using a UIWebView as follows:</p>
<pre class="brush:cpp">// Create the web view
UIWebView* webView = [[UIWebView alloc] initWithURL:@"http://
maps.google.com/maps?q=%@", @"india"];</pre>
<p>This can be added to any view in your application. Now we can close the webview from our application when we need to. In addition, we get callbacks for page loading, link clicks and so on.</p>
<p>What if the integration is more complex? Imagine this scenario &#8211; the user clicks a button in the native application and you would like to call some JavaScript function in your web application. This is done by the following code:</p>
<pre class="brush:cpp">[webView stringByEvaluatingJavaScriptFromString:
@"alert('javascript called')"];</pre>
<p>Not only you can call any JavaScript functions available in the web page being displayed, but you can call any use any JavaScript string, or even submit forms. Now what if we need to get the result of some JavaScript called on the web page into our native application? If an alert is called in the JavaScript on the web page, and listening in the web view as follows.</p>
<pre class="brush:js">// In JavaScript
alert('send event')</pre>
<pre class="brush:cpp">// In native application

- (void)webView:(UIWebView *)webView
runJavaScriptAlertPanelWithMessage:(NSString *)message
initiatedByFrame:(id)frame {
NSLog(message);
}</pre>
<p>The above code would print Send Event.</p>
<p>You can use the same method to do a more generic version of interaction, if you need to do a call from the web view based on what you received from JavaScript.</p>
<pre class="brush:js">// In JavaScript
alert('callback();');</pre>
<pre class="brush:cpp">// In native application

- (void)webView:(UIWebView *)webView
runJavaScriptAlertPanelWithMessage:(NSString *)message
initiatedByFrame:(id)frame {
[webView stringByEvaluatingJavaScriptFromString: message];
}</pre>
<p>Since the message contains callback(), this function will be called on the JavaScript by the web view.</p>
<h2>Using JavaScript API</h2>
<p>Lastly we come to our interesting use case when there is only JavaScript APIs available from a third party. All you need to do is, create an HTML page which contains the functions and include it with your application. Open this HTML in web view as follows:</p>
<pre class="brush:cpp">NSString * nsstrPath = [ [ NSBundle mainBundle ] pathForResource :
@"MapsApi" ofType : @"html" ] ;
NSURL * nsURL = [ NSURL fileURLWithPath : nsstrPath ] ;
NSURLRequest * nsURLRequest = [ NSURLRequest requestWithURL : nsURL ] ;
[ webView loadRequest : nsURLRequest ] ;</pre>
<p>We hope this article shall help you creating mobile app using iOS and HTML5. We would love to hear your feedback so please feel free to add your comments. There are many <a title="10 Useful Frameworks To Develop HTML-Based Webapps for Touch Devices" href="http://woorkup.com/2010/08/25/10-useful-frameworks-to-develop-html-based-webapps-for-touch-devices/" target="_blank">frameworks </a>which can help you creating mobile app. We prefer <a title="Sencha Touch" href="http://www.sencha.com/products/touch/" target="_blank">Sencha touch </a>though.</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmobile-iOS-html5.html&amp;linkname=Power%20mobile%20app%20using%20native%20iOS%20with%20HTML5" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmobile-iOS-html5.html&amp;linkname=Power%20mobile%20app%20using%20native%20iOS%20with%20HTML5" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmobile-iOS-html5.html&amp;linkname=Power%20mobile%20app%20using%20native%20iOS%20with%20HTML5" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmobile-iOS-html5.html&amp;linkname=Power%20mobile%20app%20using%20native%20iOS%20with%20HTML5" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmobile-iOS-html5.html&amp;linkname=Power%20mobile%20app%20using%20native%20iOS%20with%20HTML5" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmobile-iOS-html5.html&amp;linkname=Power%20mobile%20app%20using%20native%20iOS%20with%20HTML5" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmobile-iOS-html5.html&amp;linkname=Power%20mobile%20app%20using%20native%20iOS%20with%20HTML5" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fmobile-iOS-html5.html&amp;linkname=Power%20mobile%20app%20using%20native%20iOS%20with%20HTML5" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fmobile-iOS-html5.html&amp;title=Power%20mobile%20app%20using%20native%20iOS%20with%20HTML5" id="wpa2a_24"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/mobile-iOS-html5.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Socialengine performance optimization : Nginx &#8211; Apache Combo</title>
		<link>http://www.ipragmatech.com/socialengine-performance-nginx-apache.html</link>
		<comments>http://www.ipragmatech.com/socialengine-performance-nginx-apache.html#comments</comments>
		<pubDate>Sat, 12 Nov 2011 11:47:23 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Performance Optimization]]></category>
		<category><![CDATA[Social Engine]]></category>

		<guid isPermaLink="false">http://www.ipragmatech.com/?p=439</guid>
		<description><![CDATA[In our last two articles Optimize performance of your website and Iincrease performance and speed up socialengine using Memcached / APC /Xcache, we discussed about the tips to improve the performance of the socialEngine or any of custom website. In this article, we shall improve the performance further by using Nginx &#8211; Apache Combo pack. [...]]]></description>
			<content:encoded><![CDATA[<p>In our last two articles <a title="Optimize performance of your website" href="http://www.ipragmatech.com/optimize-performance-website.html" target="_blank">Optimize performance of your website</a> and I<a title="Increase performance and speed up socialengine using Memcached / APC /Xcache" href="http://www.ipragmatech.com/increase-performance-socialengine-memcache-apc-xcache.html" target="_blank">increase performance and speed up socialengine using Memcached / APC /Xcache</a>, we discussed about the tips to improve the performance of the socialEngine or any of custom website. In this article, we shall improve the performance further by using Nginx &#8211; Apache Combo pack.</p>
<p>We were using the apache + mod php for the socialEngine for one of our clients. Initially when there were less user load then website used to perform well but as user load increases with the popularity of the website, site become slower and sometimes it used to crashed without giving any warning. It was very difficult to found the exact issue for the crash. Initially we suspected that the mysql (MariaDB) can be the main culprit but after installing munin, it become clear that the issue is with Apache. We investigated further and found that apache&#8217;s preform MPM uses multiple child processes with one thread each and each process handles one connection at a time. So this resulted in more memory usage for apache as more and more users visited the website.This resulted in system crash and we used to reboot the system manually.  We tried to fine tune the prefork parameters but site was still falling apart.</p>
<p>We had no clue what should we do to stop the site crash. Users started complaining about page not opening or taking too much time to open the page. We thought about moving the static contents (css/js/images) to different server or even though of using Amazon s3. After looking at the articles on google, we tried NGINX as <a href="http://httpd.apache.org/docs/2.0/mod/mod_proxy.html#forwardreverse">reverse proxy</a> for our Apache&#8217;s server. In this mode, NGINX looks like just another Web server to users. Behind the scenes, though the reverse proxy is used to load balance Web requests among several back-end servers, or to provide caching for a slower back-end server. This result in very fast and stable Web Site with same hardware.</p>
<div id="attachment_559" class="wp-caption aligncenter" style="width: 522px"><a title="There were spikes in the apache's access during the starting of September month when only Apache was used." href="http://www.ipragmatech.com/wp-content/uploads/2011/11/socialkidspot-apache.png" rel="lightbox"><img class="size-large wp-image-559 " title="socialkidspot-apache" src="http://www.ipragmatech.com/wp-content/uploads/2011/11/socialkidspot-apache-1024x557.png" alt="Apache performance with ngnix" width="512" height="280" /></a><p class="wp-caption-text">There were spikes in the apache&#39;s access during the starting of September month when only Apache was used.</p></div>
<p>Using NGINX as reverse proxy took the most of the load from apache server which resulted in fast and stable website. Earlier accesses/min used to reach ~5K and resulted in more apache&#8217;s processes thus more memory usage. Site is stable now as NGNIX handles static contents (js/css/images) while apache needs to process only php scripts.</p>
<div id="attachment_566" class="wp-caption aligncenter" style="width: 522px"><a title="Apache used to use 150 processes in month of September and resulted into site crash" href="http://www.ipragmatech.com/wp-content/uploads/2011/11/SocialKidspot-Processes.png" rel="lightbox"><img class="size-large wp-image-566 " title="SocialKidspot-Processes" src="http://www.ipragmatech.com/wp-content/uploads/2011/11/SocialKidspot-Processes-1024x624.png" alt="" width="512" height="312" /></a><p class="wp-caption-text">Apache used to use 150 processes in month of September and resulted into site crash</p></div>
<div id="attachment_560" class="wp-caption aligncenter" style="width: 522px"><a title="Memory usages reduced drastically after ngnix acting as reverse proxy" href="http://www.ipragmatech.com/wp-content/uploads/2011/11/socialkidspot-memory.png" rel="lightbox"><img class="size-large wp-image-560 " title="socialkidspot-memory" src="http://www.ipragmatech.com/wp-content/uploads/2011/11/socialkidspot-memory-1024x658.png" alt="" width="512" height="329" /></a><p class="wp-caption-text">Memory usages reduced drastically after ngnix acting as reverse proxy</p></div>
<div id="attachment_561" class="wp-caption aligncenter" style="width: 522px"><a title="NGINX can deliver 10 times the performance on the same hardware. NGINX is very fast and uses far less resources than Apache. It does this by being event-based. That means it doesn’t spawn new processes or threads for each Web page request. So even as the load increases, memory use remains predictable" href="http://www.ipragmatech.com/wp-content/uploads/2011/11/socialkispot-ngnix.png" rel="lightbox"><img class="size-large wp-image-561" title="socialkispot-ngnix" src="http://www.ipragmatech.com/wp-content/uploads/2011/11/socialkispot-ngnix-1024x558.png" alt="" width="512" height="280" /></a><p class="wp-caption-text">NGINX can deliver 10 times the performance on the same hardware. NGINX is very fast and uses far less resources than Apache. It does this by being event-based. That means it doesn’t spawn new processes or threads for each Web page request. So even as the load increases, memory use remains predictable</p></div>
<p>The performance can be further increased by using php-fpm or fast-cgi in apache instead of using mod-php or use ngnix+fast-cgi. We tried to follow these approaches but found some limitations with each approach with our requirements. We would love to know more approaches to improve performance of website so please don&#8217;t hesitate to comment.</p>
<p>References:</p>
<ul>
<li><a title="Apache and IIS’ Web server rival NGINX is growing fast" href="www.zdnet.com/blog/networking/apache-and-iis-web-server-rival-nginx-is-growing-fast/1538" target="_blank">Apache and IIS’ Web server rival NGINX is growing fast</a></li>
<li><a title="apache vs nginx web server performance deathmatch " href="http://joeandmotorboat.com/2008/02/28/apache-vs-nginx-web-server-performance-deathmatch/" target="_blank">Apache vs nginx web server performance deathmatch</a></li>
<li><a title="Using Nginx as reverse proxy" href="http://tumblr.intranation.com/post/766288369/using-nginx-reverse-proxy" target="_blank">Using Nginx as reverse proxy</a></li>
</ul>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialengine-performance-nginx-apache.html&amp;linkname=Socialengine%20performance%20optimization%20%3A%20Nginx%20%E2%80%93%20Apache%20Combo" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialengine-performance-nginx-apache.html&amp;linkname=Socialengine%20performance%20optimization%20%3A%20Nginx%20%E2%80%93%20Apache%20Combo" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialengine-performance-nginx-apache.html&amp;linkname=Socialengine%20performance%20optimization%20%3A%20Nginx%20%E2%80%93%20Apache%20Combo" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialengine-performance-nginx-apache.html&amp;linkname=Socialengine%20performance%20optimization%20%3A%20Nginx%20%E2%80%93%20Apache%20Combo" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialengine-performance-nginx-apache.html&amp;linkname=Socialengine%20performance%20optimization%20%3A%20Nginx%20%E2%80%93%20Apache%20Combo" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialengine-performance-nginx-apache.html&amp;linkname=Socialengine%20performance%20optimization%20%3A%20Nginx%20%E2%80%93%20Apache%20Combo" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialengine-performance-nginx-apache.html&amp;linkname=Socialengine%20performance%20optimization%20%3A%20Nginx%20%E2%80%93%20Apache%20Combo" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialengine-performance-nginx-apache.html&amp;linkname=Socialengine%20performance%20optimization%20%3A%20Nginx%20%E2%80%93%20Apache%20Combo" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fsocialengine-performance-nginx-apache.html&amp;title=Socialengine%20performance%20optimization%20%3A%20Nginx%20%E2%80%93%20Apache%20Combo" id="wpa2a_26"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/socialengine-performance-nginx-apache.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android Push Notification (C2DM) &#8211; Handle HTTP/1.1 401 Unauthorized and SERVICE_NOT_AVAILABLE Error</title>
		<link>http://www.ipragmatech.com/handle-error-unauthorized-service-not-available-android-push-notification-c2dm.html</link>
		<comments>http://www.ipragmatech.com/handle-error-unauthorized-service-not-available-android-push-notification-c2dm.html#comments</comments>
		<pubDate>Fri, 24 Jun 2011 06:58:23 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=431</guid>
		<description><![CDATA[In our last article,  We discussed about powering your android application with Android Push Notification (c2dm). We are sure some developers might have faced issues like SERVICE_NOT_AVAILABLE while getting the registrationId from the android app or Issue like HTTP/1.1 401 Unauthorized while sending android push notification to the C2DM google service. So here is our [...]]]></description>
			<content:encoded><![CDATA[<p>In our last <a href="http://www.ipragmatech.com/power-mobile-app-android-push-notification-c2dm.html">article</a>,  We discussed about powering your android application with Android Push Notification (c2dm). We are sure some developers might have faced issues like SERVICE_NOT_AVAILABLE while getting the registrationId from the android app or Issue like HTTP/1.1 401 Unauthorized while sending android push notification to the C2DM google service. So here is our checklist to handle these type of errors:</p>
<p>Handle HTTP/1.1 401 Unauthorized and SERVICE_NOT_AVAILABLE Error:</p>
<ul>
<li>Your &#8220;Role account email *&#8221; should be your google email account</li>
<li>Make sure your &#8220;Role account email *&#8221; was properly filed in the signup form</li>
<li>Setup your &#8220;Role account email *&#8221; in the emulator account once. This is not documented in the c2dm documentation but it worked like magic to get rid the error  HTTP/1.1 401 Unauthorized</li>
<li>In case you have setup you domain with google app (we enjoy google email and other services for our domain) then use option &#8220;GOOGLE_OR_HOSTED&#8221; OR &#8220;HOSTED&#8221; while generating Auth code.</li>
</ul>
<p>We hope using this checklist, you should be able to get rid of the error for android push notification (c2dm). Please feel free to send us your thoughts or questions.</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fhandle-error-unauthorized-service-not-available-android-push-notification-c2dm.html&amp;linkname=Android%20Push%20Notification%20%28C2DM%29%20%E2%80%93%20Handle%20HTTP%2F1.1%20401%20Unauthorized%20and%20SERVICE_NOT_AVAILABLE%20Error" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fhandle-error-unauthorized-service-not-available-android-push-notification-c2dm.html&amp;linkname=Android%20Push%20Notification%20%28C2DM%29%20%E2%80%93%20Handle%20HTTP%2F1.1%20401%20Unauthorized%20and%20SERVICE_NOT_AVAILABLE%20Error" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fhandle-error-unauthorized-service-not-available-android-push-notification-c2dm.html&amp;linkname=Android%20Push%20Notification%20%28C2DM%29%20%E2%80%93%20Handle%20HTTP%2F1.1%20401%20Unauthorized%20and%20SERVICE_NOT_AVAILABLE%20Error" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fhandle-error-unauthorized-service-not-available-android-push-notification-c2dm.html&amp;linkname=Android%20Push%20Notification%20%28C2DM%29%20%E2%80%93%20Handle%20HTTP%2F1.1%20401%20Unauthorized%20and%20SERVICE_NOT_AVAILABLE%20Error" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fhandle-error-unauthorized-service-not-available-android-push-notification-c2dm.html&amp;linkname=Android%20Push%20Notification%20%28C2DM%29%20%E2%80%93%20Handle%20HTTP%2F1.1%20401%20Unauthorized%20and%20SERVICE_NOT_AVAILABLE%20Error" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fhandle-error-unauthorized-service-not-available-android-push-notification-c2dm.html&amp;linkname=Android%20Push%20Notification%20%28C2DM%29%20%E2%80%93%20Handle%20HTTP%2F1.1%20401%20Unauthorized%20and%20SERVICE_NOT_AVAILABLE%20Error" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fhandle-error-unauthorized-service-not-available-android-push-notification-c2dm.html&amp;linkname=Android%20Push%20Notification%20%28C2DM%29%20%E2%80%93%20Handle%20HTTP%2F1.1%20401%20Unauthorized%20and%20SERVICE_NOT_AVAILABLE%20Error" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fhandle-error-unauthorized-service-not-available-android-push-notification-c2dm.html&amp;linkname=Android%20Push%20Notification%20%28C2DM%29%20%E2%80%93%20Handle%20HTTP%2F1.1%20401%20Unauthorized%20and%20SERVICE_NOT_AVAILABLE%20Error" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fhandle-error-unauthorized-service-not-available-android-push-notification-c2dm.html&amp;title=Android%20Push%20Notification%20%28C2DM%29%20%E2%80%93%20Handle%20HTTP%2F1.1%20401%20Unauthorized%20and%20SERVICE_NOT_AVAILABLE%20Error" id="wpa2a_28"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/handle-error-unauthorized-service-not-available-android-push-notification-c2dm.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Optimize performance of your website</title>
		<link>http://www.ipragmatech.com/optimize-performance-website.html</link>
		<comments>http://www.ipragmatech.com/optimize-performance-website.html#comments</comments>
		<pubDate>Sat, 21 May 2011 12:27:55 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[Performance Optimization]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=425</guid>
		<description><![CDATA[Slow website means losing users, so every website you have should be as responsive as possible. Usually optimize performance requires professionals to achieve it but there are some best practices related to contents of your website which can optimize the website. Website owner can also use tools like yslow or pagespeed to gauge the performance of their website and [...]]]></description>
			<content:encoded><![CDATA[<p>Slow website means losing users, so every website you have should be as responsive as possible. Usually optimize performance requires professionals to achieve it but there are some best practices related to contents of your website which can optimize the website. Website owner can also use tools like <a href="http://developer.yahoo.com/yslow/">yslow</a> or <a href="http://code.google.com/speed/page-speed/">pagespeed</a> to gauge the performance of their website and use some of the tips in this article. We are discussing below the best practices which can be used to get maximum performance from the  website.</p>
<p>In the <a href="http://www.ipragmatech.com/increase-performance-socialengine-memcache-apc-xcache.html">previous article</a>, we discussed about optimize performance of socialengine using caching system. In this article, we would discuss about optimize performance of any website by tunning server settings and following best practices for static contents. Using these tips can improve the speed of a website by 30%-70%.  Though we did this improvements for socialengine but these tips can be used for any custom built website built on on any technologies like JEE, Microsoft .NET, PHP or <strong>Ruby on Rails</strong>. We are sharing these tips so that anyone can optimize performance of their own website. We are more focusing on the checklist approach. You can get the details in references section at the end of this article.</p>
<p>Note: We had followed this approach while optimizing a socialengine 4 website for one of our client.</p>
<h2>Enable HTTP compression</h2>
<p>Compressing resources with gzip or deflate can reduce the number of bytes sent over the network. Most of the modern browser supports data compression for html, CSS and JavaScript. Downloading of compressed data shall reduce the downloading time and allows your website to open faster. You can easily enable the compression on apache web server by editing config file or changing .htaccess at the root of the application.</p>
<p>Using deflate module</p>
<pre class="brush:shell">&lt;ifmodule mod_deflate.c&gt;
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
&lt;/ifmodule&gt;</pre>
<p>or using gzip module</p>
<pre class="brush:shell">&lt;IfModule mod_gzip.c&gt;
    mod_gzip_on       Yes
    mod_gzip_dechunk  Yes
    mod_gzip_item_include file      \.(html?|txt|css|js|php|pl)$
    mod_gzip_item_include handler   ^cgi-script$
    mod_gzip_item_include mime      ^text/.*
    mod_gzip_item_include mime      ^application/x-javascript.*
    mod_gzip_item_exclude mime      ^image/.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
&lt;/IfModule&gt;</pre>
<h2>Add expires headers</h2>
<p>Adding expires headers do not affect the site load time for a first time visitor but you will be surprised how much the page load time decreases (faster page load) for subsequent page views/return visits from that visitor. Expires header specifies a time far enough in the future so that browsers won’t try to re-fetch images, CSS, javascript etc files that haven’t changed (this reduces the number of HTTP requests) and hence the performance improvement on subsequent page views.<br />
To add expires header to the image, CSS, javascript files add the following to your .htaccess file</p>
<pre class="brush:shell">#Expire Header
&lt;FilesMatch "\.(ico|jpg|jpeg|png|gif|js|css|swf)"&gt;
ExpiresDefault "access plus 2 hours"
&lt;/FilesMatch&gt;
or
# Expire images header
ExpiresActive On
ExpiresDefault A0
ExpiresByType image/gif A2592000
ExpiresByType image/png A2592000
ExpiresByType image/jpg A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/ico A2592000
ExpiresByType text/css A2592000
ExpiresByType text/javascript A2592000</pre>
<h2>Minify and combine javascripts</h2>
<p>Removing extra spaces, line break, indentation, comments from the files can reduce size of the file and enabling faster downloading. There are tools like <a href="http://www.crockford.com/javascript/jsmin.html">JSMin</a> or the <a href="http://developer.yahoo.com/yui/compressor/">YUI Compressor</a> which can be used to minify the javascripts.  Combining multiple javascripts in one file shall allow better compression and lesser http threads from the browser thus other resource can be downloaded in parallel.</p>
<h2>Minify and combine css</h2>
<p>Minifying CSS has the same benefits as those for minifying JS: reducing network latency, enhancing compression, and faster browser loading and execution.Several tools are freely available to minify JavaScript, including the <a href="http://developer.yahoo.com/yui/compressor/">YUI Compressor</a> and <a href="http://www.phpied.com/cssmin-js/">cssmin.js</a></p>
<h2>Use Google&#8217;a AJAX Libraries API or Yahoo&#8217;s ComboHandler</h2>
<p>Yahoo’s <a href="http://yuiblog.com/blog/2008/07/16/combohandler/" rel="nofollow">Combo Handler</a> and Google’s <a href="http://code.google.com/apis/ajaxlibs/" rel="nofollow">AJAX Libraries API</a> both serve content from their CDNs and potentially increase the chance that your visitors will already have a file in their browser cache. Neither service serves custom content that you provide. You may wish to use these services to serve popular libraries and Minify to serve your code.</p>
<h2>Optimize image size</h2>
<p>Use the resized image that fix the content of the page rather than resizing it in the image tag e.g. if you wanted to display 60&#215;60 image while original image size is 480&#215;480 then some developer tries to make change in the image tag by defining the dimensions.Using smaller image at this place would allow faster loading of the image as smaller image size would be much lesser than the original image size. Optimize the image by reducing the unnecessary bytes from the image. There are many  tools like <a href="http://www.smushit.com/ysmush.it/">smushit</a> or <a href="http://www.gimp.org/">GIMP</a> which can you used to optimize the images.</p>
<h2>Use css image sprite</h2>
<p>CSS sprites are a way to reduce the number of HTTP requests made for image resources referenced by your site. With this style, images are combined into one larger image at defined X and Y coordinates. There are many tools like <a title="Sprite Me" href="http://spriteme.org/" rel="nofollow">SpriteMe</a> and <a title="Sprite Creator" href="http://www.floweringmind.com/sprite-creator/" rel="nofollow">Sprite Creator</a> which can help you to create sprite of the images and generate css for them.</p>
<h2 id="ServeFromCookielessDomain">Serve static content from a cookieless domain</h2>
<p>Static content, such as images, JS and CSS files, don&#8217;t need to be accompanied by cookies, as there is no user interaction with these resources. You can decrease request latency by serving static resources from a domain that doesn&#8217;t serve cookies. This technique is especially useful for pages referencing large volumes of rarely cached static content, such as frequently changing image thumbnails, or infrequently accessed image archives. We recommend this technique for any page that serves more than 5 static resources. You can use put your contents in separate server(may be subdomain) or file storage service like Amazon S3.</p>
<h2>Use alternative web server</h2>
<p>There are plenty more good alternatives for the Apache web server, so if you have a more specialized need, take a look at them, maybe you’ll find something that suits you better. Many of these alternative web servers are free to use. Nearly all offer a lightweight, highly scalable server solution. Some even outperform Apache. The 5 web servers we will be looking at as real alternatives to Apache are:</p>
<ul>
<li>Nginx</li>
<li>LiteSpeed</li>
<li>Lighttpd</li>
<li>Hiawatha</li>
<li>Cherokee</li>
</ul>
<p>Please feel free to send your suggestions or any other technique which can improve website speed.</p>
<h2>References:</h2>
<ul>
<li><a href="http://code.google.com/speed/page-speed/docs/rules_intro.html">Web Performance Best Practices</a></li>
<li><a href="http://www.parorrey.com/blog/webmaster-tasks/enabling-gzip-compression-on-your-website-on-apache-via-htaccess/">Enabling gzip, deflate compression on your website on apache via .htaccess</a></li>
<li><a href="http://slodive.com/web-development/lightweight-alternatives-to-apache-and-iis-web-servers/">5 Lightweight Alternatives to Apache and IIS Web Servers</a></li>
</ul>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Foptimize-performance-website.html&amp;linkname=Optimize%20performance%20of%20your%20website" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Foptimize-performance-website.html&amp;linkname=Optimize%20performance%20of%20your%20website" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Foptimize-performance-website.html&amp;linkname=Optimize%20performance%20of%20your%20website" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Foptimize-performance-website.html&amp;linkname=Optimize%20performance%20of%20your%20website" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Foptimize-performance-website.html&amp;linkname=Optimize%20performance%20of%20your%20website" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Foptimize-performance-website.html&amp;linkname=Optimize%20performance%20of%20your%20website" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Foptimize-performance-website.html&amp;linkname=Optimize%20performance%20of%20your%20website" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Foptimize-performance-website.html&amp;linkname=Optimize%20performance%20of%20your%20website" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Foptimize-performance-website.html&amp;title=Optimize%20performance%20of%20your%20website" id="wpa2a_30"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/optimize-performance-website.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Power your mobile apps with android push notification (C2DM)</title>
		<link>http://www.ipragmatech.com/power-mobile-app-android-push-notification-c2dm.html</link>
		<comments>http://www.ipragmatech.com/power-mobile-app-android-push-notification-c2dm.html#comments</comments>
		<pubDate>Sat, 14 May 2011 18:43:45 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=408</guid>
		<description><![CDATA[Recently we were working on android application and we had requirements from our client to support push notification. We already had implemented Apple Push Notification Service for the iPhone application and thought there would be similar solution for android push too.  As android platform doesn&#8217;t have single vendor like Apple so we were wondering who [...]]]></description>
			<content:encoded><![CDATA[<p>Recently we were working on android application and we had requirements from our client to support push notification. We already had implemented Apple Push Notification Service for the iPhone application and thought there would be similar solution for android push too.  As android platform doesn&#8217;t have single vendor like Apple so we were wondering who would support it. There are many custom build solutions based on application polling or asynchronous connection to server but timing of these event was tricky part plug they is additional usage of network resource and battery.</p>
<p>Welcome to the world of  &#8217;Cloud to Device Messaging&#8217; or C2DM supported by google services. This solution provides a  solution to send real time notification to the user on user&#8217;s handset. Since Google already uses its service for Calendar or gmail etc. on the android platform so there won&#8217;t be extra network usage or battery usage for c2dm.</p>
<p>There are plenty of excellent articles which explain working on C2DM push notification and provide sample code to Run. We feel some points were missing or not obvious in those articles specially when you are not aware of Push Notification concept. Also there is no default notification implementation on Android platform. So we decided to fill in the gap and allow developers to quickly run a sample android push application and recieve the push notification from third party server.</p>
<p>For this purpose, we created a sample application which registers the device to google service and send the registrationId to the our own third party server. The sample application displays the notification screen whenever a push notification is received by android application. You can find many server-side solutions for scripting language like php,shell script using curl etc. Since most of the enterprise applications run on J2EE platform so we decided to have a J2EE server-side solution. In our server-side implementation, you can regsiter device with registerId, view list of registerId and can send sample push to the client.</p>
<p>So the purpose of this article is to understand android push notification(c2dm) and start working on it quickly..Using this article developer can register the application from device and can send notification from web-interface. This way developer can also display push notification to clients or non-technical person.</p>
<p>There are three entity involved in android push notification:</p>
<ul>
<li>Android application &#8211; registers the device with C2DM server and passes the registerId to third party server</li>
<li>Google’s C2DM servers &#8211; send messages to android device</li>
<li>Third Party Server &#8211; send messages to C2DM server</li>
</ul>
<h2>Sample Application for Android Push Notification (C2DM):</h2>
<p>We have taken the source code from <a href="https://github.com/commonsguy/cw-advandroid">cw-advandroid</a> and added few tweaks in the source code. The only thing you need to do is to download the code from below link and configure it in your favorite IDE (We would prefer to use eclipse though). You need to open strings.xml file inside res/values directory and change the server URL.</p>
<pre class="brush:xml">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;resources&gt;
		&lt;string name="app_name"&gt;PushEndpointDemo&lt;/string&gt;
		&lt;string name="server_url"&gt;http://192.168.1.4:8080/c2dm/notify&lt;/string&gt;
&lt;/resources&gt;</pre>
<p>If you are deploying the server application (We shall discuss server-side in next section) on local machine then replace the ipaddress with your machine&#8217;s ipAddress. Now your application is ready to register your app with google and send the registrationId to your third party server.</p>
<p>Please notice few points before running the app on android:</p>
<ul>
<li>You must have android sdk 2.2+ and google service must be running on your emulator (We would recommend to install google sdk 2.3.1)</li>
<li>You must register your Google account on your emulator. You can do it by going to Settings -&gt; Accounts &amp; Sync and add gmail account. You cannot receive push notification unless Google account is set.</li>
<li>You must register your developer&#8217;s email address for your application at <a href="http://code.google.com/android/c2dm/signup.html">google</a> . Please note one thing that this account is developer&#8217;s account and might not be account which is configured in &#8216;Accounts &amp; Sync&#8217; settings.</li>
</ul>
<h2>Third party server to register device and send Android Push Notification (C2DM):</h2>
<p>We have built server-side solution on J2EE platform and application can be deployed on tomcat server(It might deployed fine on other servers but hav&#8217;nt tested it). Before deploying to server, you need to set the authentication code for your developer account in the application so please set it in the AUTH_KEY variable in class com.myor.c2dm.utils.Constants.java</p>
<pre class="brush:java">public static final String AUTH_KEY = "" //Please set your authentication key</pre>
<p>You can get authentication key using curl as mentioned <a href="http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html">this article</a> or You can use the our utility com.myor.c2dm.utils.AuthenticationUtils</p>
<pre class="brush:java">AuthenticationUtils.getAuthCode("&lt;DEVELOPER_EMAIL&gt;", "&lt;PASSWORD&gt;")</pre>
<p>Please use maven to create war file and deploy it on your server web directory.</p>
<pre class="brush:shell">mvn clean package</pre>
<p>You can access the application at</p>
<pre class="brush:shell">http://server:port/c2dm/notify</pre>
<p>Now we ready to register and receive the android push notification on sample application. Please launch the application on your emulator or device and screen would be displayed like this:</p>
<div id="attachment_416" class="wp-caption alignnone" style="width: 263px"><a href="http://www.makeurownrules.com/wp-content/uploads/2011/05/android-push-notification-c2dm-demo.png"><img class="size-full wp-image-416" title="android-push-notification-c2dm-demo" src="http://www.makeurownrules.com/wp-content/uploads/2011/05/android-push-notification-c2dm-demo.png" alt="Sample application to register push notification" width="253" height="152" /></a><p class="wp-caption-text">Sample notification application</p></div>
<p>Enter your developer email account and click on the &#8216;Register!&#8217; button. This shall make a call to google service to register the device for application. In the callback method, we make call to our third party server to register the registrationId for the device. We can access the registerId at</p>
<pre class="brush:shell">http://yourserver:port/c2dm/notify?act=1</pre>
<div id="attachment_417" class="wp-caption alignnone" style="width: 310px"><a href="http://www.makeurownrules.com/wp-content/uploads/2011/05/android-push-notification-c2dm-device-list.png"><img class="size-medium wp-image-417" title="android-push-notification-c2dm-device-list" src="http://www.makeurownrules.com/wp-content/uploads/2011/05/android-push-notification-c2dm-device-list-300x91.png" alt="List of devices registered on google service" width="300" height="91" /></a><p class="wp-caption-text">List of devices registered on google service</p></div>
<p>Now we can send push notification to the android application by clicking the &#8216;Push&#8217; link. The notification on the client&#8211;side look shall like this:</p>
<div id="attachment_415" class="wp-caption alignnone" style="width: 261px"><a href="http://www.makeurownrules.com/wp-content/uploads/2011/05/android-push-notification-c2dm-demo-ticker.png"><img class="size-full wp-image-415" title="android-push-notification-c2dm-demo-ticker" src="http://www.makeurownrules.com/wp-content/uploads/2011/05/android-push-notification-c2dm-demo-ticker.png" alt="Android Push Notification Ticker text " width="251" height="152" /></a><p class="wp-caption-text">Android Push Notification Ticker text</p></div>
<p>When you drag down the notification window then full notification shall be displayed like this:</p>
<div id="attachment_418" class="wp-caption alignnone" style="width: 267px"><a href="http://www.makeurownrules.com/wp-content/uploads/2011/05/android-push-notification-c2dm-full-notification.png"><img class="size-full wp-image-418" title="android-push-notification-c2dm-full-notification" src="http://www.makeurownrules.com/wp-content/uploads/2011/05/android-push-notification-c2dm-full-notification.png" alt="Sample notification when a push notification is received by device" width="257" height="171" /></a><p class="wp-caption-text">Push notification is received on device</p></div>
<p>We hope this article shall help you to power your application with Android push notification. Feel free to give us feedbacks or let us know if you have any queries.</p>
<p><strong>Downloads:</strong></p>
<ul>
<li><a href="http://www.makeurownrules.com/c2dm-sample/C2DM-client.zip">Android Client</a></li>
<li><a href="http://www.makeurownrules.com/c2dm-sample/c2dm.zip">Third Party Server</a></li>
</ul>
<p><strong>References:</strong></p>
<ul>
<li><a href="http://android-developers.blogspot.com/2010/05/android-cloud-to-device-messaging.html">Android Cloud To Device Messaging</a></li>
<li><a href="http://groups.google.com/group/android-c2dm">android-c2dm</a></li>
<li><a href="http://www.vogella.de/articles/AndroidCloudToDeviceMessaging/article.html">Android Cloud to Device Messaging (C2DM) &#8211; Tutorial </a></li>
<li><a href="http://www.smashingmagazine.com/2008/08/13/top-10-css-table-designs/">Top 10 CSS Table Designs</a></li>
<li><a href="http://tokudu.com/demo/android-push/">Demo to send notification</a></li>
</ul>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpower-mobile-app-android-push-notification-c2dm.html&amp;linkname=Power%20your%20mobile%20apps%20with%20android%20push%20notification%20%28C2DM%29" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpower-mobile-app-android-push-notification-c2dm.html&amp;linkname=Power%20your%20mobile%20apps%20with%20android%20push%20notification%20%28C2DM%29" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpower-mobile-app-android-push-notification-c2dm.html&amp;linkname=Power%20your%20mobile%20apps%20with%20android%20push%20notification%20%28C2DM%29" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpower-mobile-app-android-push-notification-c2dm.html&amp;linkname=Power%20your%20mobile%20apps%20with%20android%20push%20notification%20%28C2DM%29" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpower-mobile-app-android-push-notification-c2dm.html&amp;linkname=Power%20your%20mobile%20apps%20with%20android%20push%20notification%20%28C2DM%29" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpower-mobile-app-android-push-notification-c2dm.html&amp;linkname=Power%20your%20mobile%20apps%20with%20android%20push%20notification%20%28C2DM%29" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpower-mobile-app-android-push-notification-c2dm.html&amp;linkname=Power%20your%20mobile%20apps%20with%20android%20push%20notification%20%28C2DM%29" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpower-mobile-app-android-push-notification-c2dm.html&amp;linkname=Power%20your%20mobile%20apps%20with%20android%20push%20notification%20%28C2DM%29" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fpower-mobile-app-android-push-notification-c2dm.html&amp;title=Power%20your%20mobile%20apps%20with%20android%20push%20notification%20%28C2DM%29" id="wpa2a_32"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/power-mobile-app-android-push-notification-c2dm.html/feed</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>Increase performance and speed up socialengine using Memcached / APC /Xcache</title>
		<link>http://www.ipragmatech.com/increase-performance-socialengine-memcache-apc-xcache.html</link>
		<comments>http://www.ipragmatech.com/increase-performance-socialengine-memcache-apc-xcache.html#comments</comments>
		<pubDate>Mon, 02 May 2011 04:50:28 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Performance Optimization]]></category>
		<category><![CDATA[Social Engine]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=410</guid>
		<description><![CDATA[Recently we were working on the migration of socialengine v2 to socialengine v4.1.4 for one of our clients. The current socialengine website was loading very slowly even though there were not much users on the site. We tried to speed up the site by using the APC opcode,compressing the html,js and css but couldn&#8217;t improve [...]]]></description>
			<content:encoded><![CDATA[<p>Recently we were working on the migration of socialengine v2 to socialengine v4.1.4 for one of our clients. The current socialengine website was loading very slowly even though there were not much users on the site. We tried to speed up the site by using the APC opcode,compressing the html,js and css but couldn&#8217;t improve the performance much. There were various reasons for the slowdown but main reason was due to unorganized and inefficient customized source code developer by the earlier vendor. The customized code was tightly coupled with the socialengine&#8217;s core code that we couldn&#8217;t migrate it to socialengine v4.1.4 using the migration scripts. We had to rewrite the customize code from the scratch for the obvious reasons after migrating the socialengibe v2 to v4.1.4. We shall discuss about the social migration in different article and in this article would focus on speeding up the socialengine v4.x using the caching.</p>
<p>Caching is the vital part of any website and helps website to respond quickly. Social engine allows variety of caching solutions like file based, memcache, APC (Alternative Php cache) and Xcache for the platform. Using one of the caching solution would speed up performance of the socialengine 4. If you don&#8217;t have configured the memcached or APC or Xcache then you can use file system based caching but its much slower than the other caching solutions. We would recommend to use one of the caching solution to speed up the socialengine. In this article, we should show the instructions to install and configure caching for socialengine. We assume that the socialengine is running on the production mode.</p>
<p>Memcache is a distributed caching which can be used in a scenario where application is running on several web servers.All the data stored in memcached would be distributed across the all webservers.Since it requires dealing with network protocols in order to support the distributed part of caching, it is slower compared to APC/XCache cache in case of application is running on single server. While using APC/Xcache on distributed system would require manual copy of data on all the servers. APC/XCache are non distributed cache and data can be stored on the local web-server only. APC/XCache op-code caching saves on the compile and execution times of PHP thus loading of the socialengine become faster. Some people got confused whether Memcached can be used with the APC/Xcache (opcode). We can use the combination of MEMcached (as data storage) and APC/Xcache (as opcode for php).</p>
<p>Now we are going to show the installation and configuration of Memcached, APC and Xcache for socialengine on Centos.</p>
<p><strong>Install and Configure Memcached with socialengine</strong></p>
<p>1) Install memcached</p>
<pre class="brush:shell">  wget http://memcached.googlecode.com/files/memcached-1.4.5.tar.gz
tar zxpfv memcached*
cd memcached-1.4.5
./configure
make install
./memcached -u memcached -d -m 64 -l 127.0.0.1 -p 11211</pre>
<p>2) Install PHP Extension.</p>
<p>Download and install latest stable memcache version from PECL.</p>
<pre class="brush:shell">wget http://pecl.php.net/get/memcache-2.2.5.tgz
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5
phpize
./configure
make
make install</pre>
<p>memcache.so will be install in php modules directory, now enable memcache.so extension in php.ini</p>
<p>To find out your php.ini location, execute following command</p>
<pre class="brush:shell">php -i | grep php.ini
Configuration File (php.ini) Path =&gt; /usr/local/lib
Loaded Configuration File =&gt; /usr/local/lib/php.ini

vi /usr/local/lib/php.ini

extension = “memcache.so”</pre>
<p>save the file and restart httpd server.</p>
<pre class="brush:shell">/etc/init.d/httpd restart</pre>
<p>To check is memcache extension loaded in php, execute following command.</p>
<pre class="brush:shell">php -i | grep memcache
memcache
memcache support =&gt; enabled</pre>
<p>3) Configure memcached in socialengine</p>
<p>1. Go to http://yourserver/index.php/admin/core/settings/performance<br />
2. Enable caching with memcached and add parameters specific to memcached.<br />
3. Save the changes</p>
<p><strong>Install and Configure APC with socialengine</strong><br />
By default there can be one opcode caching for php so if there is already any opcode (eaccelerator etc.) then disable that to allow APC to act as opcode.</p>
<p>1) Install APC</p>
<pre class="brush:shell">yum install php-pear
yum install php-devel
yum install httpd-devel
yum install pcre-devel
pecl install apc
echo "extension=apc.so" &gt; /etc/php.d/apc.ini
/etc/init.d/httpd restart</pre>
<p>To check is APC extension loaded in php, execute following command.</p>
<pre class="brush:shell">php phpinfo()
apc.enabled=1</pre>
<p>2) Configure APC in socialengine</p>
<p>1. Go to http://yourserver/index.php/admin/core/settings/performance<br />
2. Enable caching with APC option.<br />
3. Save the changes<br />
<strong></strong></p>
<p><strong>Install and Configure Xcache with socialengine</strong></p>
<p>1) Install Xcache</p>
<pre class="brush:shell">wget http://xcache.lighttpd.net/pub/Releases/1.3.1/xcache-1.3.1.tar.gz
tar -zxvf xcache-1.3.1.tar.gz
cd xcache-1.3.1
phpize
./configure --enable-xcache
make
make install</pre>
<p>You would need to change timelib_structs.h to install Xcache<br />
Find line:</p>
<pre class="brush:shell">#include</pre>
<p>Replace / update as follows:</p>
<pre class="brush:shell">#include "timelib_config.h"</pre>
<p>Create one password for Xcache administration:</p>
<p># echo -n &#8220;yourpassword&#8221;| md5sum</p>
<p>Then open php.ini, and add the following append configuration directives.</p>
<pre class="brush:shell">[xcache-common]
zend_extension      = /usr/lib/php/modules/xcache.so

[xcache.admin]
xcache.admin.user   = "admin"
;how to create md5 pwd: echo -n "password"| md5sum
xcache.admin.pass   = "a364b1d54799c713b8a377de50f8ed3c"  #easywms.com

[xcache]
; Change xcache.size to tune the size of the opcode cache
; to disable: xcache.size=0
; to enable : xcache.size=64M etc (any size &gt; 0) and your system mmap allows
; someone said, if &gt;=64 will get problem

xcache.size         = 32M
xcache.shm_scheme   = "mmap"
; set to cpu count (cat /proc/cpuinfo |grep -c processor)

xcache.count        = 4
; just a hash hints, you can always store count(items) &gt; slots

xcache.slots        = 8K
; ttl of the cache item, 0=forever

xcache.ttl          = 0
; interval of gc scanning expired items, 0=no scan, other values is in seconds

xcache.gc_interval  = 0

; Change xcache.var_size to adjust the size of variable cache
; same as aboves but for variable cache, if you have not used xcache function in script,forget it

xcache.var_size     = 8M
xcache.var_count    = 1
xcache.var_slots    = 8K
xcache.var_ttl      = 0
xcache.var_maxttl   = 0
xcache.var_gc_interval =     300

xcache.test         = Off
xcache.readonly_protection = On
; for *nix, xcache.mmap_path is a file path, not directory.
; Use something like "/tmp/xcache" if you want to turn on ReadonlyProtection
; 2 group of php won’t share the same /tmp/xcache
; for win32, xcache.mmap_path=anonymous map name, not file path

xcache.mmap_path    = "/tmp/xcache"
; leave it blank(disabled) or "/tmp/phpcore/"
; make sure it’s writable by php (without checking open_basedir)

xcache.coredump_directory =   ""
; per request settings

xcache.cacher       = On
xcache.stat         = On
xcache.optimizer    = Off

[xcache.coverager]
; per request settings
; enable coverage data collecting for xcache.coveragedump_directory and
; xcache_coverager_start/stop/get/clean() functions (will hurt executing performance)

xcache.coverager    = On
; ini only settings
; make sure it’s readable (care open_basedir) by coverage viewer script
; requires xcache.coverager=On

xcache.coveragedump_directory = ""</pre>
<p>2) Configure Xcache in socialengine</p>
<p>1. Go to http://yourserver/index.php/admin/core/settings/performance<br />
2. Enable caching with Xcache option and add user&#8217;s credentials.<br />
3. Save the changes</p>
<p><strong>Conclusion</strong><br />
We found Xcache little faster than the Memcached/APC for socialengine 4 and used it for our client&#8217;s website.</p>
<p>Please feel free to comments or suggest other technique of caching.</p>
<p><strong>References</strong></p>
<ul>
<li><a href="http://blog.arvixe.com/optimizing-socialengine-4-performance/">Optimizing SocialEngine 4 Performance</a></li>
<li><a href="http://www.sohailriaz.com/how-to-install-memcached-with-memcache-php-extension-on-centos-5x/">How To Install memcached with memcache PHP Extension on CentOS 5.x</a></li>
<li><a href="http://2bits.com/articles/installing-php-apc-gnulinux-centos-5.html">Installing PHP APC on GNU/Linux Centos 5</a></li>
<li><a href="http://www.easywms.com/easywms/?q=en/node/210">Install XCache for PHP 5 on CentOS</a></li>
<li><a href="http://www.ducea.com/2006/10/30/php-accelerators/">PHP Accelerators</a></li>
</ul>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fincrease-performance-socialengine-memcache-apc-xcache.html&amp;linkname=Increase%20performance%20and%20speed%20up%20socialengine%20using%20Memcached%20%2F%20APC%20%2FXcache" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fincrease-performance-socialengine-memcache-apc-xcache.html&amp;linkname=Increase%20performance%20and%20speed%20up%20socialengine%20using%20Memcached%20%2F%20APC%20%2FXcache" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fincrease-performance-socialengine-memcache-apc-xcache.html&amp;linkname=Increase%20performance%20and%20speed%20up%20socialengine%20using%20Memcached%20%2F%20APC%20%2FXcache" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fincrease-performance-socialengine-memcache-apc-xcache.html&amp;linkname=Increase%20performance%20and%20speed%20up%20socialengine%20using%20Memcached%20%2F%20APC%20%2FXcache" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fincrease-performance-socialengine-memcache-apc-xcache.html&amp;linkname=Increase%20performance%20and%20speed%20up%20socialengine%20using%20Memcached%20%2F%20APC%20%2FXcache" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fincrease-performance-socialengine-memcache-apc-xcache.html&amp;linkname=Increase%20performance%20and%20speed%20up%20socialengine%20using%20Memcached%20%2F%20APC%20%2FXcache" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fincrease-performance-socialengine-memcache-apc-xcache.html&amp;linkname=Increase%20performance%20and%20speed%20up%20socialengine%20using%20Memcached%20%2F%20APC%20%2FXcache" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fincrease-performance-socialengine-memcache-apc-xcache.html&amp;linkname=Increase%20performance%20and%20speed%20up%20socialengine%20using%20Memcached%20%2F%20APC%20%2FXcache" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fincrease-performance-socialengine-memcache-apc-xcache.html&amp;title=Increase%20performance%20and%20speed%20up%20socialengine%20using%20Memcached%20%2F%20APC%20%2FXcache" id="wpa2a_34"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/increase-performance-socialengine-memcache-apc-xcache.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improve database performance using Amazon simpledb on Ruby on rails</title>
		<link>http://www.ipragmatech.com/improve-database-performance-amazon-simpledb-ror.html</link>
		<comments>http://www.ipragmatech.com/improve-database-performance-amazon-simpledb-ror.html#comments</comments>
		<pubDate>Tue, 26 Apr 2011 07:31:24 +0000</pubDate>
		<dc:creator>sundeep.goyal</dc:creator>
				<category><![CDATA[Performance Optimization]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=406</guid>
		<description><![CDATA[We were enjoying mysql database performance until we had large data in the database. The problem started with millions of data in the tables and increasing rapidly on daily bases.It was taking much more time to retrieve data from those tables.We already had proper indexing on the columns but still it was taking some time(20-25 [...]]]></description>
			<content:encoded><![CDATA[<p>We were enjoying mysql database performance until we had large data in the database. The problem started with millions of data in the tables and increasing rapidly on daily bases.It was taking much more time to retrieve data from those tables.We already had proper indexing on the columns but still it was taking some time(20-25 sec) to run a query.After doing research on google, we found an alternative solution to the RDBMS. Welcome to the word of NoSQL !!!</p>
<p>We looked at the various implementation of NoSQL and found solutions like Membase, Redis, CouchDB, MongoDB and SimpleDB. Since we were already using Amazon infrstructure like EC2 and S3 so we gave a shot to amazon SimpleDB. We are very pleased with the performance of simpledb as query time is below five seconds now.</p>
<p>Here are the instructions to use SimpleDB with <strong>Ruby on rails</strong>. We have used the simple_db gem to connect to Amazon SimpleDB web service.</p>
<p><strong><br />
How to use simple db with <strong>ruby on rails</strong>:</strong></p>
<p>1. Install simple_record gem by: gem install simple_record<br />
2. Create connection with simple db and execute sql query.</p>
<pre class="brush:ruby">SimpleRecord.establish_connection('access_key_id','secret_access_key', :connection_mode=&gt;:per_thread)

Company.find(:all,:conditions =&gt; ["name = ?", name], <img src='http://www.ipragmatech.com/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> rder =&gt; "id desc")</pre>
<p>3. close simple db connection.It is better to use close_connection in Application controller:</p>
<pre class="brush:ruby">after_filter :close_sdb_connection
class ApplicationController &lt; ActionController::Base

#TO CLOSE SIMPLE DB CONNNECTION AFTER EVERY REQUEST
def close_sdb_connection
SimpleRecord.close_connection
end</pre>
<p>There were few more requirements from client-side to generats reports from the SimpleDB. we told the client about the limitation of SimpleDB but client insist us to use SimpleDB for reporting system. We started working on the reporting and encounter some problems and limitations of SimpleDB.</p>
<p>Here are some major limitations :<br />
1. It doesn&#8217;t support group by clause<br />
2. It doesn&#8217;t support join of tables<br />
3. It doesn&#8217;t support as (alias)<br />
4. It can not have more than 20 comparisons in where clause.</p>
<p>NOTE: We cannot use full fledge &#8216;in&#8217; query in the simpleDB as every value in array counted as a comparison clause.</p>
<p>Finally we had to revert back to mysql for reporting system.So, the moral of the story is that never use simple db blindly.<br />
Think carefully before implementing, is it suitable or fulfill your requirement.</p>
<p><strong>Here are some points to consider before implementing simple db:</strong><br />
** SimpleDB shifts work out of the database and onto programmers which is why the SimpleDB programming model sucks: it requires a lot more programming to do simple things. I’ll argue however that this is the kind of sulkiness programmers like. Programmers like problems they can solve with more programming. We don’t even care how twisted and inelegant the code is because we can make it work. As long as we can make it work we are happy.</p>
<p><strong>References:</strong><br />
<a href="http://aws.amazon.com/simpledb/">Amazon SimpleDB</a><br />
<a href="http://rubygems.org/gems/simple_record">SimpleRecord Gem</a><br />
<a href="http://www.ryanpark.org/2008/04/top-10-avoid-the-simpledb-hype.html">Top 10 Reasons to Avoid the SimpleDB Hype</a></p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-database-performance-amazon-simpledb-ror.html&amp;linkname=Improve%20database%20performance%20using%20Amazon%20simpledb%20on%20Ruby%20on%20rails" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-database-performance-amazon-simpledb-ror.html&amp;linkname=Improve%20database%20performance%20using%20Amazon%20simpledb%20on%20Ruby%20on%20rails" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-database-performance-amazon-simpledb-ror.html&amp;linkname=Improve%20database%20performance%20using%20Amazon%20simpledb%20on%20Ruby%20on%20rails" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-database-performance-amazon-simpledb-ror.html&amp;linkname=Improve%20database%20performance%20using%20Amazon%20simpledb%20on%20Ruby%20on%20rails" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-database-performance-amazon-simpledb-ror.html&amp;linkname=Improve%20database%20performance%20using%20Amazon%20simpledb%20on%20Ruby%20on%20rails" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-database-performance-amazon-simpledb-ror.html&amp;linkname=Improve%20database%20performance%20using%20Amazon%20simpledb%20on%20Ruby%20on%20rails" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-database-performance-amazon-simpledb-ror.html&amp;linkname=Improve%20database%20performance%20using%20Amazon%20simpledb%20on%20Ruby%20on%20rails" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-database-performance-amazon-simpledb-ror.html&amp;linkname=Improve%20database%20performance%20using%20Amazon%20simpledb%20on%20Ruby%20on%20rails" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-database-performance-amazon-simpledb-ror.html&amp;title=Improve%20database%20performance%20using%20Amazon%20simpledb%20on%20Ruby%20on%20rails" id="wpa2a_36"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/improve-database-performance-amazon-simpledb-ror.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Post form data to java server using php curl</title>
		<link>http://www.ipragmatech.com/post-form-data-java-php-curl.html</link>
		<comments>http://www.ipragmatech.com/post-form-data-java-php-curl.html#comments</comments>
		<pubDate>Tue, 05 Apr 2011 04:12:38 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=402</guid>
		<description><![CDATA[Recently one of client come up with the requirements to post data from php platform to java platform. We thought it would be simpler task as we need to fetch data from mysql database and need to do http post to the java server. We can use the php curl and post the data to [...]]]></description>
			<content:encoded><![CDATA[<p>Recently one of client come up with the requirements to post data from php platform to java platform. We thought it would be simpler task as we need to fetch data from mysql database and need to do http post to the java server. We can use the php <a href="http://php.net/manual/en/book.curl.php">curl</a> and post the data to java server. Simple stuff !!! right ? Well not exactly. We tried to use the php curl and used array to send the data to server. To our surprise, data was not captured by java server. We were using the following code to post form data to java server:</p>
<pre class="brush:php">define("URL","http://Yoursite.com:8080/action.do");

$fields = array(
  'lname'=&gt;$last_name,
  'fname'=&gt;$first_name,
  'title'=&gt;$title,
  'company'=&gt;$institution,
  'age'=&gt;$age,
  'email'=&gt;$email,
  'phone'=&gt;$phone
);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$output = curl_exec($ch);
curl_close($ch);</pre>
<p>We tried to investigate the problem and our first suspicion was that the php curl is not working properly. We create a php script which just listens the request and print all the parameters in the log file.We used the above code and we were able to extract the parameters from the request. So it was the time we ask our friends google and stackoverflow. We read many articles and documentations but there were no solution for this problem. Later we realized that java server is not unmarshalling the post data(mutipart/form-data) which is in array format from php curl. So we decided to use other approach i.e. send the parameters in urlencoding string as we have http servlet on the java server side.</p>
<pre class="brush:php">&lt;?php
define("URL","http://Yoursite.com:8080/action.do");

$fields = array(
  'lname'=&gt;$last_name,
  'fname'=&gt;$first_name,
  'title'=&gt;$title,
  'company'=&gt;$institution,
  'age'=&gt;$age,
  'email'=&gt;$email,
  'phone'=&gt;$phone
);

// url encoding
$fields_string = http_build_query($fields);

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
$output = curl_exec($ch);
curl_close($ch);
?&gt;</pre>
<p>We hope this would help other developers to resolve this type of issue. Alternative solution to resolve this issue is to add support for multipart/form-data on java server using common&#8217;s <a href="http://commons.apache.org/fileupload/apidocs/org/apache/commons/fileupload/servlet/ServletFileUpload.html">ServletFileUpload</a><br />
Please let us know your questions.</p>
<h3>Related Posts</h3>
<ul>
<li><a href="http://www.askapache.com/htaccess/sending-post-form-data-with-php-curl.html">Sending POST form data with php CURL</a></li>
<li><a href="http://davidwalsh.name/execute-http-post-php-curl">Execute a HTTP POST Using PHP CURL</a></li>
</ul>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpost-form-data-java-php-curl.html&amp;linkname=Post%20form%20data%20to%20java%20server%20using%20php%20curl" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpost-form-data-java-php-curl.html&amp;linkname=Post%20form%20data%20to%20java%20server%20using%20php%20curl" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpost-form-data-java-php-curl.html&amp;linkname=Post%20form%20data%20to%20java%20server%20using%20php%20curl" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpost-form-data-java-php-curl.html&amp;linkname=Post%20form%20data%20to%20java%20server%20using%20php%20curl" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpost-form-data-java-php-curl.html&amp;linkname=Post%20form%20data%20to%20java%20server%20using%20php%20curl" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpost-form-data-java-php-curl.html&amp;linkname=Post%20form%20data%20to%20java%20server%20using%20php%20curl" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpost-form-data-java-php-curl.html&amp;linkname=Post%20form%20data%20to%20java%20server%20using%20php%20curl" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fpost-form-data-java-php-curl.html&amp;linkname=Post%20form%20data%20to%20java%20server%20using%20php%20curl" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fpost-form-data-java-php-curl.html&amp;title=Post%20form%20data%20to%20java%20server%20using%20php%20curl" id="wpa2a_38"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/post-form-data-java-php-curl.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Connect over secure rest web service for mobile application on android</title>
		<link>http://www.ipragmatech.com/secure-rest-web-service-mobile-application-android.html</link>
		<comments>http://www.ipragmatech.com/secure-rest-web-service-mobile-application-android.html#comments</comments>
		<pubDate>Tue, 29 Mar 2011 09:08:14 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=400</guid>
		<description><![CDATA[In the last article, we developed application for android to get the data from rest web service (geo-names). Previous approach works fine for http rest web service but it doesn&#8217;t work over SSL secure connection. We were developing android application for a client whose rest web services are running over secure connection. Initially we thought [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://www.makeurownrules.com/rest-spring-maven-android">last article</a>, we developed application for android to get the data from rest web service (geo-names). Previous approach works fine for http rest web service but it doesn&#8217;t work over SSL secure connection. We were developing android application for a client whose rest web services are running over secure connection. Initially we thought it would be much simple to connect to secure rest web service because we already have the framework to connect to http connection. When we use it and there was exception &#8220;javax.net.ssl.SSLException: Not trusted server certificate&#8221; all over the application.<br />
We didn&#8217;t loose our patience and asked our truly friends google and stackoverflow. We found various solution to intercept the connection and use self certificate but we wanted a solution which just by pass the authorization of the certificates. After checking various sites and reading the article, we found a solution which fit our requirements.</p>
<h3>Create Easy SSL Socket Factory and create httpclient instance</h3>
<pre class="brush:java">import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import java.security.*;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;

import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import org.apache.http.conn.ssl.SSLSocketFactory;
public class EasySSLSocketFactory extends SSLSocketFactory {
        SSLContext sslContext = SSLContext.getInstance("TLS");

        public EasySSLSocketFactory(KeyStore truststore)
                        throws NoSuchAlgorithmException, KeyManagementException,
                        KeyStoreException, UnrecoverableKeyException {
                super(truststore);

                TrustManager tm = new X509TrustManager() {
                        public void checkClientTrusted(X509Certificate[] chain,
                                        String authType) throws CertificateException {
                        }

                        public void checkServerTrusted(X509Certificate[] chain,
                                        String authType) throws CertificateException {
                        }

                        public X509Certificate[] getAcceptedIssuers() {
                                return null;
                        }
                };

                sslContext.init(null, new TrustManager[] { tm }, null);
        }

        @Override
        public Socket createSocket(Socket socket, String host, int port,
                        boolean autoClose) throws IOException, UnknownHostException {
                return sslContext.getSocketFactory().createSocket(socket, host, port,
                                autoClose);
        }

        @Override
        public Socket createSocket() throws IOException {
                return sslContext.getSocketFactory().createSocket();
        }

}</pre>
<p>We shall be using this ssl socket factory to access the secure connection to rest web service.</p>
<pre class="brush:java">import java.security.KeyStore;

import org.apache.http.HttpVersion;
import org.apache.http.client.HttpClient;
import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
import org.apache.http.params.HttpProtocolParams;
import org.apache.http.protocol.HTTP;

public class HttpUtils {
        public static HttpClient getNewHttpClient() {
            try {
                KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
                trustStore.load(null, null);

                SSLSocketFactory sf = new EasySSLSocketFactory(trustStore);
                sf.setHostnameVerifier(
                       SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

                HttpParams params = new BasicHttpParams();
                HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
                HttpProtocolParams.setContentCharset(params, HTTP.UTF_8);

                SchemeRegistry registry = new SchemeRegistry();
                registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
                registry.register(new Scheme("https", sf, 443));

                ClientConnectionManager ccm = new ThreadSafeClientConnManager(params, registry);

                return new DefaultHttpClient(ccm, params);
            } catch (Exception e) {
                return new DefaultHttpClient();
            }
        }
}</pre>
<p>Back to our original rest client code</p>
<pre class="brush:java">// Create a new RestTemplate instance
				RestTemplate restTemplate = new RestTemplate();

				// The HttpComponentsClientHttpRequestFactory uses the
				// org.apache.http package to make network requests
				restTemplate
						.setRequestFactory(new HttpComponentsClientHttpRequestFactory(
								HttpUtils.getNewHttpClient()));

				// The URL for making the GET request
				final String url = "https://xxx.xxx.xxx.xxx";
                                // Initiate the HTTP GET request, expecting an array of
				// objects in response
				Object result = restTemplate.getForObject(url, Object.class);</pre>
<p>Finally we were able to make connection over secure rest web service android application.</p>
<p>Feel free to comment or ask questions.</p>
<h3>Useful resources</h3>
<ul>
<li><a href="http://blog.antoine.li/index.php/2010/10/android-trusting-ssl-certificates/">Android: Trusting SSL certificates</a></li>
<li><a href="http://www.exampledepot.com/egs/javax.net.ssl/TrustAll.html">Disabling Certificate Validation in an HTTPS Connection</a></li>
<li><a href="http://code.google.com/p/redmine-java-api/">Redmine java api</a></li>
</ul>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsecure-rest-web-service-mobile-application-android.html&amp;linkname=Connect%20over%20secure%20rest%20web%20service%20for%20mobile%20application%20on%20android" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsecure-rest-web-service-mobile-application-android.html&amp;linkname=Connect%20over%20secure%20rest%20web%20service%20for%20mobile%20application%20on%20android" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsecure-rest-web-service-mobile-application-android.html&amp;linkname=Connect%20over%20secure%20rest%20web%20service%20for%20mobile%20application%20on%20android" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsecure-rest-web-service-mobile-application-android.html&amp;linkname=Connect%20over%20secure%20rest%20web%20service%20for%20mobile%20application%20on%20android" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsecure-rest-web-service-mobile-application-android.html&amp;linkname=Connect%20over%20secure%20rest%20web%20service%20for%20mobile%20application%20on%20android" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsecure-rest-web-service-mobile-application-android.html&amp;linkname=Connect%20over%20secure%20rest%20web%20service%20for%20mobile%20application%20on%20android" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsecure-rest-web-service-mobile-application-android.html&amp;linkname=Connect%20over%20secure%20rest%20web%20service%20for%20mobile%20application%20on%20android" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fsecure-rest-web-service-mobile-application-android.html&amp;linkname=Connect%20over%20secure%20rest%20web%20service%20for%20mobile%20application%20on%20android" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fsecure-rest-web-service-mobile-application-android.html&amp;title=Connect%20over%20secure%20rest%20web%20service%20for%20mobile%20application%20on%20android" id="wpa2a_40"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/secure-rest-web-service-mobile-application-android.html/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Create facebook application using php &#8211; Yii Framework and Graph API</title>
		<link>http://www.ipragmatech.com/create-facebook-yiiframework-graphapi.html</link>
		<comments>http://www.ipragmatech.com/create-facebook-yiiframework-graphapi.html#comments</comments>
		<pubDate>Tue, 22 Mar 2011 15:36:10 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[LAMP]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=399</guid>
		<description><![CDATA[Recently we developed an facebook application and during the development of application, we encounter lots of issues due to vague Facebook documentation. We wanted to share our experience so that other developers can develop facebook application easily. We have used yii framework for this application as its pretty cool framework and application development on this [...]]]></description>
			<content:encoded><![CDATA[<p>Recently we developed an facebook application and during the development of application, we encounter lots of issues due to vague Facebook documentation. We wanted to share our experience so that other developers can develop facebook application easily. We have used <a href="http://www.yiiframework.com/">yii framework</a> for this application as its pretty cool framework and application development on this framework takes less time without compromising the performance.In this article, we assume that the reader have experience in <a href="http://www.facebook.com">facebook application development</a>.</p>
<h2>A little introduction about yii framework</h2>
<p>Yii is a high-performance PHP framework best for developing Web 2.0 applications. Yii comes with rich features: MVC, DAO/ActiveRecord, I18N/L10N, caching, authentication and role-based access control, scaffolding, testing, etc. It can reduce your development time significantly. It has pretty good documentation and you can get more help by googling the issue. You can also compare the performance of yii framework with other popular frameworks <a href="http://www.yiiframework.com/performance/">here</a></p>
<h2>A little introduction about facebook Graph API</h2>
<p>Facebook introduced new components of Facebook Platform and one of them is Graph API. The API provides access to Facebook objects like people, photos, events etc. and the connections between them like friends, tags, shared content etc. via a uniform and consistent URI to access the representation. Every object can be accessed using the the URL https://graph.facebook.com/ID, where ID stands for the unique ID for the object in the social graph. For more details, please take a look at <a href="http://developers.facebook.com/docs/reference/api/">graph api</a></p>
<h2>Sample facebook application using yii framework</h2>
<p>We assume that you have created facebook application and have the access to the App Id and Secret Key for the application. If you have no idea about it then please take a look at the links below to get started. We also assume that you have also created the <a href="http://www.yiiframework.com/doc/guide/1.1/en/quickstart.first-app">sample application using yii framework</a>.</p>
<h2>Configure facebook api in the application</h2>
<p>Get php facebook api from <a href="https://github.com/facebook/php-sdk/">git</a> and place it in the vendors directory(create if not exist). We needed some additional properties so we created facebookwrapper which extends facebook api.</p>
<pre class="brush:php">require 'facebook.php';
/*
 * Created on Mar 15, 2011
 *
 * Provides access to Custom application properties along with the Facebook Platform.
 *
 * @author makeurownrules
 */
 class FacebookWrapper extends Facebook{
 ...
 ...
 }</pre>
<p>We had initialize the facebook api in the controller and added facebook filter to verify that the facebook session exist. We need to include the wrapper in the main controller in the components package.</p>
<pre class="brush:php">Yii::import('application.vendors.*');
require_once('facebook-php-sdk-b14edfa/src/facebookwrapper.php');
...
...
function __construct($id,$module=null) {
    parent::__construct($id, $module);
    // Get an instance of the Facebook class distributed as the PHP SDK by facebook:
    Yii::app()-&gt;params['facebook'] = new FacebookWrapper(array(
      'appId'  =&gt; 'appId',
      'secret' =&gt; 'secretKey',
      'cookie' =&gt; true,
      'appName' =&gt; 'App Name',
      'canvasPage' =&gt; 'http://apps.facebook.com/appname/',
      'canvasUrl'  =&gt; 'http://example.com/appname/'
      ));

  }

  /**
   * Filters for all the request coming to facebook application
   */
  public function filters() {
    return array(
            'facebook',
    );
  }

  public function filterFacebook($filterChain) {
    header('P3P: CP="CAO PSA OUR"');
    $facebook = Yii::app()-&gt;params['facebook'];
    $session = $facebook-&gt;getSession();
    $fbme = null;
    if ($session) {
      try {
        $uid = $facebook-&gt;getUser();
        $fbme = $facebook-&gt;api('/me');
      } catch (FacebookApiException $e) {
         //handle error
      }
    }
    if ($fbme) {
      // call $filterChain-&gt;run() to continue filtering and action execution
      $filterChain-&gt;run();
    }
    else {
      $appId = $facebook-&gt;getAppId();
      $canvasUrl = $facebook-&gt;getCanvasPage();
      // Set the required permissions for the application
      $perms = "publish_stream,friends_birthday, offline_access, email";
      $loginUrl = "https://www.facebook.com/dialog/oauth?scope=".$perms.
        "&amp;client_id=".$facebook-&gt;getAppId().
        "&amp;redirect_uri=".urlencode($canvasUrl);
      location =  'top.location.href=';
     echo("<script type="text/javascript">// <![CDATA[
".$location. $loginUrl . "'
// ]]&gt;</script>");
      Yii::app()-&gt;end();
    }
  }</pre>
<p>After initializing the facebook API, we can access facebook instance in the SiteController or any other controller.</p>
<pre class="brush:php">public function actionIndex()
	{
		$facebook = Yii :: app()-&gt;params['facebook'];
                $myuid = $facebook-&gt;getUser();
	  // renders the view file 'protected/views/site/index.php'
		// using the default layout 'protected/views/layouts/main.php'
		$this-&gt;render('index',array('myuid'=&gt; $myuid));
	}</pre>
<p>So facebook api can be accessed and used to publish on wall, send message or change the status of user.</p>
<h2>Source code and Demo</h2>
<p>Source for sample application is available <a href="http://www.makeurownrules.com/facebook-sample.zip">here</a>.<br />
Demo is available <a href="http://apps.facebook.com/myorapp">here</a></p>
<h2>References</h2>
<p>We highly recommend to go through basic facebook application documentation.</p>
<p><strong>Official Facebook documentation / developer site</strong>:<br />
<a href="http://developers.facebook.com/docs/guides/canvas/">Facebook Developers Site</a></p>
<p><strong>Facebook tutorials:</strong><br />
<a href="http://www.makeurownrules.com/facebook-publish-media-wall.html">publish post with media on wall using facebook Graph API</a></p>
<p><a href="http://www.merchantos.com/blog/makebeta/facebook/facebook-php-tutorial">Facebook PHP Tutorial</a><br />
<a href="http://www.sitepoint.com/article/developing-facebook-platform">Developing with the Facebook Platform and PHP</a></p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcreate-facebook-yiiframework-graphapi.html&amp;linkname=Create%20facebook%20application%20using%20php%20%E2%80%93%20Yii%20Framework%20and%20Graph%20API" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcreate-facebook-yiiframework-graphapi.html&amp;linkname=Create%20facebook%20application%20using%20php%20%E2%80%93%20Yii%20Framework%20and%20Graph%20API" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcreate-facebook-yiiframework-graphapi.html&amp;linkname=Create%20facebook%20application%20using%20php%20%E2%80%93%20Yii%20Framework%20and%20Graph%20API" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcreate-facebook-yiiframework-graphapi.html&amp;linkname=Create%20facebook%20application%20using%20php%20%E2%80%93%20Yii%20Framework%20and%20Graph%20API" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcreate-facebook-yiiframework-graphapi.html&amp;linkname=Create%20facebook%20application%20using%20php%20%E2%80%93%20Yii%20Framework%20and%20Graph%20API" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcreate-facebook-yiiframework-graphapi.html&amp;linkname=Create%20facebook%20application%20using%20php%20%E2%80%93%20Yii%20Framework%20and%20Graph%20API" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcreate-facebook-yiiframework-graphapi.html&amp;linkname=Create%20facebook%20application%20using%20php%20%E2%80%93%20Yii%20Framework%20and%20Graph%20API" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcreate-facebook-yiiframework-graphapi.html&amp;linkname=Create%20facebook%20application%20using%20php%20%E2%80%93%20Yii%20Framework%20and%20Graph%20API" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fcreate-facebook-yiiframework-graphapi.html&amp;title=Create%20facebook%20application%20using%20php%20%E2%80%93%20Yii%20Framework%20and%20Graph%20API" id="wpa2a_42"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/create-facebook-yiiframework-graphapi.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>publish media to wall using facebook Graph API</title>
		<link>http://www.ipragmatech.com/facebook-publish-media-wall.html</link>
		<comments>http://www.ipragmatech.com/facebook-publish-media-wall.html#comments</comments>
		<pubDate>Sun, 20 Mar 2011 05:07:38 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[LAMP]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=397</guid>
		<description><![CDATA[We were developing one of the facebook application for our client on php/mysql platform using yii framework. There was one requirement from the client to publish the media file(video / flash) on the friend&#8217;s wall so that it can be played on user&#8217;s wall. The main challenge with facebook application development is vague/obsolete documentation on [...]]]></description>
			<content:encoded><![CDATA[<p>We were developing one of the <a href="http://www.facebook.com">facebook</a> application for our client on php/mysql platform using <a href="http://www.yiiframework.com/">yii framework</a>. There was one requirement from the client to publish the media file(video / flash) on the friend&#8217;s wall so that it can be played on user&#8217;s wall. The main challenge with facebook application development is vague/obsolete documentation on the facebook wiki. After throughly investigation, we found two ways to publish media on friend&#8217;s wall.</p>
<p>1. Using <a href="http://developers.facebook.com/docs/reference/javascript/">Javascript SDK</a><br />
2. Using <a href="http://developers.facebook.com/docs/reference/api/">Graph API</a></p>
<p>We can use facebook&#8217;s javascript api to publish media of friend&#8217;s wall like :</p>
<pre class="brush:js">// Include facebook javascript by including http://connect.facebook.net/en_US/all.js
// Initialize facebook session
FB.init({
		appId  : '<!--?php echo $facebookWrapper---> getAppId();?&gt;', // application Id
		status : true, // check login status
		cookie : true, // enable cookies to allow the server to access the session
		xfbml  : true  // parse XFBML
	});
function publishStream(targetId, name, link, picture, source, userName,message) {
FB.ui(
        {
        	 method: 'feed',
        	 to: targetId,
                 name: name,
                 link: link,
                 picture: picture,
                 source:  source, // The URL of a media file (e.g., a SWF or video file) attached to this post
                 caption: 'Shared by '+userName,
                 actions:  {name: 'Try App', link: link},
                 message: message

        },
        function(response){
		     if (response &amp;&amp; response.post_id) {
		      alert('Post was published.');
		     } else {
		       alert('Post was not published.');
		     }
        });
    }</pre>
<p>Second way is to use Graph API:</p>
<pre class="brush:xml">http://www.facebook.com/dialog/feed?app_id=app_id&amp;link=link&amp;picture=picture &amp;caption=caption&amp;name=name&amp;source=source &amp;message=message&amp;redirect_uri=response</pre>
<p>We are assume that you have already worked on facebook api. We would like to answer your questions.</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Ffacebook-publish-media-wall.html&amp;linkname=publish%20media%20to%20wall%20using%20facebook%20Graph%20API" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Ffacebook-publish-media-wall.html&amp;linkname=publish%20media%20to%20wall%20using%20facebook%20Graph%20API" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Ffacebook-publish-media-wall.html&amp;linkname=publish%20media%20to%20wall%20using%20facebook%20Graph%20API" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Ffacebook-publish-media-wall.html&amp;linkname=publish%20media%20to%20wall%20using%20facebook%20Graph%20API" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Ffacebook-publish-media-wall.html&amp;linkname=publish%20media%20to%20wall%20using%20facebook%20Graph%20API" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Ffacebook-publish-media-wall.html&amp;linkname=publish%20media%20to%20wall%20using%20facebook%20Graph%20API" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Ffacebook-publish-media-wall.html&amp;linkname=publish%20media%20to%20wall%20using%20facebook%20Graph%20API" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Ffacebook-publish-media-wall.html&amp;linkname=publish%20media%20to%20wall%20using%20facebook%20Graph%20API" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Ffacebook-publish-media-wall.html&amp;title=publish%20media%20to%20wall%20using%20facebook%20Graph%20API" id="wpa2a_44"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/facebook-publish-media-wall.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Upload files using attachment_fu and swfupload on rails</title>
		<link>http://www.ipragmatech.com/swfupload-attachmentfu-ruby-on-rails.html</link>
		<comments>http://www.ipragmatech.com/swfupload-attachmentfu-ruby-on-rails.html#comments</comments>
		<pubDate>Sat, 12 Feb 2011 08:49:42 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=387</guid>
		<description><![CDATA[Uploading files in ruby on rails application seems trivial task using attachment_fu plugin but it become non-trivial when you need to display upload progress.Recently we had requirements from client to show the progress bar while uploading the image/video files. We could show the file upload progress only when we upload with flash. We found swfupload [...]]]></description>
			<content:encoded><![CDATA[<p>Uploading files in <strong>ruby on rails</strong> application seems trivial task using <a href="https://github.com/technoweenie/attachment_fu/wiki">attachment_fu</a> plugin but it become non-trivial when you need to display upload progress.Recently we had requirements from client to show the progress bar while uploading the image/video files. We could show the file upload progress only when we upload with flash. We found swfupload a reliable solution for this and decided to use it. We were using attachment_fu plugin for the attachment and there is no easier way to integrate it with swfupload. attachment_fu saves the files using the mime type of the file and when swfupload is used for uploading the file, it set mimetype of files to application/octet-stream. It become difficult to detect the difference between image/video or other formated files. So we come up with a solution which first convert the convert the file data in same format which is expected by attachment_fu plugin and later detect the mimetype of the file.</p>
<h3>Conversion of file data to attachment_fu format</h3>
<p>Using attachment_fu plugin we were expecting the file data in params[:ASSET_DATA] but with swfupload data was coming as params[:Filedata]. So we wrapped the Filedata from swfupload and put that in the desired format</p>
<pre class="brush:rails"> data = {"uploaded_data" =&gt;params[:Filedata]}</pre>
<h3>Setting mimetype of the file</h3>
<p>Attachment_fu requires the mimetype to be set correctly before it will accept the files. Matt Aimonetti wrote <a href="http://code.google.com/p/mimetype-fu/">mimetype-fu</a> to help attachment_fu properly set the mimetype.</p>
<p>We override the uploaded_data of attachment_fu in our model object.</p>
<pre class="brush:rails"> #override attachment_fu plugin
  def uploaded_data=(file_data)
    return nil if file_data.nil? || file_data.size == 0
    self.filename = file_data.original_filename if respond_to?(:filename)
    extension = file_data.original_filename.slice(/\.\w+$/)
    # Map file extensions to mime types.  Thanks to bug in Flash 8
    # the content type is always set to application/octet-stream.
    mime = MIME::Types.type_for(self.filename)[0]
    self.content_type = mime.blank? ? file_data.content_type : mime.content_type
    #Custom name of the file
    self.filename  = "xxxx_" + Digest::SHA1.hexdigest(Time.now.to_s) + extension
    if file_data.is_a?(StringIO)
      file_data.rewind
      self.temp_data = file_data.read
    else
      self.temp_path = file_data.path
    end
     #callback after attachment is uploaded
    after_attachment_uploaded
  end</pre>
<p>Please let us know if you have any issues using above code or have any questions.</p>
<h3>References</h3>
<ul>
<li><a href="http://swfupload.org/">SWFUpload</a></li>
<li><a href="http://rubyonrails.org/"><strong>Ruby on Rails</strong></a></li>
<li><a href="http://airbladesoftware.com/notes/uploading-files-with-swfupload">Uploading Files using SWFUpload</a></li>
</ul>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fswfupload-attachmentfu-ruby-on-rails.html&amp;linkname=Upload%20files%20using%20attachment_fu%20and%20swfupload%20on%20rails" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fswfupload-attachmentfu-ruby-on-rails.html&amp;linkname=Upload%20files%20using%20attachment_fu%20and%20swfupload%20on%20rails" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fswfupload-attachmentfu-ruby-on-rails.html&amp;linkname=Upload%20files%20using%20attachment_fu%20and%20swfupload%20on%20rails" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fswfupload-attachmentfu-ruby-on-rails.html&amp;linkname=Upload%20files%20using%20attachment_fu%20and%20swfupload%20on%20rails" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fswfupload-attachmentfu-ruby-on-rails.html&amp;linkname=Upload%20files%20using%20attachment_fu%20and%20swfupload%20on%20rails" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fswfupload-attachmentfu-ruby-on-rails.html&amp;linkname=Upload%20files%20using%20attachment_fu%20and%20swfupload%20on%20rails" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fswfupload-attachmentfu-ruby-on-rails.html&amp;linkname=Upload%20files%20using%20attachment_fu%20and%20swfupload%20on%20rails" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fswfupload-attachmentfu-ruby-on-rails.html&amp;linkname=Upload%20files%20using%20attachment_fu%20and%20swfupload%20on%20rails" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fswfupload-attachmentfu-ruby-on-rails.html&amp;title=Upload%20files%20using%20attachment_fu%20and%20swfupload%20on%20rails" id="wpa2a_46"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/swfupload-attachmentfu-ruby-on-rails.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Custom Error messages for Jquery validation plugin</title>
		<link>http://www.ipragmatech.com/custom-messages-jquery-validation-plugin</link>
		<comments>http://www.ipragmatech.com/custom-messages-jquery-validation-plugin#comments</comments>
		<pubDate>Sat, 22 Jan 2011 20:33:48 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=373</guid>
		<description><![CDATA[We found a very good plugin for jquery validation at position absolute. We enjoyed the plugin and met most of our requirements but it lacked to show customized error message for a field. It uses generic messages for each form field so we done some modification in the plugin to meet our requirements. With modification, [...]]]></description>
			<content:encoded><![CDATA[<p>We found a very good plugin for jquery validation at position absolute. We enjoyed the plugin and met most of our requirements but it lacked to show customized error message for a field. It uses generic messages for each form field so we done some modification in the plugin to meet our requirements. With modification, plugin is allowed to display custom message for a form field.</p>
<p>We override buildprompt function from the validationengine and added functionality to pick the customized error message.</p>
<pre class="brush:js">var buildPrompt = $.validationEngine.buildPrompt;
$.validationEngine.buildPrompt = function(caller, promptText, type, ajaxed) {
  // Get the rules to map the message for a method
  var rulesRegExp = /\[(.*)\]/;
  var getRules = rulesRegExp.exec($(caller).attr('class'));
  var str = getRules[1];
  var pattern = /\[|,|\]/;
  var rules = str.split(pattern);
  //Check if title attribute present in the element
  //otherwise we shall use default error message
  if ($(caller).attr('title')) {
    var getMessages = rulesRegExp.exec($(caller).attr('title'));
    var str = getMessages[1];
    var pattern = /\[|,|\]/;
    var messages = str.split(pattern);

    var j = 0;
    newPrompt = "";
    for ( var i = 0; i &lt; rules.length; i++) {
     rules = $.validationEngine.settings.allrules[rules[i]]
      if (rules) {
        if (promptText.indexOf(rules.alertText) != -1) {

          newPrompt += "</pre>
<p class="errorMsg">&#8221; + messages[j] + &#8221; &#8220;; } j++; } } promptText = newPrompt; } buildPrompt(caller, promptText, type, ajaxed); }</p>
<p>So in the plugin, we have added error messages in the &#8216;title&#8217; attribute and this gives the flexibility to customize the error message for different field. So here is the example where custom error message can be added:</p>
<pre class="brush:html">
<input id="user" class="validate[required,custom[noSpecialCaracters],length[0,20]]" title="[* Desired username is required,* No special caracters allowed for  Desired username,* Desired username should have characters between 0 and 20]" type="text" name="user" value="" /></pre>
<p>Now validation engine would display custom error message as shown below:<br />
<img src="http://www.makeurownrules.com/m-geonames/validation.png" alt="Custom Error Validation Engine" /></p>
<p>Please feel free to add your comments/questions or Suggestions</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-messages-jquery-validation-plugin&amp;linkname=Custom%20Error%20messages%20for%20Jquery%20validation%20plugin" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-messages-jquery-validation-plugin&amp;linkname=Custom%20Error%20messages%20for%20Jquery%20validation%20plugin" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-messages-jquery-validation-plugin&amp;linkname=Custom%20Error%20messages%20for%20Jquery%20validation%20plugin" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-messages-jquery-validation-plugin&amp;linkname=Custom%20Error%20messages%20for%20Jquery%20validation%20plugin" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-messages-jquery-validation-plugin&amp;linkname=Custom%20Error%20messages%20for%20Jquery%20validation%20plugin" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-messages-jquery-validation-plugin&amp;linkname=Custom%20Error%20messages%20for%20Jquery%20validation%20plugin" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-messages-jquery-validation-plugin&amp;linkname=Custom%20Error%20messages%20for%20Jquery%20validation%20plugin" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-messages-jquery-validation-plugin&amp;linkname=Custom%20Error%20messages%20for%20Jquery%20validation%20plugin" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fcustom-messages-jquery-validation-plugin&amp;title=Custom%20Error%20messages%20for%20Jquery%20validation%20plugin" id="wpa2a_48"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/custom-messages-jquery-validation-plugin/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>RESTFul client using Spring+Maven on Android</title>
		<link>http://www.ipragmatech.com/rest-spring-maven-android</link>
		<comments>http://www.ipragmatech.com/rest-spring-maven-android#comments</comments>
		<pubDate>Sat, 22 Jan 2011 16:35:20 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[Android]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=352</guid>
		<description><![CDATA[Interested in diving into Restful client development on Android, but not exactly sure where to start then here is the article which can guide you to create Restful client on Android. This article assumes that reader of this article are familiar with Android development and also know about Restful service.Spring framework is very popular framework [...]]]></description>
			<content:encoded><![CDATA[<p>Interested in diving into Restful client development on Android, but not exactly sure where to start then here is the article which can guide you to create Restful client on Android. This article assumes that reader of this article are familiar with Android development and also know about Restful service.Spring framework is very popular framework for j2ee and it come up with framework for mobile too.</p>
<p>In this Artcle, I used geonames.org Rest service to fetch the near places for a specific postal code which in radius.So first of we need to configure the project with maven. Please refer <a href="http://www.wakaleo.com/blog/302-android-development-with-maven">this</a> to get the details of configuring maven for Android.</p>
<p>Your pom.xml file should look like this:</p>
<pre class="brush:xml">
    src
    ${project.artifactId}

        com.jayway.maven.plugins.android.generation2
        maven-android-plugin
        ${maven-android-plugin-version}

${android.home}
${android-platform}

            Android2.1

          true
          true

        true

        maven-compiler-plugin
        ${maven-compiler-plugin-version}</pre>
<p>After configuring the android project with maven, we are ready for some action. We need to connect to geonames.org to get the data from the rest service. Using spring platform for mobile, its very easy to do that. So here is the code which connects to service and fetch the results:</p>
<pre class="brush:java">  // Create a new RestTemplate instance
  RestTemplate restTemplate = new RestTemplate();

  // The HttpComponentsClientHttpRequestFactory uses the
  // org.apache.http package to make network requests
  restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory());

  // The URL for making the GET request
  final String url = "http://ws.geonames.org/findNearbyPostalCodesJSON?postalcode={postalCode}&amp;country={countryCode}&amp;radius={radius}";

  // Initiate the HTTP GET request, expecting an array of State
  // objects in response
  PostalCodes result = restTemplate.getForObject(url,
      PostalCodes.class, this.postalCode, this.countryCode,
      this.radius);</pre>
<p>In case restful service uses digest authentication then you can use this:</p>
<pre class="brush:java">DefaultHttpClient client = new DefaultHttpClient();
Credentials defaultcreds = new UsernamePasswordCredentials("xxxx", "xxxx");

client.getCredentialsProvider()
  .setCredentials(new AuthScope("xxxx", 80, AuthScope.ANY_REALM), defaultcreds);
// The HttpComponentsClientHttpRequestFactory uses the
// org.apache.http package to make network requests
restTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(client));</pre>
<p>The response from service returns json objects so we require pojo objects to populate the response and use them in android client. So we need to create two Pojo as</p>
<pre class="brush:java">public class PostalCodes {
	private PostalCode[] postalCodes;
..
}
public class PostalCode {
	private String adminName2;
	private String adminCode2;
	private String adminCode1;
	private String postalCode;
	private String countryCode;
	private Double lng;
	private String placeName;
	private Double lat;
	private String adminName1;
...
}</pre>
<p>So all code is in place and its time to build the android project using:</p>
<pre class="brush:shell">mvn clean install</pre>
<p>We can start the emulator using</p>
<pre class="brush:shell">mvn android:emulator-start</pre>
<p>We can deploy the application using</p>
<pre class="brush:shell"> mvn android:deploy</pre>
<p>Home Screen for the android client would be:<br />
<img src="http://makeurownrules.com/m-geonames/m-geonames-home.png" alt="Home Screen for android client" /></p>
<p>Results from Restful service:<br />
<img src="http://makeurownrules.com/m-geonames/m-geonames-list.png" alt="Result Screen for android client" /></p>
<p>So we have created restful client for android without much efforts. Please feel free to send your comments/questions.</p>
<p>You can find the source code <a href="http://code.google.com/p/geonames-android/">here</a></p>
<p>References:</p>
<p><a href="http://www.springsource.org/spring-android">Spring-Android</a><a href="http://developer.android.com/index.html">Android</a><a href="http://www.geonames.org/export/web-services.html">geonames</a><a href="http://www.wakaleo.com/blog/302-android-development-with-maven">Android Development with Maven</a></p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Frest-spring-maven-android&amp;linkname=RESTFul%20client%20using%20Spring%2BMaven%20on%20Android" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Frest-spring-maven-android&amp;linkname=RESTFul%20client%20using%20Spring%2BMaven%20on%20Android" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Frest-spring-maven-android&amp;linkname=RESTFul%20client%20using%20Spring%2BMaven%20on%20Android" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Frest-spring-maven-android&amp;linkname=RESTFul%20client%20using%20Spring%2BMaven%20on%20Android" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Frest-spring-maven-android&amp;linkname=RESTFul%20client%20using%20Spring%2BMaven%20on%20Android" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Frest-spring-maven-android&amp;linkname=RESTFul%20client%20using%20Spring%2BMaven%20on%20Android" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Frest-spring-maven-android&amp;linkname=RESTFul%20client%20using%20Spring%2BMaven%20on%20Android" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Frest-spring-maven-android&amp;linkname=RESTFul%20client%20using%20Spring%2BMaven%20on%20Android" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Frest-spring-maven-android&amp;title=RESTFul%20client%20using%20Spring%2BMaven%20on%20Android" id="wpa2a_50"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/rest-spring-maven-android/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Image cropping and uploading to Amazon S3 using Ruby on Rails</title>
		<link>http://www.ipragmatech.com/image_croping_upload_ruby_on_rails</link>
		<comments>http://www.ipragmatech.com/image_croping_upload_ruby_on_rails#comments</comments>
		<pubDate>Sun, 14 Nov 2010 09:57:46 +0000</pubDate>
		<dc:creator>sundeep.goyal</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=327</guid>
		<description><![CDATA[The image cropping and uploading is essential part of any web application now days. Recently, I was working on a web application built on ROR platform. Initially we were using attachment_fu gem for image uploading but later there were requirements of cropping the image. I looked for the option for cropping in the attachment_fu but [...]]]></description>
			<content:encoded><![CDATA[<p>The image cropping and uploading is essential part of any web application now days. Recently, I was working on a web application built on ROR platform. Initially we were using attachment_fu gem for image uploading but later there were requirements of cropping the image. I looked for the option for cropping in the attachment_fu but couldn&#8217;t found any option for image cropping in it. Finally after go through documentation for attachment_fu and googling for alternative, I found a gem called &#8216;Paperclip&#8217;. Paperclip gem is used for image upload and cropping but no straight forward integration with attachment_fu. So, I come up with idea of integrating attachment_fu with image cropping feature and shall explain step to step implementation of image cropping using attachment_fu.</p>
<p><strong>Image Crop:</strong></p>
<p>There are many javascripts from <a href="http://www.hotscripts.com/blog/javascript-image-cropping-scripts/" target="_blank">hotscripts</a> which can be used for image cropping and I have used one of the javasript &#8220;Javascript Image Cropper UI&#8221; .</p>
<p><strong>Image Processing</strong></p>
<p>The above javascript shall give us the dimensions for the cropped image and we need to process the image using gem &#8216;RMagick&#8217;</p>
<pre class="brush:rails">=start rdoc
This method takes crop image dimensions along with the original image path
and re-sized the image to the desired size
x: left most x coordinate of image for cropped image from JavaScript
y: left most y coordinate of image for cropped image from JavaScript
Width: width of image for cropped image from JavaScript
Height: height of image for cropped image from JavaScript
Path: Image path from JavaScript
=end

def self.update_attributes_crop(x,y,width,height,path)

    # Get the path of the Directory where Image should be stored
    path = File.dirname(__FILE__) + "/../../public/#{path}"

    orig_img = Magick::ImageList.new(path)

    scale = orig_img.crop(x.to_i,y.to_i,width.to_i,height.to_i, true)

    crop_img = Magick::Image.new(width.to_i,height.to_i)

    orig_img = crop_img.composite(scale,0,0,Magick::OverCompositeOp)

    orig_img.write(path)

end</pre>
<p><strong>Upload image to Amazon S3</strong><br />
If you want to upload the image to Amazon S3 then you can use :<br />
S3_copy(source, destination, bucket) line of code in your controller</p>
<pre class="brush:rails">=start rdoc
This method upload the file from local drive to Amazon S3 bucket
Source: source(path) of image from rails server
Destination: destination (relative path) of Image on S3 server
Bucket: your S3 bucket name for image upload
=end
def S3_copy(source, destination, bucket)

	AWS::S3::Base.establish_connection!(

	:access_key_id =&gt; S3_access_key_id,

	:secret_access_key =&gt; S3_secret_access_key

	)

	AWS::S3::S3Object.copy(source,destination,bucket,:access =&gt; :public_read)

	policy = AWS::S3::S3Object.acl(destination,bucket)
	policy.grants &lt;&lt; AWS::S3::ACL::Grant.grant(:public_read)
	policy.grants &lt;&lt; AWS::S3::ACL::Grant.grant(:public_read_acp)

	begin

		AWS::S3::S3Object.acl(destination, bucket, policy)

	rescue

		p 'Issue occurred while granting access for the file'

	end

end</pre>
<p>I hope using above approach you can do image cropping and uploading. Please let me know if you have any questions</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimage_croping_upload_ruby_on_rails&amp;linkname=Image%20cropping%20and%20uploading%20to%20Amazon%20S3%20using%20Ruby%20on%20Rails" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimage_croping_upload_ruby_on_rails&amp;linkname=Image%20cropping%20and%20uploading%20to%20Amazon%20S3%20using%20Ruby%20on%20Rails" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimage_croping_upload_ruby_on_rails&amp;linkname=Image%20cropping%20and%20uploading%20to%20Amazon%20S3%20using%20Ruby%20on%20Rails" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimage_croping_upload_ruby_on_rails&amp;linkname=Image%20cropping%20and%20uploading%20to%20Amazon%20S3%20using%20Ruby%20on%20Rails" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimage_croping_upload_ruby_on_rails&amp;linkname=Image%20cropping%20and%20uploading%20to%20Amazon%20S3%20using%20Ruby%20on%20Rails" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimage_croping_upload_ruby_on_rails&amp;linkname=Image%20cropping%20and%20uploading%20to%20Amazon%20S3%20using%20Ruby%20on%20Rails" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimage_croping_upload_ruby_on_rails&amp;linkname=Image%20cropping%20and%20uploading%20to%20Amazon%20S3%20using%20Ruby%20on%20Rails" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimage_croping_upload_ruby_on_rails&amp;linkname=Image%20cropping%20and%20uploading%20to%20Amazon%20S3%20using%20Ruby%20on%20Rails" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fimage_croping_upload_ruby_on_rails&amp;title=Image%20cropping%20and%20uploading%20to%20Amazon%20S3%20using%20Ruby%20on%20Rails" id="wpa2a_52"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/image_croping_upload_ruby_on_rails/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improve query speed in the MySQL for large data</title>
		<link>http://www.ipragmatech.com/improve-speed-mysql-large-data</link>
		<comments>http://www.ipragmatech.com/improve-speed-mysql-large-data#comments</comments>
		<pubDate>Tue, 19 Oct 2010 08:59:23 +0000</pubDate>
		<dc:creator>sundeep.goyal</dc:creator>
				<category><![CDATA[LAMP]]></category>
		<category><![CDATA[Performance Optimization]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=319</guid>
		<description><![CDATA[I was executing select query which had 4-5 table join on large data set for report and query was taking too much time or not giving any result even after an hour even tables were proper indexed. Later on I started to find out the reason of this behavior and found that there is some [...]]]></description>
			<content:encoded><![CDATA[<p>I was executing select query which had 4-5 table join on large data set for report and query was taking too much time or not giving any result even after an hour even tables were proper indexed. Later on I started to find out the reason of this behavior and found that there is some problem in mysql&#8217;s configurations.</p>
<p>I have to change mysql configuration file( my.cnf) as:</p>
<p>1. tmp_table_size: from 32M  to 128M (This might not work because of <a href="http://www.mysqlperformanceblog.com/2007/01/19/tmp_table_size-and-max_heap_table_size/" target="_blank">known bug</a>)<br />
2. max_heap_table_size: 32M to 128M</p>
<p>After this change, query is taking around 10 seconds for execution which is quite faster.</p>
<p><strong>Reason:</strong></p>
<p>Mysql creates temporary table for  the results is an on-disk table.If an internal temporary table is created initially as an in-memory table but becomes too large, MySQL automatically converts it to an on-disk table. The maximum size for in-memory temporary tables is the minimum of the tmp_table_size and <code>max_heap_table_size</code> values.The <code>max_heap_table_size</code> system variable determines how large the table is permitted to grow and there is no conversion to on-disk format.</p>
<p>If<code> the value of max_heap_table_size is small then </code>converts in-memory table to an on-disk table.Due to this on-disk table, it would take too much time for I/O read in comparison of  in-memory table(temp table).</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-speed-mysql-large-data&amp;linkname=Improve%20query%20speed%20in%20the%20MySQL%20for%20large%20data" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-speed-mysql-large-data&amp;linkname=Improve%20query%20speed%20in%20the%20MySQL%20for%20large%20data" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-speed-mysql-large-data&amp;linkname=Improve%20query%20speed%20in%20the%20MySQL%20for%20large%20data" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-speed-mysql-large-data&amp;linkname=Improve%20query%20speed%20in%20the%20MySQL%20for%20large%20data" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-speed-mysql-large-data&amp;linkname=Improve%20query%20speed%20in%20the%20MySQL%20for%20large%20data" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-speed-mysql-large-data&amp;linkname=Improve%20query%20speed%20in%20the%20MySQL%20for%20large%20data" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-speed-mysql-large-data&amp;linkname=Improve%20query%20speed%20in%20the%20MySQL%20for%20large%20data" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-speed-mysql-large-data&amp;linkname=Improve%20query%20speed%20in%20the%20MySQL%20for%20large%20data" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fimprove-speed-mysql-large-data&amp;title=Improve%20query%20speed%20in%20the%20MySQL%20for%20large%20data" id="wpa2a_54"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/improve-speed-mysql-large-data/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Backup and Restore a Large MySQL database</title>
		<link>http://www.ipragmatech.com/backup-restore-mysql</link>
		<comments>http://www.ipragmatech.com/backup-restore-mysql#comments</comments>
		<pubDate>Sat, 16 Oct 2010 07:48:13 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[LAMP]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=311</guid>
		<description><![CDATA[Recently I was working on a large web-application and had to port it to new server. The main challenge was how to take the backup of the huge database and restore it on new server. Phpmyadmin was not able to take the backup of the database because of timeout issue with Apache. So I decided [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was working on a large web-application and had to port it to new server. The main challenge was how to take the backup of the huge database and restore it on new server. Phpmyadmin was not able to take the backup of the database because of timeout issue with Apache. So I decided to use mysql&#8217;s utility &#8216;mysqldump&#8217; for the database backup. I also want to transfer data to new server so I have to compress the database dump. It was quite easy</p>
<p><strong>Backup MySQL Database</strong></p>
<pre class="brush:shell">$mysqldump -u {username} -p{password} {database} | gzip -9 &gt; [database.sql.gz]</pre>
<p>We can use scp utility to transfer this database dump to new server. if you are not aware of scp then please google and you shall find lots of information about the usage</p>
<p>We can easy extract the data by using gzip</p>
<pre class="brush:shell">$gzip database.sql.gz</pre>
<p><strong>Restore MySQL Database</strong><br />
This part is tricky as mysql dump size grow. A simple command for restoring database is</p>
<pre class="brush:shell">$mysql -u {username} -p{password} {database} &lt; database.sql</pre>
<p>or use this in case you have compressed file</p>
<pre class="brush:shell">gunzip &lt; {database.sql.gz} |mysql -u {username} -p{password} {database}</pre>
<p>This should have done the magic of restoring the database but NO for larger database. For restoring large database, you must change configurations file my.cnf or specify the &#8211;max_allow_packet =1G during restore command.</p>
<pre class="brush:shell">[mysqld] section
max_allowed_packet= 1G</pre>
<p>Please note that mysql allows up to 1G for max_allowed_packet.</p>
<p>If your packet size(not database size) is more than 1G then consider &#8211;extended-insert off during database dump. It shall take more time for database restore but it would work.</p>
<p>I would like to see your comments on this.</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fbackup-restore-mysql&amp;linkname=Backup%20and%20Restore%20a%20Large%20MySQL%20database" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fbackup-restore-mysql&amp;linkname=Backup%20and%20Restore%20a%20Large%20MySQL%20database" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fbackup-restore-mysql&amp;linkname=Backup%20and%20Restore%20a%20Large%20MySQL%20database" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fbackup-restore-mysql&amp;linkname=Backup%20and%20Restore%20a%20Large%20MySQL%20database" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fbackup-restore-mysql&amp;linkname=Backup%20and%20Restore%20a%20Large%20MySQL%20database" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fbackup-restore-mysql&amp;linkname=Backup%20and%20Restore%20a%20Large%20MySQL%20database" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fbackup-restore-mysql&amp;linkname=Backup%20and%20Restore%20a%20Large%20MySQL%20database" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fbackup-restore-mysql&amp;linkname=Backup%20and%20Restore%20a%20Large%20MySQL%20database" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fbackup-restore-mysql&amp;title=Backup%20and%20Restore%20a%20Large%20MySQL%20database" id="wpa2a_56"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/backup-restore-mysql/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Minify, Compress and Synch your assets on Amazon S3 using Capistrano and Rails</title>
		<link>http://www.ipragmatech.com/ruby-on-rails/minify-compress-synch-amazons3-capistrano</link>
		<comments>http://www.ipragmatech.com/ruby-on-rails/minify-compress-synch-amazons3-capistrano#comments</comments>
		<pubDate>Sat, 02 Oct 2010 10:46:34 +0000</pubDate>
		<dc:creator>Kapil Jain</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.makeurownrules.com/?p=296</guid>
		<description><![CDATA[I hope every one is aware of Amazon&#8217;s S3 service and using this service for Static contents like JS/CSS/Images. It&#8217;s a wonderful storage server with high-performance and reliability at fairly low price.I am using this service for my project and main challenge was to automate the process of uploading the static contents on the S3. [...]]]></description>
			<content:encoded><![CDATA[<p>I hope every one is aware of Amazon&#8217;s S3 service and using this service for Static contents like JS/CSS/Images. It&#8217;s a wonderful storage server with high-performance and reliability at fairly low price.I am using this service for my project and main challenge was to automate the process of uploading the static contents on the S3.</p>
<p>I wanted to speed up the mobile website so I decided to do following:</p>
<ul>
<li>Minify the CSS and JS files</li>
<li>Gzip Compression of minified files</li>
<li>Uploading the Static Contents on Amazon S3</li>
</ul>
<p>I wanted to use Capistrano script to automate the process but found no straight forward solution. So I decided that I build the solution and Share it with you guys <img src='http://www.ipragmatech.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p><strong>Pre-Requisites:</strong><br />
Following are the list of plugins required on your host machine</p>
<ul>
<li><a href="http://www.capistranorb.com/">Capistrano</a> 2.0.0 or greater</li>
<li><a href="http://developer.yahoo.com/yui/compressor/">YUI Compressor</a> 2.4.2 or greater (For this you need java)</li>
<li><a href="http://amazon.rubyforge.org/">AWS-S3</a> Gem</li>
<li>Capistrano plugin extension <a href="http://scottpatten.ca/projects/synching-your-amazon-s3-asset-host-using-capistrano.html">S3 Asset Host Syncher</a></li>
<li>gzip</li>
</ul>
<p><strong>Installation</strong><br />
First we need to set up Capistrano for our project and generate a capFile for the deployment. We also need to install supporting gems and libraries. Type following from the Root of your project:</p>
<pre class="brush:shell">$&gt; sudo gem install capistrano
$&gt; sudo gem install aws-s3
$&gt;ruby script/plugin install git://github.com/spatten/synch_s3_asset_host.git (Make sure its installed in /vendor/plugins/synch_s3_asset_host otherwise download the plugin from site).
$&gt;wget http://yuilibrary.com/downloads/download.php?file=2a526a9aedfe2affceed1e1c3f9c0579 (Extract the yuicompressor-xxx.jar and put it in /vendor/plugins/yuicompressor directory).</pre>
<p><strong>Capistrano configuration</strong></p>
<p>In RAILS_ROOT/config/deploy.rb</p>
<p>Specify one of your web hosts as an “asset_host_syncher”. If you only have one web host, you don’t make a new line for this,<br />
just edit the existing line that sets your :web role<br />
role :web, webserver1, :asset_host_syncher =&gt; true</p>
<p>Create a new task minify in the cap file:</p>
<pre class="brush:shell">task :minify do
  compressor = "java -jar #{current_path}/vendor/plugins/yuocompressor/yuicompressor-2.4.2.jar"
  #name of the javascript files to be minify and compressed
   js_list = ["xxxx","yyyyy"]
   javascript_path = #{current_path}/public/javascripts
   run  "cd #{javascript_path}"
   js_list.each do |js|
     run "#{compressor} --type js #{js}.js -o #{js}.min.js"
     run "gzip -c #{js}.min.js &gt;#{js}.min.js.gz"
  end

  #name of the style files to be minify and compressed
  css_list = ["xxxx","yyyy"]
  css_path = #{current_path}/public/stylesheets
  run ("cd #{css_path}")
  css_list.each do |css|
     run "#{compressor} --type css #{css}.css -o #{css}.min.css"
     run ("gzip -c #{css}.min.css &gt;#{js}.min.css.gz"
  end
  deploy::s3_asset_host:synch_public
end</pre>
<p>Configure Capistrano to minify before doing the final symlink task:</p>
<pre class="brush:shell">before "deploy:symlink", "minify"</pre>
<p><strong>S3 configuration</strong></p>
<p>Create a file in RAILS_ROOT/config called synch_s3_asset_host.yml. Add the following to it,<br />
and edit to suit:</p>
<p>AWS_ACCESS_KEY_ID: ‘your access key here’</p>
<p>AWS_SECRET_ACCESS_KEY: ‘your secret key here’</p>
<p>asset_host_name: “xyz.com”</p>
<p><strong><br />
Configure Single asset host</strong></p>
<p>For a single asset host, simply add the following line to RAILS_ROOT/config/environments/production.rb:</p>
<pre class="brush:rails">config.action_controller.asset_host = "http://xyz.com"</pre>
<p><strong><br />
Some tweaks in S3synch plugin</strong><br />
As you know that Amazon S3 have its own ways to use compressed css/js so we need few tweaks in the S3 Asset Host Syncher.To make it work gzip compression, I had to add following in the s3sync/s3sync.rb (Line 507)</p>
<pre class="brush:rails">if @path.include? '.gz'
  headers['Content-Encoding'] = 'gzip'
end</pre>
<p>Now we are ready to deploy our stuff on site and improve the performance of the site.</p>
<p><strong>Deploy</strong></p>
<pre class="brush:shell">$&gt; cap s3_asset_host:setup (No need if you have bucket already)
$&gt; cap deploy</pre>
<p>We can add some more tweak like excluding directories for synching to Amazon S3 bucket and I have added that tweak in the comments of Asset Syncher. If there are better solutions, let me know. I&#8217;d love a simpler solution for this.</p>
<p><a class="a2a_button_facebook" href="http://www.addtoany.com/add_to/facebook?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fruby-on-rails%2Fminify-compress-synch-amazons3-capistrano&amp;linkname=Minify%2C%20Compress%20and%20Synch%20your%20assets%20on%20Amazon%20S3%20using%20Capistrano%20and%20Rails" title="Facebook" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/facebook.png" width="16" height="16" alt="Facebook"/></a><a class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fruby-on-rails%2Fminify-compress-synch-amazons3-capistrano&amp;linkname=Minify%2C%20Compress%20and%20Synch%20your%20assets%20on%20Amazon%20S3%20using%20Capistrano%20and%20Rails" title="LinkedIn" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/linkedin.png" width="16" height="16" alt="LinkedIn"/></a><a class="a2a_button_twitter" href="http://www.addtoany.com/add_to/twitter?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fruby-on-rails%2Fminify-compress-synch-amazons3-capistrano&amp;linkname=Minify%2C%20Compress%20and%20Synch%20your%20assets%20on%20Amazon%20S3%20using%20Capistrano%20and%20Rails" title="Twitter" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/twitter.png" width="16" height="16" alt="Twitter"/></a><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fruby-on-rails%2Fminify-compress-synch-amazons3-capistrano&amp;linkname=Minify%2C%20Compress%20and%20Synch%20your%20assets%20on%20Amazon%20S3%20using%20Capistrano%20and%20Rails" title="Delicious" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_dzone" href="http://www.addtoany.com/add_to/dzone?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fruby-on-rails%2Fminify-compress-synch-amazons3-capistrano&amp;linkname=Minify%2C%20Compress%20and%20Synch%20your%20assets%20on%20Amazon%20S3%20using%20Capistrano%20and%20Rails" title="DZone" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/dzone.png" width="16" height="16" alt="DZone"/></a><a class="a2a_button_technorati_favorites" href="http://www.addtoany.com/add_to/technorati_favorites?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fruby-on-rails%2Fminify-compress-synch-amazons3-capistrano&amp;linkname=Minify%2C%20Compress%20and%20Synch%20your%20assets%20on%20Amazon%20S3%20using%20Capistrano%20and%20Rails" title="Technorati Favorites" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/technorati.png" width="16" height="16" alt="Technorati Favorites"/></a><a class="a2a_button_yahoo_bookmarks" href="http://www.addtoany.com/add_to/yahoo_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fruby-on-rails%2Fminify-compress-synch-amazons3-capistrano&amp;linkname=Minify%2C%20Compress%20and%20Synch%20your%20assets%20on%20Amazon%20S3%20using%20Capistrano%20and%20Rails" title="Yahoo Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/yahoo.png" width="16" height="16" alt="Yahoo Bookmarks"/></a><a class="a2a_button_google_bookmarks" href="http://www.addtoany.com/add_to/google_bookmarks?linkurl=http%3A%2F%2Fwww.ipragmatech.com%2Fruby-on-rails%2Fminify-compress-synch-amazons3-capistrano&amp;linkname=Minify%2C%20Compress%20and%20Synch%20your%20assets%20on%20Amazon%20S3%20using%20Capistrano%20and%20Rails" title="Google Bookmarks" rel="nofollow" target="_blank"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/icons/google.png" width="16" height="16" alt="Google Bookmarks"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwww.ipragmatech.com%2Fruby-on-rails%2Fminify-compress-synch-amazons3-capistrano&amp;title=Minify%2C%20Compress%20and%20Synch%20your%20assets%20on%20Amazon%20S3%20using%20Capistrano%20and%20Rails" id="wpa2a_58"><img src="http://www.ipragmatech.com/wp-content/plugins/add-to-any/share_save_120_16.png" width="120" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://www.ipragmatech.com/ruby-on-rails/minify-compress-synch-amazons3-capistrano/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  www.ipragmatech.com/feed ) in 0.89298 seconds, on May 19th, 2012 at 4:52 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 26th, 2012 at 4:52 pm UTC -->
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- Quick Cache Is Fully Functional :-) ... A Quick Cache file was just served for (  www.ipragmatech.com/feed ) in 0.04646 seconds, on May 20th, 2012 at 10:59 am UTC. -->
