<?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>Golygon</title>
	<atom:link href="http://www.golygon.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.golygon.com</link>
	<description>Journey of Golygon</description>
	<lastBuildDate>Thu, 29 Mar 2012 02:10:24 +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>Mobile Marketing</title>
		<link>http://www.golygon.com/2011/06/mobile-marketing/</link>
		<comments>http://www.golygon.com/2011/06/mobile-marketing/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 12:45:50 +0000</pubDate>
		<dc:creator>Sanchit Garg</dc:creator>
				<category><![CDATA[Marketing]]></category>
		<category><![CDATA[adwords]]></category>
		<category><![CDATA[mobile marketing]]></category>

		<guid isPermaLink="false">http://www.golygon.com/?p=285</guid>
		<description><![CDATA[This blog is for marketing novices to demonstrate how effective is mobile marketing with some numbers. Best rate one can get for sending SMS in India &#8211; 8 paise per SMS for minimum of 1 lakh SMS. In this case database of phone numbers is provided by the service provider. We did our tie up [...]]]></description>
			<content:encoded><![CDATA[<p>This blog is for marketing novices to demonstrate how effective is mobile marketing with some numbers.</p>
<p>Best rate one can get for sending SMS in India &#8211; 8 paise per SMS for minimum of 1 lakh SMS. In this case database of phone numbers is provided by the service provider. We did our tie up with <a href="http://www.cellnext.com" target="_blank">Cell Next</a> and they have further tie ups with Airtel, Tata, etc. to send SMS. They promised to send 1 lakh SMS and provide us reports that they were sent. We were told to verify this by calling random 10 numbers in the list and verify.</p>
<p>Time for facts:</p>
<ul>
<li>Total cost for SMS campaign = 8000 + 10.3% tax = 9000 INR</li>
<li>Approx calls expected from SMS receivers when the offer sent to them (my ad, or creative) is
<ul>
<li>V. Good = 200 (for e.g. when my ad is say: &#8220;trip to Rishikesh in 80% discount&#8221;)</li>
<li>Good = 100 (for e.g. when my ad is say: &#8220;go to Rishikesh for a fabulous trip. Get great deals!&#8221;)</li>
<li>ok = 50 (for e.g. when my ad is say: &#8220;go to Rishikesh for a fabulous trip.&#8221;)</li>
</ul>
</li>
<li>Remaining statistics in a tabular format (Google adwords vs Mobile marketing)</li>
<li>
<table>
<tbody>
<tr>
<th style="text-align: left;">Creative Quality</th>
<th style="text-align: left; width: 80px;">Cool</th>
<th style="text-align: left; width: 80px;">Good</th>
<th style="text-align: left; width: 60px;">ok</th>
</tr>
<tr>
<td>1. Expected Calls</td>
<td>200</td>
<td>100</td>
<td>50</td>
</tr>
<tr>
<td>2. Approx Website Hits</td>
<td>50</td>
<td>30</td>
<td>10</td>
</tr>
<tr>
<td>3. Cost per Lead(INR) (1+2/total Cost)</td>
<td>50</td>
<td>90</td>
<td>180</td>
</tr>
<tr>
<td>Google Adword Costs per Hit</td>
<td>40</td>
<td>50</td>
<td>70</td>
</tr>
</tbody>
</table>
<p>&nbsp;</li>
<li>Google adwords turn out to be a clear winner against mobile marketing for online websites. Mobile marketing may be useful in following circumstances
<ul>
<li>You need to target offline customers</li>
<li>Target them in a day or very quickly want to spread word among the masses</li>
<li>Your business can run on phone and you do not need website hits</li>
</ul>
</li>
<li>Targeting possibilities that mobile marketing provides
<ul>
<li>Demographic (you can target one particular city)</li>
<li>Income group (This group you can not target in google adwords) Not sure how effective this is in mobile marketing, but they claim it to be effective</li>
<li>Service Provider based</li>
</ul>
</li>
</ul>
<p><strong>Conclusion: </strong>Whereas Google provides you much more flexibility and various other options and is a clear winner against mobile marketing, unless you have specific requirements as mentioned above.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.golygon.com/2011/06/mobile-marketing/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sphinx &#8211; A Use case with Rails 3</title>
		<link>http://www.golygon.com/2011/06/sphinx-a-use-case-with-rails-3/</link>
		<comments>http://www.golygon.com/2011/06/sphinx-a-use-case-with-rails-3/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 11:21:46 +0000</pubDate>
		<dc:creator>Sanchit Garg</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.golygon.com/?p=306</guid>
		<description><![CDATA[Sphinx is open source search server used for full text search, we have used it with Rails and MySql database. Why Sphinx: Blazingly fast indexing and searching Variety of Text Processing features which are easy to adapt as per Application. Scalling: It can scale up to millions of queries per day. Performance: Sphinx indexes up [...]]]></description>
			<content:encoded><![CDATA[<p>Sphinx is open source search server used for full text search, we have used it with Rails and MySql database.</p>
<p>Why Sphinx:</p>
<ul>
<li>Blazingly fast indexing and searching</li>
<li>Variety of Text Processing features which are easy to adapt as per Application.</li>
<li>Scalling: It can scale up to millions of queries per day.</li>
<li>Performance: Sphinx indexes up to 10-15 MB of text per second per single CPU core.</li>
<li>Easy to write Sql Style Queries</li>
<li>Grouping and Clustering</li>
<li>Distrubuted Searching</li>
</ul>
<p><strong>Thinking Sphinx: </strong>Thinking Sphinx is a Ruby gem which helps us to connect Sphinx with Rails Active Record.<br />
We can attach our models to sphinx through Thinking Sphinx</p>
<p>Example:</p>
<p>Suppose we have Model Country with  fields: id, name, about, continent_id, capital, rating_no</p>
<p>class Country &lt; ActiveRecord::Base<br />
has_many :places_to_visits<br />
end</p>
<p>PlacesToVisit<br />
field: name, country_id</p>
<p>class PlacesToVisit &lt; ActiveRecord::Base<br />
belongs_to :country<br />
end</p>
<p>We want to have full text search on all fields of Country except id and its places to visit (has many association)</p>
<p>How to Use:<br />
We will write in  Country model</p>
<div style="padding: 10px 10px 2px 30px; background-color: black; color: white;">
class Country &lt; ActiveRecord::Base<br />
has_many :places_to_visits</p>
<p>define_index do<br />
indexes name, :sortable =&gt; true<br />
indexes about<br />
indexes rating_no<br />
indexes capital</p>
<p>indexes places_to_visits(:name), :as =&gt; :place, :sortable =&gt; true<br />
has continent_id<br />
end<br />
end
</p></div>
<p>you can read more about indexing here<br />
<a href="http://freelancing-god.github.com/ts/en/indexing.html" target="_blank">http://freelancing-god.github.com/ts/en/indexing.html</a></p>
<p>Searching example</p>
<p>Suppose we want to search countries with rating between 5 and 10.</p>
<p>Country.search params[:search], :with =&gt; {:rating_no =&gt; 5..10}</p>
<p>Here with is used for filtering, it accepts ruby array and ranges</p>
<p>A typical example with some advanced options</p>
<div style="padding: 10px 10px 2px 30px; background-color: black; color: white;">
Country(params[:search],<br />
:match_mode =&gt; :all,<br />
:field_weights =&gt; {:name =&gt; 20, :about =&gt; 10},<br />
:with =&gt; {:rating_no =&gt; 5..10 },<br />
:conditions =&gt; { :continent_id =&gt; 1},<br />
:page =&gt; params[:page], :per_page =&gt; 3)
</div>
<ul>
<li>We have provided field weights here so that while searching is applied name will have more priority than about</li>
<li>conditions is for full text searching specific attributes, :with is for filtering search results.</li>
<li>We use pagination with incorporating :page and :per_page parameters</li>
<li>match mode: How the key words will match to the fields</li>
<ul>
<li>:all &#8211; all records that has the complete key word will be returned</li>
<li>:any &#8211; means all records that has any of the keyword will be returned</li>
<li>:boolean &#8211; we can also use boolean operators with keywords</li>
<li>example: Country.search &#8216;India | USA&#8217;, :match_mode =&gt; :boolean</li>
</ul>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.golygon.com/2011/06/sphinx-a-use-case-with-rails-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Protected: First Blood!</title>
		<link>http://www.golygon.com/2011/06/first-blood/</link>
		<comments>http://www.golygon.com/2011/06/first-blood/#comments</comments>
		<pubDate>Sun, 05 Jun 2011 03:29:43 +0000</pubDate>
		<dc:creator>Sanchit Garg</dc:creator>
				<category><![CDATA[Experiences]]></category>
		<category><![CDATA[Operations]]></category>
		<category><![CDATA[first customer]]></category>
		<category><![CDATA[jayanti]]></category>
		<category><![CDATA[operations]]></category>

		<guid isPermaLink="false">http://www.golygon.com/?p=273</guid>
		<description><![CDATA[There is no excerpt because this is a protected post.]]></description>
			<content:encoded><![CDATA[<form action="http://www.golygon.com/wp-pass.php" method="post">
<p>This post is password protected. To view it please enter your password below:</p>
<p><label for="pwbox-273">Password:<br />
<input name="post_password" id="pwbox-273" type="password" size="20" /></label><br />
<input type="submit" name="Submit" value="Submit" /></p></form>
]]></content:encoded>
			<wfw:commentRss>http://www.golygon.com/2011/06/first-blood/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails &#8211; Speed up Server Start Time</title>
		<link>http://www.golygon.com/2011/05/rails-speed-up-server-start-time/</link>
		<comments>http://www.golygon.com/2011/05/rails-speed-up-server-start-time/#comments</comments>
		<pubDate>Sat, 21 May 2011 13:20:22 +0000</pubDate>
		<dc:creator>Sanchit Garg</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[load time]]></category>
		<category><![CDATA[production]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://www.golygon.com/?p=266</guid>
		<description><![CDATA[I use Amazon EC2 infrastructure to run my Ruby on Rails application and lately the load time for my application has gone in minutes, actually couple of minutes. After some googling I realized that it does not matter much if I have lots of models and controllers in my code. Most of the time consumed [...]]]></description>
			<content:encoded><![CDATA[<p>I use Amazon EC2 infrastructure to run my Ruby on Rails application and lately the load time for my application has gone in minutes, actually couple of minutes. After some googling I realized that it does not matter much if I have lots of models and controllers in my code. Most of the time consumed is while loading gems when the application starts. [<a href="http://stackoverflow.com/questions/3503175/rails-3-app-server-startup-time-is-long">Source</a>]</p>
<p>So I realized that in my Gemfile I have couple of Gems which were used only during<em> db:seed</em> and are not at all used in production server. But when server is restarted, rails still load these gems as they are mentioned in Gemfile. To avoid this, we can mention &#8216;require =&gt; false&#8217; for such gems and rails will do following:</p>
<ul>
<li>Install these gems whenever you run <em>bundle install</em></li>
<li>Do not load them when a server starts</li>
<li>You can still load them by explicitly specifying &#8220;require &lt;gemname&gt;&#8221; where you need them</li>
</ul>
<p>This brought down my server load time by 25% of original load time. Here is the log:</p>
<ul>
<li>Before using &#8216;require =&gt; true&#8217; :
<div style="padding: 10px 10px 2px 30px; background-color: black; color: white;"><strong>time r s -d </strong><br />
=&gt; Booting WEBrick<br />
=&gt; Rails 3.0.3 application starting in development on http://0.0.0.0:3000<br />
real	0m21.213s<br />
user	0m17.353s<br />
sys	0m1.852s</div>
</li>
<li>After using require =&gt; true (e.g. <em>gem testgem, :require =&gt; true</em>)
<div style="padding: 10px 10px 2px 30px; background-color: black; color: white;"><strong>time r s -d </strong><br />
=&gt; Booting WEBrick<br />
=&gt; Rails 3.0.3 application starting in development on http://0.0.0.0:3000&nbsp;<br />
real	0m17.351s<br />
user	0m13.865s<br />
sys	0m1.648s
</div>
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.golygon.com/2011/05/rails-speed-up-server-start-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Virtual Touring in Google Maps with Play/Pause feature</title>
		<link>http://www.golygon.com/2011/05/virtual-touring-in-google-maps-with-playpause-feature/</link>
		<comments>http://www.golygon.com/2011/05/virtual-touring-in-google-maps-with-playpause-feature/#comments</comments>
		<pubDate>Fri, 13 May 2011 19:24:41 +0000</pubDate>
		<dc:creator>Prabhat Gupta</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[google Maps Javascript API]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[moving marker]]></category>
		<category><![CDATA[Tour with play/pause feature]]></category>
		<category><![CDATA[virtual Tour]]></category>

		<guid isPermaLink="false">http://www.golygon.com/?p=240</guid>
		<description><![CDATA[Source code and sample html available at: https://github.com/prabgupt/googleMap_virtual_tour Usage: Mentioned in README present at git repo above Purpose of Plugin: You can display virtual tours between places on map. Currently, above sample show animation of marker moving along actual direction path between places located on map in sequence specified. Prequisite HTML, jQuery/JavaScript knowledge is required Basic [...]]]></description>
			<content:encoded><![CDATA[<p>Source code and sample html available at: <a href="https://github.com/prabgupt/googleMap_virtual_tour">https://github.com/prabgupt/googleMap_virtual_tour</a></p>
<p><em>Usage</em>: Mentioned in README present at git repo above</p>
<p><em>Purpose of Plugin</em>: You can display virtual tours between places on map. Currently, above sample show animation of marker moving along actual direction path between places located on map in sequence specified.</p>
<p><strong>Prequisite</strong></p>
<ul>
<li>HTML, jQuery/JavaScript knowledge is required</li>
<li>Basic knowledge about methods available in <a href="http://code.google.com/apis/maps/documentation/javascript/" target="_blank">google Maps Javascript API v3</a> is recommended</li>
</ul>
<p><strong>Summary about method&#8217;s inside custom <a href="https://github.com/prabgupt/googleMap_virtual_tour/blob/master/googleMaps.js" target="_blank">googleMaps js</a></strong></p>
<p>You&#8217;ll need to mainly use two method just like used in <a href="https://github.com/prabgupt/googleMap_virtual_tour/blob/master/virtual_tour_map.html" target="_blank">sample html</a>.</p>
<ul>
<li><strong>showMapForDay</strong>- This method would render the map with places displayed as markers and routes connecting those places. It takes following arguments:</li>
</ul>
<p style="padding-left: 60px;"><em>location 2D Array</em> &#8211; It contains single locations in format [lat, lng] and routes in format [[lat1, lng2], [lat1, lng2]]. You can skip routes from this array if in your case, there will always be a route between two consecutive locations. Routes then, can be auto-generated inside this method after modifying its code a little bit.</p>
<p style="padding-left: 60px;"><em>zoom </em>- zoom level which you want to set for your map</p>
<p style="padding-left: 60px;"><em>divId </em>- This is div element Id inside which you want to show map. Google Maps libraries need this as an argument and hence passed here.</p>
<p style="padding-left: 60px;"><em>Description Array</em> &#8211; This is array containing description about each location to be displayed in infoWindow when corresponding marker on map is clicked. This attribute allows HTML code inside it.</p>
<ul>
<li><strong>animateTrip &#8211; </strong>This method displays virtual tour between places in sequence as specified. It also supports play/pause feature. If this function is called when tour is running, it resumes tour while if it is called when no tour is running, it starts tour. Few of the arguments in this method are same as above method:</li>
</ul>
<p style="padding-left: 60px;"><em>divId </em>- This is div element Id inside which you want to show map. Google Maps libraries need this as an argument and hence passed here.</p>
<p style="padding-left: 60px;"><em>location 2D Array</em> &#8211; It contains single locations in format [lat, lng]</p>
<p style="padding-left: 60px;"><em>Description Array</em> &#8211; This is array containing description about each location to be displayed in infoWindow when place is reached while virtual tour. This attribute allows HTML code inside it.</p>
<p style="padding-left: 60px;"><em>callBack Function</em> &#8211; This function specifies what to do when tours end. In case not provided, map will halt at last location with its infoWindow opened.</p>
<p><strong>Main function which is actually responsible for enabling virtual tour animation</strong></p>
<ul>
<li><strong>animate </strong>- We call this function periodically using &#8216;setTimeout&#8217; Handler and each time this function is called, marker location is incremented by &#8216;step&#8217;(constant variable in js). In case current step is closer to the place we have located on map, marker is displayed for the location and corresponding infoWindow is opened by triggering &#8216;click&#8217; action on the marker. Likewise, we keep proceeding until we reach &#8216;eol&#8217;(another variable in js) which signifies total path distance to be traveled on map and is calculated dynamically based on map&#8217;s locations.</li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.golygon.com/2011/05/virtual-touring-in-google-maps-with-playpause-feature/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Party Animals</title>
		<link>http://www.golygon.com/2011/05/party-animals/</link>
		<comments>http://www.golygon.com/2011/05/party-animals/#comments</comments>
		<pubDate>Fri, 13 May 2011 06:52:04 +0000</pubDate>
		<dc:creator>Sanchit Garg</dc:creator>
				<category><![CDATA[Experiences]]></category>

		<guid isPermaLink="false">http://www.golygon.com/?p=255</guid>
		<description><![CDATA[Anurag Rawat joined as as our Sales and Marketing go-to-guy for 2 months from IIM Calcutta and today was his last day before he joins his new job in Boston Consulting Group. Team went out for a dinner and Anurag was more than willing to treat us Had some nice get together and lot of [...]]]></description>
			<content:encoded><![CDATA[<p>Anurag Rawat joined as as our Sales and Marketing go-to-guy for 2 months from IIM Calcutta and today was his last day before he joins his new job in Boston Consulting Group. Team went out for a dinner and Anurag was more than willing to treat us <img src='http://www.golygon.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
Had some nice get together and lot of <em>gyaan</em> flowed during &#8216;Happy Hours&#8217;. We were joined by Ananya, newest member to the team (6 months old), who loves eating desserts.<br />
We wish good luck to Anurag for his future adventures.</p>
<p>Some pictures to remember the good time:<br />
<div id="attachment_256" class="wp-caption alignnone" style="width: 458px"><a href="http://www.golygon.com/wp-content/uploads/2011/05/DSC01092.jpg"><img src="http://www.golygon.com/wp-content/uploads/2011/05/DSC01092.jpg" alt="" title="DSC01092" width="448" height="336" class="size-full wp-image-256" /></a><p class="wp-caption-text">Our Boss, Sankalp, is behind the camera and that explains the blurr picture</p></div><br />
<div id="attachment_257" class="wp-caption alignnone" style="width: 458px"><a href="http://www.golygon.com/wp-content/uploads/2011/05/DSC01082.jpg"><img src="http://www.golygon.com/wp-content/uploads/2011/05/DSC01082.jpg" alt="" title="What to order?" width="448" height="336" class="size-full wp-image-257" /></a><p class="wp-caption-text">What to order? Calls for a discussion meeting.</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.golygon.com/2011/05/party-animals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Plugin to upload video to YouTube directly from your site</title>
		<link>http://www.golygon.com/2011/05/plugin-to-upload-video-to-youtube-directly-from-your-site/</link>
		<comments>http://www.golygon.com/2011/05/plugin-to-upload-video-to-youtube-directly-from-your-site/#comments</comments>
		<pubDate>Thu, 12 May 2011 08:23:31 +0000</pubDate>
		<dc:creator>Prabhat Gupta</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[Google Data API]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[Rails 3]]></category>
		<category><![CDATA[Video Upload]]></category>
		<category><![CDATA[YouTube]]></category>

		<guid isPermaLink="false">http://www.golygon.com/?p=226</guid>
		<description><![CDATA[Source code and sample available at: https://github.com/prabgupt/youtube_video_upload_plugin Usage: Please note that sample is available for RoR3 but it can be easily converted for any underlying platform. Refer README in git repo above to know how to run it in RoR3. To see how to tweak code to use it for any other platform, keep reading the [...]]]></description>
			<content:encoded><![CDATA[<p>Source code and sample available at: <a href="https://github.com/prabgupt/youtube_video_upload_plugin">https://github.com/prabgupt/youtube_video_upload_plugin</a></p>
<p><em>Usage</em>: Please note that sample is available for RoR3 but it can be easily converted for any underlying platform. Refer README in git repo above to know how to run it in RoR3. To see how to tweak code to use it for any other platform, keep reading the post.</p>
<p><em>Purpose of this Utility</em>: It will upload end user&#8217;s video directly to youtube and is easily integratable within your website.</p>
<p><strong>Few Advantage:</strong></p>
<ul>
<li>No need to have storage on server machine as you can now dump/use all videos directly to/from youtube.</li>
<li>In case you have youtube channel, can directly organize video uploaded through your site to youtube channel.</li>
<li>NO need for end user to login to youtube first to upload video through your site.</li>
</ul>
<p><strong>Flow to upload video on YouTube</strong></p>
<ol>
<li>Website requests  token and upload URL from youtube for every new video request. This is needed to avoid having end user logging into his/her YouTube account.</li>
<li>Post your video to URL received in step#1 with parameter &#8216;nexturl&#8217;. &#8216;nexturl&#8217; is callback url to be called by YouTube with status and video_id once upload operation is completed with failure or success. You need to send token received in step#1 too along with.</li>
<li>Youtube invokes &#8216;nexturl&#8217; with status and video_id, if upload is successful. Process/store this video_id as this will be key from now onwards based on which you can perform operations on this video directly in YouTube.</li>
</ol>
<p>Source code contains of following things that you need to know:</p>
<p><a href="https://github.com/prabgupt/youtube_video_upload_plugin/blob/master/public/scripts/youtubeUtilAPIs.py" target="_blank">youtubeUtilAPIs.py</a>- Python script that uses <a href="http://code.google.com/p/gdata-python-client/">Google Data Python client library</a>.  This script contains few methods performing certain operation on youtube.</p>
<p style="padding-left: 60px;">Usage: py [-t &lt;comma separated title and description&gt;] [-u &lt;video_id&gt;] [-s &lt;video_id&gt;] [-d &lt;video_id&gt;]</p>
<p style="padding-left: 90px;">-t =&gt; to get token and url. Input required is comma separated video title and video description</p>
<p style="padding-left: 90px;">-u =&gt; to get youtube URL for that video. Input required is video_id</p>
<p style="padding-left: 90px;">-s =&gt; to get upload status of the video. Input required is video_id</p>
<p style="padding-left: 90px;">-d =&gt; to delete video from youtube. Input required is video_id</p>
<p style="padding-left: 30px;"><span style="text-decoration: underline;">Prerequisite</span>:</p>
<ul>
<li>
<ul>
<li>Please refer <a href="http://code.google.com/apis/gdata/articles/python_client_lib.html">Getting Started</a> guide. In nutshell, you need to install Python and then google Data Library as specified in the link.</li>
<li>Replace following senstive data inside python script; like developer key, password, etc. with that of yours. You will need to <a href="http://code.google.com/apis/youtube/dashboard/">sign in</a> for YouTube developer key. Once signed in, register you product and get values for below attributes. &#8216;source&#8217; and &#8216;client_id&#8217;   will be the name of the product you registered before.</li>
</ul>
</li>
</ul>
<p style="padding-left: 90px;">yt_service.developer_key = &#8216;xxxxxxx&#8217;</p>
<p style="padding-left: 90px;">yt_service.client_id = &#8216;xxxxxxx&#8217;</p>
<p style="padding-left: 90px;">yt_service.email = &#8216;xxxxxxx&#8217;</p>
<p style="padding-left: 90px;">yt_service.password = &#8216;xxxxxxxx&#8217;</p>
<p style="padding-left: 90px;">yt_service.source = &#8216;xxxxxxxxxx&#8217;</p>
<ul>
<li>Since above utility contains some sensitive data, hence for security reasons you would need to introduce a server side handler that will execute above script on client request and can send the required details back to client. In our case, we have introduced method &#8216;uploadToken&#8217; inside multimedia controller which execute python script and returns back token and url needed to upload video on youtube.</li>
</ul>
<p style="padding-left: 60px;"><div id="gist-968163" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'>&nbsp;<span class="k">def</span> <span class="nf">uploadToken</span></div><div class='line' id='LC2'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">cmd</span> <span class="o">=</span> <span class="no">Rails</span><span class="o">.</span><span class="n">root</span><span class="o">.</span><span class="n">to_s</span> <span class="o">+</span> <span class="s1">&#39;/public/scripts/youtubeUtilAPIs.py&#39;</span></div><div class='line' id='LC3'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">title</span> <span class="o">=</span> <span class="s2">&quot;Test Video&quot;</span></div><div class='line' id='LC4'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">description</span> <span class="o">=</span> <span class="s2">&quot;Test Video description&quot;</span></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">resp</span> <span class="o">=</span> <span class="sb">`</span><span class="si">#{</span><span class="n">cmd</span><span class="si">}</span><span class="sb"> -t &quot;</span><span class="si">#{</span><span class="n">title</span><span class="si">}</span><span class="sb">,</span><span class="si">#{</span><span class="n">description</span><span class="si">}</span><span class="sb">&quot;`</span></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">resp</span> <span class="o">=</span> <span class="n">resp</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;::&#39;</span><span class="p">)</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">response</span> <span class="o">=</span> <span class="p">(</span><span class="n">resp</span><span class="o">.</span><span class="n">length</span> <span class="o">==</span> <span class="mi">2</span><span class="p">)</span> <span class="p">?</span> <span class="p">{</span><span class="ss">:uploadUrl</span> <span class="o">=&gt;</span> <span class="n">resp</span><span class="o">[</span><span class="mi">0</span><span class="o">]</span><span class="p">,</span> <span class="ss">:token</span> <span class="o">=&gt;</span> <span class="n">resp</span><span class="o">[</span><span class="mi">1</span><span class="o">]</span><span class="p">}</span> <span class="p">:</span> <span class="s2">&quot;&quot;</span></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="n">respond_to</span> <span class="k">do</span> <span class="o">|</span><span class="nb">format</span><span class="o">|</span></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nb">format</span><span class="o">.</span><span class="n">js</span> <span class="p">{</span><span class="n">render</span> <span class="ss">:js</span> <span class="o">=&gt;</span> <span class="n">response</span><span class="o">.</span><span class="n">to_json</span><span class="p">}</span></div><div class='line' id='LC10'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">end</span></div><div class='line' id='LC11'>&nbsp;&nbsp;<span class="k">end</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/9885986309e63e38a598/234e0ff6328f24af6778e95212fe7920a7704dd8/getUploadToken.rb" style="float:right;">view raw</a>
            <a href="https://gist.github.com/9885986309e63e38a598#file_get_upload_token.rb" style="float:right;margin-right:10px;color:#666">getUploadToken.rb</a>
            <a href="https://gist.github.com/9885986309e63e38a598">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</p>
<ul>
<li>Below is the HTML code you&#8217;ll plug into your website to let end user select the video and upload it to youtube. Code just contains a form to have end use select the video and has action, token value blank at render time. If you have already noticed, there is async ajax request present at end of code which fetches upload URL and token from server at time page is loading and populate it inside form once ajax request gets completed.</li>
</ul>
<p style="padding-left: 60px;"><div id="gist-968142" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="nt">&lt;div</span> <span class="na">id=</span><span class="s">&quot;upload_video&quot;</span><span class="nt">&gt;</span></div><div class='line' id='LC2'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;field&quot;</span><span class="nt">&gt;</span></div><div class='line' id='LC3'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nt">&lt;form</span> <span class="na">action=</span><span class="s">&#39;&#39;</span> <span class="na">id=</span><span class="s">&quot;youtube_video_upload&quot;</span> <span class="na">method=</span><span class="s">&quot;post&quot;</span> <span class="na">enctype=</span><span class="s">&quot;multipart/form-data&quot;</span><span class="nt">&gt;</span></div><div class='line' id='LC4'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nt">&lt;input</span> <span class="na">name=</span><span class="s">&quot;file&quot;</span> <span class="na">type=</span><span class="s">&quot;file&quot;</span> <span class="na">class=</span><span class="s">&quot;multimedia_file&quot;</span><span class="nt">/&gt;</span></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;errMsg&quot;</span> <span class="na">style=</span><span class="s">&quot;display:none;color:red&quot;</span><span class="nt">&gt;</span></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You need to specify a file.</div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nt">&lt;/div&gt;</span></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;errMsg2&quot;</span> <span class="na">style=</span><span class="s">&quot;display:none;color:red&quot;</span><span class="nt">&gt;</span></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Video cannot be uploaded this time. Please try again after sometime.</div><div class='line' id='LC10'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nt">&lt;/div&gt;</span></div><div class='line' id='LC11'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nt">&lt;input</span> <span class="na">class=</span><span class="err"> </span><span class="s">&quot;token&quot;</span> <span class="na">name=</span><span class="s">&quot;token&quot;</span> <span class="na">type=</span><span class="s">&quot;hidden&quot;</span> <span class="na">value=</span><span class="s">&quot;&quot;</span><span class="nt">/&gt;</span></div><div class='line' id='LC12'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nt">&lt;input</span> <span class="na">value=</span><span class="s">&quot;Upload Video File&quot;</span> <span class="na">class=</span><span class="s">&quot;upload_button&quot;</span> <span class="na">type=</span><span class="s">&quot;submit&quot;</span> <span class="nt">/&gt;</span></div><div class='line' id='LC13'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nt">&lt;/form&gt;</span></div><div class='line' id='LC14'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nt">&lt;/div&gt;&lt;br/&gt;</span></div><div class='line' id='LC15'><span class="nt">&lt;/div&gt;</span></div><div class='line' id='LC16'><span class="nt">&lt;script&gt;</span></div><div class='line' id='LC17'>&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="nb">document</span><span class="p">).</span><span class="nx">ready</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s1">&#39; #youtube_video_upload .multimedia_file&#39;</span><span class="p">).</span><span class="nx">click</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC19'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">siblings</span><span class="p">(</span><span class="s1">&#39;.errMsg&#39;</span><span class="p">).</span><span class="nx">css</span><span class="p">(</span><span class="s2">&quot;display&quot;</span><span class="p">,</span> <span class="s2">&quot;none&quot;</span><span class="p">);</span></div><div class='line' id='LC20'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">children</span><span class="p">(</span><span class="s1">&#39;.errMsg2&#39;</span><span class="p">).</span><span class="nx">css</span><span class="p">(</span><span class="s2">&quot;display&quot;</span><span class="p">,</span> <span class="s2">&quot;none&quot;</span><span class="p">);</span></div><div class='line' id='LC21'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC22'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#youtube_video_upload&#39;</span><span class="p">).</span><span class="nx">submit</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC23'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span> <span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">children</span><span class="p">(</span><span class="s1">&#39;.multimedia_file&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">()</span> <span class="o">==</span> <span class="kc">null</span> <span class="o">||</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">children</span><span class="p">(</span><span class="s1">&#39;.multimedia_file&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span><span class="p">){</span></div><div class='line' id='LC24'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">children</span><span class="p">(</span><span class="s1">&#39;.errMsg&#39;</span><span class="p">).</span><span class="nx">css</span><span class="p">(</span><span class="s2">&quot;display&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">);</span></div><div class='line' id='LC25'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="kc">false</span><span class="p">;</span></div><div class='line' id='LC26'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span><span class="k">else</span> <span class="k">if</span> <span class="p">(</span><span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">children</span><span class="p">(</span><span class="s1">&#39;.token&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">()</span> <span class="o">==</span> <span class="kc">null</span> <span class="o">||</span> <span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">children</span><span class="p">(</span><span class="s1">&#39;.token&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">()</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span><span class="p">){</span></div><div class='line' id='LC27'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">children</span><span class="p">(</span><span class="s1">&#39;.errMsg2&#39;</span><span class="p">).</span><span class="nx">css</span><span class="p">(</span><span class="s2">&quot;display&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">);</span></div><div class='line' id='LC28'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="kc">false</span><span class="p">;</span></div><div class='line' id='LC29'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC30'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#youtube_video_upload&#39;</span><span class="p">).</span><span class="nx">children</span><span class="p">(</span><span class="s1">&#39;.upload_button&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;disabled&#39;</span><span class="p">,</span> <span class="s1">&#39;true&#39;</span><span class="p">);</span></div><div class='line' id='LC31'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC32'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#video_link&#39;</span><span class="p">).</span><span class="nx">click</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC33'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#add_link&quot;</span><span class="p">).</span><span class="nx">css</span><span class="p">(</span><span class="s2">&quot;display&quot;</span><span class="p">,</span> <span class="s2">&quot;none&quot;</span><span class="p">);</span></div><div class='line' id='LC34'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#upload_video&quot;</span><span class="p">).</span><span class="nx">css</span><span class="p">(</span><span class="s2">&quot;display&quot;</span><span class="p">,</span><span class="s2">&quot;&quot;</span><span class="p">);</span></div><div class='line' id='LC35'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC36'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#youtube_link&#39;</span><span class="p">).</span><span class="nx">click</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC37'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#upload_video&quot;</span><span class="p">).</span><span class="nx">css</span><span class="p">(</span><span class="s2">&quot;display&quot;</span><span class="p">,</span><span class="s2">&quot;none&quot;</span><span class="p">);</span></div><div class='line' id='LC38'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#add_link&quot;</span><span class="p">).</span><span class="nx">css</span><span class="p">(</span><span class="s2">&quot;display&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">);</span></div><div class='line' id='LC39'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.errMsg&#39;</span><span class="p">).</span><span class="nx">css</span><span class="p">(</span><span class="s2">&quot;display&quot;</span><span class="p">,</span> <span class="s2">&quot;none&quot;</span><span class="p">);</span></div><div class='line' id='LC40'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.errMsg2&#39;</span><span class="p">).</span><span class="nx">css</span><span class="p">(</span><span class="s2">&quot;display&quot;</span><span class="p">,</span> <span class="s2">&quot;none&quot;</span><span class="p">);</span></div><div class='line' id='LC41'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC42'>&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC43'>&nbsp;&nbsp;&nbsp;<span class="c1">// asyn ajax request to fetch upload URL and token from youtube</span></div><div class='line' id='LC44'>&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">.</span><span class="nx">get</span><span class="p">(</span><span class="s1">&#39;&lt;%= url_for(:action =&gt; &quot;uploadToken&quot;, :controller =&gt; &quot;multimedias&quot;, :only_path =&gt; false)%&gt;&#39;</span><span class="p">,</span><span class="kd">function</span><span class="p">(</span><span class="nx">data</span><span class="p">){</span></div><div class='line' id='LC45'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">if</span><span class="p">(</span><span class="nx">data</span> <span class="o">!=</span> <span class="s2">&quot;&quot;</span><span class="p">){</span></div><div class='line' id='LC46'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#youtube_video_upload&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;action&#39;</span><span class="p">,</span> <span class="nx">data</span><span class="p">.</span><span class="nx">uploadUrl</span> <span class="o">+</span> <span class="s1">&#39;?nexturl=&lt;%= url_for(:action =&gt; &quot;new&quot;, :controller =&gt; &quot;multimedias&quot;, :only_path =&gt; false)%&gt;&#39;</span><span class="p">);</span></div><div class='line' id='LC47'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#youtube_video_upload&#39;</span><span class="p">).</span><span class="nx">children</span><span class="p">(</span><span class="s1">&#39;.token&#39;</span><span class="p">).</span><span class="nx">val</span><span class="p">(</span><span class="nx">data</span><span class="p">.</span><span class="nx">token</span><span class="p">);</span></div><div class='line' id='LC48'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#youtube_video_upload&#39;</span><span class="p">).</span><span class="nx">children</span><span class="p">(</span><span class="s1">&#39;.errMsg2&#39;</span><span class="p">).</span><span class="nx">css</span><span class="p">(</span><span class="s2">&quot;display&quot;</span><span class="p">,</span> <span class="s2">&quot;none&quot;</span><span class="p">);</span></div><div class='line' id='LC49'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span><span class="k">else</span><span class="p">{</span></div><div class='line' id='LC50'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div><div class='line' id='LC51'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC52'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">},</span> <span class="s2">&quot;json&quot;</span><span class="p">);</span></div><div class='line' id='LC53'>&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC54'><span class="nt">&lt;/script&gt;</span></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/7235b56ea6c039a9cab0/ea97a003e5a0fac28c012ac3d363b3e972b5bd24/uploadVideotoYouTube.html" style="float:right;">view raw</a>
            <a href="https://gist.github.com/7235b56ea6c039a9cab0#file_upload_videoto_you_tube.html" style="float:right;margin-right:10px;color:#666">uploadVideotoYouTube.html</a>
            <a href="https://gist.github.com/7235b56ea6c039a9cab0">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>
</p>
]]></content:encoded>
			<wfw:commentRss>http://www.golygon.com/2011/05/plugin-to-upload-video-to-youtube-directly-from-your-site/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AutoCompletion script for world places using google geocode API</title>
		<link>http://www.golygon.com/2011/05/autocompletion-script-for-world-places-using-google-geocode-api/</link>
		<comments>http://www.golygon.com/2011/05/autocompletion-script-for-world-places-using-google-geocode-api/#comments</comments>
		<pubDate>Wed, 11 May 2011 00:26:20 +0000</pubDate>
		<dc:creator>Prabhat Gupta</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[autocomplete]]></category>
		<category><![CDATA[geocode locations]]></category>
		<category><![CDATA[google Maps]]></category>
		<category><![CDATA[JQuery]]></category>

		<guid isPermaLink="false">http://www.golygon.com/?p=206</guid>
		<description><![CDATA[Source code and README available at: https://github.com/prabgupt/geocode_autocompletion_js Purpose of this Utility: It will auto suggest world places based on user input Instructions  as well as sample HTML to use the code are mentioned inside README mentioned above. Making of geocode_autocomplete.js I&#8217;m assuming here that you are already familiar with JavaScript/jQuery. You&#8217;ll need to understand following things [...]]]></description>
			<content:encoded><![CDATA[<p>Source code and README available at: <a href="https://github.com/prabgupt/geocode_autocompletion_js">https://github.com/prabgupt/geocode_autocompletion_js</a></p>
<p><em>Purpose of this Utility</em>: It will auto suggest world places based on user input</p>
<p>Instructions  as well as sample HTML to use the code are mentioned inside README mentioned above.</p>
<p><strong>Making of geocode_autocomplete.js</strong></p>
<p>I&#8217;m assuming here that you are already familiar with JavaScript/jQuery. You&#8217;ll need to understand following things so as to proceed further:</p>
<ol>
<li><a title="AutoComplete jQuery UI" href="http://jqueryui.com/demos/autocomplete/" target="_blank">autocomple jQuery UI</a>: This jquery displays suggested list based on result passed to it</li>
<li><a href="http://code.google.com/apis/maps/documentation/geocoding/" target="_blank">Google Maps GeoCoding API usage</a>: I&#8217;d recommend you to go through &#8216;<a href="http://code.google.com/apis/maps/documentation/geocoding/#Results" target="_blank">Results</a>&#8216;  structure as it will help you to identify attributes you need to process based on your requirement. Once understood, rest would just be getting those attributes from result.</li>
</ol>
<div id="gist-965623" class="gist">

        <div class="gist-file">
          <div class="gist-data gist-syntax">
              <div class="highlight"><pre><div class='line' id='LC1'><span class="kd">var</span> <span class="nx">geocoder</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">google</span><span class="p">.</span><span class="nx">maps</span><span class="p">.</span><span class="nx">Geocoder</span><span class="p">();</span></div><div class='line' id='LC2'><br/></div><div class='line' id='LC3'><span class="nx">$</span><span class="p">(</span><span class="s1">&#39;.geocode_autocomplete&#39;</span><span class="p">).</span><span class="nx">live</span><span class="p">(</span><span class="s1">&#39;focus&#39;</span><span class="p">,</span> <span class="kd">function</span><span class="p">(){</span></div><div class='line' id='LC4'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="k">this</span><span class="p">).</span><span class="nx">autocomplete</span><span class="p">({</span></div><div class='line' id='LC5'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">source</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">request</span><span class="p">,</span> <span class="nx">response</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC6'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">geocoder</span><span class="p">.</span><span class="nx">geocode</span><span class="p">(</span> <span class="p">{</span><span class="s1">&#39;address&#39;</span><span class="o">:</span> <span class="nx">request</span><span class="p">.</span><span class="nx">term</span><span class="p">},</span> <span class="kd">function</span><span class="p">(</span><span class="nx">results</span><span class="p">,</span> <span class="nx">status</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC7'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#map_location&quot;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s2">&quot;value&quot;</span><span class="p">,</span><span class="s2">&quot;&quot;</span><span class="p">);</span></div><div class='line' id='LC8'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">response</span><span class="p">(</span><span class="nx">$</span><span class="p">.</span><span class="nx">map</span><span class="p">(</span><span class="nx">results</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">item</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC9'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">value</span> <span class="o">=</span> <span class="nx">item</span><span class="p">.</span><span class="nx">address_components</span><span class="p">[</span><span class="mi">0</span><span class="p">].</span><span class="nx">long_name</span><span class="p">;</span></div><div class='line' id='LC10'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="k">return</span> <span class="p">{</span></div><div class='line' id='LC11'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">label</span><span class="o">:</span> <span class="nx">item</span><span class="p">.</span><span class="nx">formatted_address</span><span class="p">,</span></div><div class='line' id='LC12'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">value</span><span class="o">:</span> <span class="nx">value</span><span class="p">,</span></div><div class='line' id='LC13'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">location</span><span class="o">:</span> <span class="nx">item</span><span class="p">.</span><span class="nx">geometry</span><span class="p">.</span><span class="nx">location</span><span class="p">,</span></div><div class='line' id='LC14'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">addr</span><span class="o">:</span> <span class="nx">item</span><span class="p">.</span><span class="nx">address_components</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span></div><div class='line' id='LC15'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}</span></div><div class='line' id='LC16'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">}));</span></div><div class='line' id='LC17'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">})</span></div><div class='line' id='LC18'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">},</span></div><div class='line' id='LC19'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">minLength</span><span class="o">:</span> <span class="mi">2</span><span class="p">,</span></div><div class='line' id='LC20'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">select</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">event</span><span class="p">,</span> <span class="nx">ui</span><span class="p">)</span> <span class="p">{</span></div><div class='line' id='LC21'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="nx">$</span><span class="p">(</span><span class="s2">&quot;#map_location&quot;</span><span class="p">).</span><span class="nx">html</span><span class="p">(</span><span class="s2">&quot;Latitude: &quot;</span> <span class="o">+</span> <span class="nx">ui</span><span class="p">.</span><span class="nx">item</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">lat</span><span class="p">()</span> <span class="o">+</span> <span class="s2">&quot; Longitude: &quot;</span><span class="o">+</span> <span class="nx">ui</span><span class="p">.</span><span class="nx">item</span><span class="p">.</span><span class="nx">location</span><span class="p">.</span><span class="nx">lng</span><span class="p">());</span></div><div class='line' id='LC22'>	    <span class="p">}</span></div><div class='line' id='LC23'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC24'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="p">});</span></div><div class='line' id='LC25'><br/></div></pre></div>
          </div>

          <div class="gist-meta">
            <a href="https://gist.github.com/raw/c92b776656b43b44f4a9/e8ed35acc2b1a2359c45279733aa832b0cb86eda/geocode_autocomplete.js" style="float:right;">view raw</a>
            <a href="https://gist.github.com/c92b776656b43b44f4a9#file_geocode_autocomplete.js" style="float:right;margin-right:10px;color:#666">geocode_autocomplete.js</a>
            <a href="https://gist.github.com/c92b776656b43b44f4a9">This Gist</a> brought to you by <a href="http://github.com">GitHub</a>.
          </div>
        </div>
</div>

<p><strong>StepWise description of above code:</strong></p>
<p># First we bind &#8216;focus&#8217; event to element so that on focus, we can attach autocomplete handler to it.</p>
<p># <strong>source </strong>requires map list that will get displayed as suggestion list. We are calling geocode function of google maps here treating input value as some address. You can change the attribute as per what you expect end user to provide.</p>
<p>On receiving response, we are populating map which will be shown as suggested list. An entry in this suggested list is kinda map containing multiple keys/values. You can add/remove keys as per your requirement.</p>
<p># <strong>minLength </strong>attr specifies minimum length of input after which it should try to find suggested list.</p>
<p># <strong>select </strong>attr contains functions which gets executed once an entry is selected. In our case, once an entry is selected we process its location(lat/lng) and displays it on UI. You can add your logic that you need to execute once an entry is selected.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.golygon.com/2011/05/autocompletion-script-for-world-places-using-google-geocode-api/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Include JS in the end &#8211; Demonstration</title>
		<link>http://www.golygon.com/2011/04/include-js-in-the-end-demonstration/</link>
		<comments>http://www.golygon.com/2011/04/include-js-in-the-end-demonstration/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 03:20:51 +0000</pubDate>
		<dc:creator>Sanchit Garg</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[why should we include javascripts in the end?]]></category>

		<guid isPermaLink="false">http://www.golygon.com/?p=193</guid>
		<description><![CDATA[I was experimenting on how can we improve a page loading time which has loads of JS and image files. It turns out that we can optimize it by including JS files in the end of HTML content. That gives the flexibility to browser to render images and JS files in parallel. The technical point [...]]]></description>
			<content:encoded><![CDATA[<p>I was experimenting on how can we improve a page loading time which has loads of JS and image files. It turns out that we can optimize it by including JS files in the end of HTML content. That gives the flexibility to browser to render images and JS files in parallel.<br />
The technical point of why should we include javascripts in the end, is that JS has the capability to alter the properties of HTML elements. Hence if the web developer has included JS earlier (say in the &lt;head&gt;), then this JS file might be modifying the HTML elements that are gonna get included in the &lt;body&gt;. In this case, browser first needs to know the properties that JS is applying on elements and only then it can fetch and load the elements. This halts the process of loading HTML elements when a JS is getting loaded.</p>
<p>Following are two screenshots where the same has been depicted. Please observe the network request for get_top_menu.js that has been highlighted. I have moved its position from &lt;head&gt; (screenshot 1) to &lt;footer&gt; (screenshot 2).<br />

<a href='http://www.golygon.com/2011/04/include-js-in-the-end-demonstration/js-first/' title='When JS is included in the beginning'><img width="150" height="150" src="http://www.golygon.com/wp-content/uploads/2011/04/js-first-150x150.png" class="attachment-thumbnail" alt="When JS is included in the beginning" title="When JS is included in the beginning" /></a>
<a href='http://www.golygon.com/2011/04/include-js-in-the-end-demonstration/js-last/' title='When JS is included in the end'><img width="150" height="150" src="http://www.golygon.com/wp-content/uploads/2011/04/js-last-150x150.png" class="attachment-thumbnail" alt="When JS is included in the end" title="When JS is included in the end" /></a>
</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.golygon.com/2011/04/include-js-in-the-end-demonstration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What to cache and what not to! &#8211; Rails</title>
		<link>http://www.golygon.com/2011/04/what-to-cache-and-what-not-to-rails/</link>
		<comments>http://www.golygon.com/2011/04/what-to-cache-and-what-not-to-rails/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 06:48:23 +0000</pubDate>
		<dc:creator>Sanchit Garg</dc:creator>
				<category><![CDATA[Technical]]></category>
		<category><![CDATA[cache]]></category>
		<category><![CDATA[production]]></category>
		<category><![CDATA[Rails 3]]></category>

		<guid isPermaLink="false">http://www.golygon.com/?p=178</guid>
		<description><![CDATA[With fragment caching floating around it always remain to decide how small piece of code should I cache. Is it worth caching a code as it renders a partial, or just because it has a few lines of HTML/ JS / Ruby code, or it makes a few DB calls to fetch data. This blog [...]]]></description>
			<content:encoded><![CDATA[<p>With fragment caching floating around it always remain to decide how small piece of code should I cache. Is it worth caching a code as it renders a partial, or just because it has a few lines of HTML/ JS / Ruby code, or it makes a few DB calls to fetch data.</p>
<p>This blog is dedicated to my findings and observations regarding the same. I am using Rails 3 + Memcachedb + Ubuntu for my experiments. Please note that I have mentioned average response time after coupling a few requests.</p>
<h3>1. Small partials &#8211; caching not needed</h3>
<p>About partial: Few lines of HTML / CSS and JS code (Around 10 lines)</p>
<ul>
<li>Response Time when cache was set:
<div style="padding: 10px 10px 2px 30px; background-color: black; color: white;">
<p>Started GET &#8220;/get_top_menu.js&#8221; for 127.0.0.1 at 2011-04-20 11:58:58 +0530<br />
Processing by HomeController#get_top_menu as JS<br />
User Load (9.9ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 1) LIMIT 1<br />
Exist fragment? views/logged_in-true (1.9ms)<br />
Read fragment views/logged_in-true (0.1ms)<br />
Rendered home/get_top_menu.js.erb (1201.0ms)<br />
Completed 200 OK in <strong>1259ms (Views: 1247.3ms</strong> | ActiveRecord: 9.9ms | Sphinx: 0.0ms)</p>
</div>
</li>
<li>Response time when cache was not set:
<div style="padding: 10px 10px 2px 30px; background-color: black; color: white;">
<p><em> Rails.cache.delete(&#8216;views/logged_in-true&#8217;)</em></p>
<p>Started GET &#8220;/get_top_menu.js&#8221; for 127.0.0.1 at 2011-04-20 12:07:53 +0530<br />
Processing by HomeController#get_top_menu as JS<br />
User Load (1.5ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 1) LIMIT 1<br />
Exist fragment? views/logged_in-true (6.7ms)<br />
Rendered devise/menu/_logged_in_menu.html.erb (7.7ms)<br />
Rendered devise/menu/_logged_in.html.erb (19.2ms)<br />
Write fragment views/logged_in-true (1.2ms)<br />
Rendered home/get_top_menu.js.erb (1225.8ms)<br />
Completed 200 OK in <strong>1284ms (Views: 1281.5ms</strong> | ActiveRecord: 1.5ms | Sphinx: 0.0ms)</p>
</div>
<p>Please observe there was no time saved with cache here. Probably because sending a tcp request to memcachedb (even on localhost) is itself time consuming. Here we made 2 such requests, one to check if cache exists and second to actually fetch it. This nullifies the time we saved on rendering a small partial.</li>
<li>Response time when we did not implement any cache:
<div style="padding: 10px 10px 2px 30px; background-color: black; color: white;">
<p>Started GET &#8220;/get_top_menu.js&#8221; for 127.0.0.1 at 2011-04-20 12:14:25 +0530<br />
Processing by HomeController#get_top_menu as JS<br />
User Load (3.3ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 1) LIMIT 1<br />
Rendered devise/menu/_logged_in_menu.html.erb (1.3ms)<br />
Rendered devise/menu/_logged_in.html.erb (7.6ms)<br />
Rendered home/get_top_menu.js.erb (425.6ms)<br />
Completed 200 OK in <strong>462ms (Views: 457.6ms</strong> | ActiveRecord: 3.3ms | Sphinx: 0.0ms)</p>
</div>
<p>Please observe there we got a faster response when cache was not at all used. Probably because sending a tcp request to memcachedb (even on localhost) is itself time consuming.
</li>
</ul>
<p>I guess results are pretty self explanatory and make sure that you use fragment cache when there is a need and not for every small request. The need arises when there are sql queries (they will anyway make tcp requests to db) or heavy computation in ruby code. You will also save memory by not dumping in huge contents (HTML / CSS / JS) which do not require much time to render.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.golygon.com/2011/04/what-to-cache-and-what-not-to-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

