<?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>Sun, 05 Feb 2012 09:58:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<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[Home]]></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_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-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[Home]]></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 href="http://www.ipragmatech.com/wp-content/uploads/2011/11/SocialEngine-Event-Calendar.png" rel="lightbox" title="Displays events as a list or within a calendar grid"><img 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" title="SocialEngine-Event-Calendar" width="520" height="431" class="size-full wp-image-638" /></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_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/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[Home]]></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_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/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[Home]]></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 href="http://www.ipragmatech.com/wp-content/uploads/2011/11/socialkidspot-apache.png" rel="lightbox" title="There were spikes in the apache&#39;s access during the starting of September month when only Apache was used."><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 href="http://www.ipragmatech.com/wp-content/uploads/2011/11/SocialKidspot-Processes.png" rel="lightbox" title="Apache used to use 150 processes in month of September and resulted into site crash"><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 href="http://www.ipragmatech.com/wp-content/uploads/2011/11/socialkidspot-memory.png" rel="lightbox" title="Memory usages reduced drastically after ngnix acting as reverse proxy"><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 href="http://www.ipragmatech.com/wp-content/uploads/2011/11/socialkispot-ngnix.png" rel="lightbox" 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"><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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%20Apache%20Combo" 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/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[Home]]></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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%20Handle%20HTTP%2F1.1%20401%20Unauthorized%20and%20SERVICE_NOT_AVAILABLE%20Error" 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/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[Home]]></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_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/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[Home]]></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_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/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[Home]]></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_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/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[Home]]></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_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/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[Home]]></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_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/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[Home]]></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_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/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[Home]]></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 <info@makeurownrules.com/>
 */
 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()->params['facebook'] = new FacebookWrapper(array(
      'appId'  => 'appId',
      'secret' => 'secretKey',
      'cookie' => true,
      'appName' => 'App Name',
      'canvasPage' => 'http://apps.facebook.com/appname/',
      'canvasUrl'  => '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()->params['facebook'];
    $session = $facebook->getSession();
    $fbme = null;
    if ($session) {
      try {
        $uid = $facebook->getUser();
        $fbme = $facebook->api('/me');
      } catch (FacebookApiException $e) {
         //handle error
      }
    }
    if ($fbme) {
      // call $filterChain->run() to continue filtering and action execution
      $filterChain->run();
    }
    else {
      $appId = $facebook->getAppId();
      $canvasUrl = $facebook->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.
        "&#038;client_id=".$facebook->getAppId().
        "&#038;redirect_uri=".urlencode($canvasUrl);
      location =  'top.location.href=';
     echo("<script>".$location. $loginUrl . "'</script>");
      Yii::app()->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()->params['facebook'];
                $myuid = $facebook->getUser();
	  // renders the view file 'protected/views/site/index.php'
		// using the default layout 'protected/views/layouts/main.php'
		$this->render('index',array('myuid'=> $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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%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%26%238211%3B%20Yii%20Framework%20and%20Graph%20API" 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/create-facebook-yiiframework-graphapi.html/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>publish swf 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[Home]]></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();?>', // 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 &#038;&#038; 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&#038;link=link&#038;picture=picture &#038;caption=caption&#038;name=name&#038;source=source &#038;message=message&#038;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%20swf%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%20swf%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%20swf%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%20swf%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%20swf%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%20swf%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%20swf%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%20swf%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%20swf%20to%20wall%20using%20facebook%20Graph%20API" 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/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[Home]]></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" =>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/" alt="Attachment 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/" alt="SWF Upload">SWFUpload</a></li>
<li><a href="http://rubyonrails.org/" alt="Ruby on Rails"><strong>Ruby on Rails</strong></a></li>
<li>
     <a href="http://airbladesoftware.com/notes/uploading-files-with-swfupload" alt="Uploading Files using SWF Upload">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_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/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[Home]]></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 < rules.length; i++) {
     rules = $.validationEngine.settings.allrules[rules[i]]
      if (rules) {
        if (promptText.indexOf(rules.alertText) != -1) {

          newPrompt += "
<p class='errorMsg'>" + messages[j] + "

";

        }
        j++;
      }
    }
    promptText = newPrompt;
  }

  buildPrompt(caller, promptText, type, ajaxed);
}
</pre>
<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 value="" class="validate[required,custom[noSpecialCaracters],length[0,20]]" type="text" name="user" id="user" title="[* Desired username is required,* No special caracters allowed for  Desired username,* Desired username should have characters between 0 and 20]">
</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_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/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[Home]]></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">
<build>
    <sourceDirectory>src</sourceDirectory>
    <finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
        <groupId>com.jayway.maven.plugins.android.generation2</groupId>
        <artifactId>maven-android-plugin</artifactId>
        <version>${maven-android-plugin-version}</version>
        <configuration>
          <sdk>
<path>${android.home}</path>
<platform>${android-platform}</platform>
          </sdk>
          <emulator>
            <avd>Android2.1</avd>
          </emulator>
          <deleteConflictingFiles>true</deleteConflictingFiles>
          <undeployBeforeDeploy>true</undeployBeforeDeploy>
        </configuration>
        <extensions>true</extensions>
      </plugin>
<plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler-plugin-version}</version>
      </plugin>
    </plugins>
</build>
</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}&#038;country={countryCode}&#038;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>
<ul>
<ol><a href="http://www.springsource.org/spring-android">Spring-Android</a></ol>
<ol><a href="http://developer.android.com/index.html">Android</a></ol>
<ol><a href="http://www.geonames.org/export/web-services.html">geonames</a></ol>
<ol><a href="http://www.wakaleo.com/blog/302-android-development-with-maven">Android Development with Maven</a></ol>
</ul>
<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_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/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[Home]]></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_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/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[Home]]></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_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-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[Home]]></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 > [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} < database.sql
</pre>
<p>or use this in case you have compressed file</p>
<pre class="brush:shell">
gunzip < {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 --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 --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_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/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[Home]]></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">
$> sudo gem install capistrano
$> sudo gem install aws-s3
$>ruby script/plugin install git://github.com/spatten/synch_s3_asset_host.git (Make sure its installed in <ROOT>/vendor/plugins/synch_s3_asset_host otherwise download the plugin from site).
$>wget http://yuilibrary.com/downloads/download.php?file=2a526a9aedfe2affceed1e1c3f9c0579 (Extract the yuicompressor-xxx.jar and put it in <ROOT>/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 => 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 >#{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 >#{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">
$> cap s3_asset_host:setup (No need if you have bucket already)
$> 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_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/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.makeurownrules.com/feed ) in 0.84153 seconds, on Feb 5th, 2012 at 10:35 am UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 12th, 2012 at 10:35 am UTC -->
<!-- +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
<!-- Quick Cache Is Fully Functional :-) ... A Quick Cache file was just served for (  www.makeurownrules.com/feed ) in 0.04375 seconds, on Feb 8th, 2012 at 11:18 am UTC. -->
