<?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>Sat, 21 Jul 2012 19:58:27 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Paperclip upload image via console</title>
		<link>http://www.golygon.com/2012/07/paperclip-upload-image-via-console/</link>
		<comments>http://www.golygon.com/2012/07/paperclip-upload-image-via-console/#comments</comments>
		<pubDate>Sat, 21 Jul 2012 19:52:07 +0000</pubDate>
		<dc:creator>Sanchit Garg</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.golygon.com/?p=337</guid>
		<description><![CDATA[It is very easy to associate an image with a model using ruby console, given you are associating image to the model using paperclip. Here is what you are gonna do url="http://golygon.com/image_url.png" file = open url //Ruby will fetch the image using HTTP on your server @user.photo = file // User model uses paperclip to [...]]]></description>
				<content:encoded><![CDATA[<p>It is very easy to associate an image with a model using ruby console, given you are associating image to the model using paperclip.<br />
Here is what you are gonna do<br />
<code><br />
url="http://golygon.com/image_url.png"<br />
file = open url <em>//Ruby will fetch the image using HTTP on your server</em><br />
@user.photo = file <em>// User model uses paperclip to associate photo. This will do the trick</em><br />
@user.save<br />
</code></p>
<p>Don&#8217;t want to use multipart at client side and still want to associate image to the the model using paperclip? You can do a simple binary upload from the client and handle it at server using following commands<br />
<code><br />
uploaded_io = params[:photo][:data] <em>//read data in binary format uploaded by client/browser</em><br />
name=params[:photo][:filename] || "uploads.jpg" <em>//file-name</em><br />
base_dir = Rails.root.join('public', 'system', 'photos' ) <em>//Make sure you have the right target directory</em><br />
new_dir = File.join(base_dir, @user.id.to_s)<br />
if !File.directory?(new_dir)<br />
&nbsp;&nbsp;Dir.mkdir(new_dir, 0700)<br />
end<br />
</code></p>
<p><code>File.open(File.join(new_dir, name), 'w:ASCII-8BIT') do |file|<br />
&nbsp;&nbsp;file.write(Base64.decode64(uploaded_io)) <em>//saves file at some temp location on your server</em><br />
&nbsp;&nbsp;file.close<br />
end<br />
</code></p>
<p>Now that you have file on your server, you can run the first code snippet to read it from the location you just saved the file and associate it with the parent model using paperclip internally.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.golygon.com/2012/07/paperclip-upload-image-via-console/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails Tips  &#8211; Counter Cache (.size vs .count)</title>
		<link>http://www.golygon.com/2012/06/rails-tips-counter-cache-size-vs-count/</link>
		<comments>http://www.golygon.com/2012/06/rails-tips-counter-cache-size-vs-count/#comments</comments>
		<pubDate>Thu, 28 Jun 2012 14:11:07 +0000</pubDate>
		<dc:creator>Sanchit Garg</dc:creator>
				<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://www.golygon.com/?p=332</guid>
		<description><![CDATA[* Size (rails function) is more intelligent than count (ruby function) * Notice that when you counter cache, size makes only one call to db as opposed to count which does 2 queries. 1.9.2-p320 :057 > ParentModel.find(5765).childmodel.count RequestedTrip Load (0.3ms) SELECT `parent_models`.* FROM `parent_models` WHERE (`parent_models`.`id` = 5765) ORDER BY parent_models.created_at desc LIMIT 1 SQL [...]]]></description>
				<content:encoded><![CDATA[<p>* Size (rails function) is more intelligent than count (ruby function)<br />
* Notice that when you counter cache, size makes only one call to db as opposed to count which does 2 queries.</p>
<p><code><br />
1.9.2-p320 :057 > ParentModel.find(5765).childmodel.count<br />
RequestedTrip Load (0.3ms)  SELECT `parent_models`.* FROM `parent_models` WHERE (`parent_models`.`id` = 5765) ORDER BY parent_models.created_at desc LIMIT 1<br />
  SQL (6.9ms)  SELECT COUNT(*) FROM `childmodels` WHERE (`quotes`.requested_trip_id = 5765)<br />
 => 5<br />
</code></p>
<p><code><br />
1.9.2-p320 :058 > ParentModel.find(5765).childmodel.size<br />
  RequestedTrip Load (0.4ms)  SELECT `parent_models`.* FROM `parent_models` WHERE (`parent_models`.`id` = 5765) ORDER BY parent_models.created_at desc LIMIT 1<br />
 => 5 </p>
<p></code></p>
<p>You can view all queries to db for commands in rails console by redirecting the logs using following commands:<br />
<code><br />
ActiveRecord::Base.logger = Logger.new(STDOUT)<br />
ActiveRecord::Base.clear_active_connections!<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.golygon.com/2012/06/rails-tips-counter-cache-size-vs-count/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>1</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-login.php?action=postpass" method="post">
<p>This post is password protected. To view it please enter your password below:</p>
<p><label for="pwbox-273">Password: <input name="post_password" id="pwbox-273" type="password" size="20" /></label> <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;"><script src="https://gist.github.com/9885986309e63e38a598.js"></script><noscript><pre><code class="language-ruby ruby"> def uploadToken
    cmd = Rails.root.to_s + '/public/scripts/youtubeUtilAPIs.py'
    title = &quot;Test Video&quot;
    description = &quot;Test Video description&quot;
    resp = `#{cmd} -t &quot;#{title},#{description}&quot;`
    resp = resp.split('::')
    response = (resp.length == 2) ? {:uploadUrl =&gt; resp[0], :token =&gt; resp[1]} : &quot;&quot;
    respond_to do |format|
      format.js {render :js =&gt; response.to_json}
    end
  end</code></pre></noscript></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;"><script src="https://gist.github.com/7235b56ea6c039a9cab0.js"></script><noscript><pre><code class="language-html html">&lt;div id=&quot;upload_video&quot;&gt;
    &lt;div class=&quot;field&quot;&gt;
     &lt;form action='' id=&quot;youtube_video_upload&quot; method=&quot;post&quot; enctype=&quot;multipart/form-data&quot;&gt;
        &lt;input name=&quot;file&quot; type=&quot;file&quot; class=&quot;multimedia_file&quot;/&gt;
        &lt;div class=&quot;errMsg&quot; style=&quot;display:none;color:red&quot;&gt;
          You need to specify a file.
        &lt;/div&gt;
        &lt;div class=&quot;errMsg2&quot; style=&quot;display:none;color:red&quot;&gt;
          Video cannot be uploaded this time. Please try again after sometime.
        &lt;/div&gt;
        &lt;input class= &quot;token&quot; name=&quot;token&quot; type=&quot;hidden&quot; value=&quot;&quot;/&gt;
        &lt;input value=&quot;Upload Video File&quot; class=&quot;upload_button&quot; type=&quot;submit&quot; /&gt;
      &lt;/form&gt;
    &lt;/div&gt;&lt;br/&gt;
&lt;/div&gt;
&lt;script&gt;
  $(document).ready(function(){
    $(' #youtube_video_upload .multimedia_file').click(function(){
      $(this).siblings('.errMsg').css(&quot;display&quot;, &quot;none&quot;);
      $(this).children('.errMsg2').css(&quot;display&quot;, &quot;none&quot;);
    });
    $('#youtube_video_upload').submit(function(){
      if ($(this).children('.multimedia_file').val() == null || $(this).children('.multimedia_file').val() == &quot;&quot;){
        $(this).children('.errMsg').css(&quot;display&quot;, &quot;&quot;);
        return false;
      }else if ($(this).children('.token').val() == null || $(this).children('.token').val() == &quot;&quot;){
        $(this).children('.errMsg2').css(&quot;display&quot;, &quot;&quot;);
        return false;
      }
      $('#youtube_video_upload').children('.upload_button').attr('disabled', 'true');
    });
    $('#video_link').click(function(){
      $(&quot;#add_link&quot;).css(&quot;display&quot;, &quot;none&quot;);
      $(&quot;#upload_video&quot;).css(&quot;display&quot;,&quot;&quot;);
    });
    $('#youtube_link').click(function(){
      $(&quot;#upload_video&quot;).css(&quot;display&quot;,&quot;none&quot;);
      $(&quot;#add_link&quot;).css(&quot;display&quot;, &quot;&quot;);
      $('.errMsg').css(&quot;display&quot;, &quot;none&quot;);
      $('.errMsg2').css(&quot;display&quot;, &quot;none&quot;);
    });
    
   // asyn ajax request to fetch upload URL and token from youtube
    $.get('&lt;%= url_for(:action =&gt; &quot;uploadToken&quot;, :controller =&gt; &quot;multimedias&quot;, :only_path =&gt; false)%&gt;',function(data){
        if(data != &quot;&quot;){
          $('#youtube_video_upload').attr('action', data.uploadUrl + '?nexturl=&lt;%= url_for(:action =&gt; &quot;new&quot;, :controller =&gt; &quot;multimedias&quot;, :only_path =&gt; false)%&gt;');
          $('#youtube_video_upload').children('.token').val(data.token);
          $('#youtube_video_upload').children('.errMsg2').css(&quot;display&quot;, &quot;none&quot;);
        }else{
          
        }
      }, &quot;json&quot;);
  });
&lt;/script&gt;</code></pre></noscript></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>2</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>
<script src="https://gist.github.com/c92b776656b43b44f4a9.js"></script><noscript><pre><code class="language-javascript javascript">var geocoder = new google.maps.Geocoder();

$('.geocode_autocomplete').live('focus', function(){
        $(this).autocomplete({
            source: function(request, response) {
              geocoder.geocode( {'address': request.term}, function(results, status) {
                $(&quot;#map_location&quot;).attr(&quot;value&quot;,&quot;&quot;);
                response($.map(results, function(item) {
                    value = item.address_components[0].long_name;
                  return {
                    label: item.formatted_address,
                    value: value,
                    location: item.geometry.location,
                    addr: item.address_components[0]
                  }
                }));
              })
            },
            minLength: 2,
            select: function(event, ui) {
               $(&quot;#map_location&quot;).html(&quot;Latitude: &quot; + ui.item.location.lat() + &quot; Longitude: &quot;+ ui.item.location.lng());
	    }
          });
        });
</code></pre></noscript>
<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>5</slash:comments>
		</item>
	</channel>
</rss>
