<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5785907677647112110</id><updated>2025-12-16T12:08:04.112-08:00</updated><category term="Ruby on Rails"/><category term="General"/><category term="Linux"/><category term="Exercises"/><category term="web.py"/><category term="AJAX"/><category term="Devise"/><category term="Jcrop"/><category term="Python"/><category term="Dropbox API"/><category term="Facebook share"/><category term="Linkedin share"/><category term="Omniauth"/><category term="Paperclip"/><category term="Project"/><category term="Ruby"/><category term="Twitter share"/><category term="github API"/><category term="linkedin API"/><category term="rest-client"/><title type='text'>random Bytes</title><subtitle type='html'>By Sreehari K M</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-1228390945815008348</id><published>2013-08-28T21:51:00.001-07:00</published><updated>2013-08-28T22:42:19.301-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="github API"/><category scheme="http://www.blogger.com/atom/ns#" term="rest-client"/><category scheme="http://www.blogger.com/atom/ns#" term="Ruby on Rails"/><title type='text'>github_api gem with Rails 4: How to import github user information to your Rails Application</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This time i am back with one more API feature to the list , that we can incorporate with the existing Rails 4 Application. github api gem is the Ruby wrapper for the GitHub REST API v3.It supports almost all the API methods provided by Github.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;Refs&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;a href=&quot;https://github.com/peter-murach/github&quot;&gt;https://github.com/peter-murach/github&lt;/a&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://github.com/rest-client/rest-client&quot;&gt;https://github.com/rest-client/rest-client&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;Gemfile&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Add &lt;i&gt;&lt;b&gt;gem &#39;github-api&#39;&lt;/b&gt;&lt;/i&gt; &amp;amp; &lt;i&gt;&lt;b&gt;gem &#39;rest-client&#39;&lt;/b&gt;&lt;/i&gt; to your Gemfile.&lt;b&gt; &#39;rest-client&#39;&lt;/b&gt; gem is a&amp;nbsp;simple HTTP and REST client for Ruby. It will help you to get the response data from github after attaching the access token.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;Github Controller&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;script src=&quot;https://gist.github.com/sreeharikmarar/6365470.js&quot;&gt;&lt;/script&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;As you all know the basic API authentication and after that returning the user back to the callback method, here also there no much changes in the basic functions .First it will authenticate the user to the github app , after that it will redirect the user back to the callback method that we have specified in the redirect url with an &lt;b&gt;authorization code&lt;/b&gt; as params , by using the authorization code returned from the github , we will be able to generate a github client object and we can call the &lt;b&gt;get_token&lt;/b&gt; method by passing the authorization code as an argument . It will return the Access token to you . by using the access token you can easily call the Git API link by attaching the access token. It will give you the whole user Repository list as JSON.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;Route File&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;script src=&quot;https://gist.github.com/sreeharikmarar/6374317.js&quot;&gt;&lt;/script&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;View file&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;script src=&quot;https://gist.github.com/sreeharikmarar/6374368.js&quot;&gt;&lt;/script&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/1228390945815008348/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2013/08/githubapi-gem-with-rails-4-how-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/1228390945815008348'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/1228390945815008348'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2013/08/githubapi-gem-with-rails-4-how-to.html' title='github_api gem with Rails 4: How to import github user information to your Rails Application'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-7752873528376568274</id><published>2013-08-28T04:58:00.000-07:00</published><updated>2013-08-28T22:45:40.069-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="linkedin API"/><category scheme="http://www.blogger.com/atom/ns#" term="Ruby on Rails"/><title type='text'>Linkedin Gem with Rails 4 : How to Import Linkedin user information to your Rails Application</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;All your Linkedin&amp;nbsp;Information&#39;s are now just a mouse click away. by using linkedin gem with Rails we can easily import all your linkedin information&#39;s &amp;nbsp;like your skills , contact details , experience details, education details , project details , connection details etc. Now almost all popular websites mainly working in the Professional Networking platform are providing this feature ,&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://careers.stackoverflow.com/&quot;&gt;http://careers.stackoverflow.com/&lt;/a&gt;&amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;is my favorite among them , which does the job very brilliant.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Refs&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;https://github.com/pengwynn/linkedin&quot;&gt;https://github.com/pengwynn/linkedin&lt;/a&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&lt;a href=&quot;http://developer.linkedin.com/documents/profile-fields&quot;&gt;http://developer.linkedin.com/documents/profile-fields&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;a href=&quot;https://gist.github.com/sreeharikmarar/6364970&quot;&gt;https://gist.github.com/sreeharikmarar/6364970&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Gemfile&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&amp;nbsp;&lt;i&gt;&amp;nbsp;&lt;/i&gt;&lt;/b&gt;&lt;i&gt;gem &#39;linkedin&#39;, &#39;0.4.2&#39;, :git =&amp;gt; &quot;git://github.com/pengwynn/linkedin.git&quot;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;Linkedin Controller&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;script src=&quot;https://gist.github.com/sreeharikmarar/6364790.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;As you all know the basic authentication and the Callback methods , here also first it will &amp;nbsp;authenticate the user with the linkedin app . You can specify the user access information here in the Linkedin Configuration .What all user fields that your application want to get access. After Authenticating the user it will redirect the user back to the callback method with &lt;b&gt;oauth_verifier&lt;/b&gt; as parmas. you will be able to create Access token and access token secret by using the linkedin client object that we have created using the response parameter.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once the linkedin Client object creation is done , you will be able to access all the user information&#39;s like contact details , skills , education details , experience details etc , All the profile field information&#39;s are available at&amp;nbsp;&lt;/span&gt;&lt;a href=&quot;http://developer.linkedin.com/documents/profile-fields&quot;&gt;http://developer.linkedin.com/documents/profile-fields&lt;/a&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;LinkedIn is very particular about access to profile fields and you cannot combine multiple fields which requires 2 different type of access. so when you try to get just position details by c.profile(:fields =&amp;gt; %w(positions)) it assumes the access of type &#39;r_basicprofile&#39; whereas educations field require access of type &#39;r_fullprofile&#39;.so try 2 seperate API calls to retrieve both fields.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&quot;first_name&quot;,&quot;last_name&quot;,&quot;headline&quot;,&quot;positions&quot; available for &#39;r_basicprofile&#39; member permission,so they can be combined together. but &quot;educations&quot;, &quot;three_current_positions&quot;, &quot;three_past_positions&quot; , &quot;certifications&lt;/span&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&quot; etc are available in &#39;r_fullprofile&#39; . So you have to separate the API calls with respect to the requirements.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;Route File&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/sreeharikmarar/6365099.js&quot;&gt;&lt;/script&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;View File&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/sreeharikmarar/6365104.js&quot;&gt;&lt;/script&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/7752873528376568274/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2013/08/linkedin-gem-with-rails-4-how-to-import.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/7752873528376568274'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/7752873528376568274'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2013/08/linkedin-gem-with-rails-4-how-to-import.html' title='Linkedin Gem with Rails 4 : How to Import Linkedin user information to your Rails Application'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-5317774793744443671</id><published>2013-07-19T21:18:00.000-07:00</published><updated>2013-09-09T21:25:24.663-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Dropbox API"/><category scheme="http://www.blogger.com/atom/ns#" term="Paperclip"/><category scheme="http://www.blogger.com/atom/ns#" term="Ruby on Rails"/><title type='text'>Integrate Dropbox with your Rails App by using Dropbox API gem with Paperclip</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;We&lt;/b&gt; are going to steal all the Dropbox documents by using Dropbox API with the help of Paperclip. Hey got scared !! .. Oh pls .. &amp;nbsp;just kidding. But seriously ,We can do that with the help of &lt;a href=&quot;https://rubygems.org/gems/dropbox-api&quot; target=&quot;_blank&quot;&gt;dropbox-api&lt;/a&gt; gem &amp;amp; &lt;a href=&quot;https://github.com/thoughtbot/paperclip&quot; target=&quot;_blank&quot;&gt;paperclip&lt;/a&gt;&amp;nbsp;.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Step 1&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Create an App in &lt;a href=&quot;https://www.dropbox.com/developers&quot; target=&quot;_blank&quot;&gt;Dropbox &amp;nbsp;Developer&lt;/a&gt;&amp;nbsp; to get the key-Secret pair. You have to set the permission type to &quot;Full Dropbox&quot; mode to get the full Read/Write Access to any file inside the user&#39;s Dropbox.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Step 2&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Setup your Rails App , include these 2 gems in your Gemfile.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;i&gt;gem &#39;dropbox-api&#39;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;i&gt;gem &quot;paperclip&quot;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Step 3&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Create&amp;nbsp;a file in your config/initializers&amp;nbsp;directory and name it &lt;b&gt;dropbox.rb &lt;/b&gt;and put the following line of code inside.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;Dropbox::API::Config.app_key &amp;nbsp; &amp;nbsp;= &#39;APP KEY&#39;
Dropbox::API::Config.app_secret = &#39;SECRET KEY&#39;
Dropbox::API::Config.mode &amp;nbsp; &amp;nbsp; &amp;nbsp; = &quot;dropbox&quot;

&lt;/pre&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Step 4&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
we have to create Paperclip model for downloading the Files from Dropbox and create the same in your app in Rails way.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;class DropboxFiles &amp;lt; ActiveRecord::Base

&amp;nbsp; &amp;nbsp;attr_accessible :url , :created_at ,:updated_at, :document

&amp;nbsp;  has_attached_file :document ,

&amp;nbsp; &amp;nbsp; :url =&amp;gt; &quot;/system/:class/:attachment/:id/:style/:basename.:extension&quot;,
&amp;nbsp; &amp;nbsp; :path =&amp;gt; &quot;#{Rails.root}/public/system/:class/:attachment/:id/:style/:basename.:extension&quot;,
&amp;nbsp; &amp;nbsp; :storage =&amp;gt; ((Rails.env.production? || Rails.env.staging?) ? :s3 : :filesystem)

end

&lt;/pre&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Step 5&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Controller and Callback Actions for authenticating the user first to Dropbox and redirecting the user back to the callback action to perform the Downloading Activities.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;routes.rb&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;match &#39;/dropbox/authorize&#39; &amp;nbsp; =&amp;gt; &#39;dropbox#authorize&#39; , :method =&amp;gt; :get , :as =&amp;gt; :dropbox_auth
match &#39;/dropbox/callback&#39; =&amp;gt; &#39;dropbox#callback&#39; , :method =&amp;gt; :get , :as =&amp;gt; &amp;nbsp;:dropbox_callback
&lt;/pre&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;dropbox_controller.rb&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/sreeharikmarar/6061961.js&quot;&gt;&lt;/script&gt;

&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I will&amp;nbsp;brief you the functions written inside Dropbox controller.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&lt;b&gt;authorize Action &lt;/b&gt;will authorize the user with App and will redirect the user back to the Callback action.&amp;nbsp;&lt;b&gt;Callback Action &lt;/b&gt;will give you the secret token pair as a response . We can create a Dropbox client object with access token &amp;amp; secret token pair .&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now we are ready to download the entire documents ( One after another ) belongs to that particular user.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;We will list all the documents and will iterate inside a loop . this time we will check whether the document is a File or a Directory . it will call &amp;nbsp;the function recursively until it reaches a File object .&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If it is a File object then will call&amp;nbsp;&lt;b&gt;download_and_create(obj) &lt;/b&gt;function and will pass the same File obj as an argument. Inside&amp;nbsp;&lt;b&gt;download_and_create(obj) &lt;/b&gt;function&amp;nbsp;we will again call one more function named&amp;nbsp;&lt;b&gt;download_file_from_url &lt;/b&gt;and will pass the same argument .The File object that we passed as an argument has one instance method named &lt;b&gt;&quot;redirect_url&quot;&lt;/b&gt; , we can get the full &lt;b&gt;Dropbox path&lt;/b&gt; of that particular document by calling &quot;&lt;b&gt;redirect_url.url&lt;/b&gt;&quot; method.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;download_file_from_url &lt;/b&gt;action will download the file first to Server and will return the absolute path of the downloaded file. So now the File is there in our Rails App. we can create a Paperclip file Object by using&amp;nbsp;&lt;/span&gt;&lt;b style=&quot;font-family: Verdana, sans-serif;&quot;&gt;DropboxFiles &lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;model , &lt;/span&gt;&lt;b style=&quot;font-family: Verdana, sans-serif;&quot;&gt;DropboxFiles.create(:document =&amp;gt; dp_file). &lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;here we are passing the absolute file path as an argument.It will create same File in Our Rails application. Don&#39;t forget to remove the file from your Rails root path after creating the Paperclip Object.&lt;/span&gt;

&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;So that&#39;s it , hope you guys will try this . There are lot of options that we can try out with Dropbox-api gem.  I have not optimized the code , hope you guys will do it for me. so have fun coding ...&lt;/span&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/5317774793744443671/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2013/07/ruby-on-rails-practice-some-safe.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/5317774793744443671'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/5317774793744443671'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2013/07/ruby-on-rails-practice-some-safe.html' title='Integrate Dropbox with your Rails App by using Dropbox API gem with Paperclip'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-2872642189912878511</id><published>2013-05-08T03:13:00.000-07:00</published><updated>2013-07-19T21:57:28.718-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Linkedin share"/><category scheme="http://www.blogger.com/atom/ns#" term="Ruby on Rails"/><title type='text'>Linkedin Gem for Rails : How to share dynamic contents to Linkedin from your Rails Application</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;After &lt;a href=&quot;http://sreeharikmarar.blogspot.in/2013/05/fb-graph-gem-for-rails-how-to-post.html&quot; target=&quot;_blank&quot;&gt;Facebook&lt;/a&gt; &amp;amp; &lt;a href=&quot;http://sreeharikmarar.blogspot.in/2013/05/twitter-gem-for-rails-how-to-share.html&quot; target=&quot;_blank&quot;&gt;Twitter&lt;/a&gt; share ,its time for Linkedin. I would suggest you to refer my 2 prev posts before going through this article.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Include &quot;&lt;a href=&quot;https://github.com/pengwynn/linkedin&quot; target=&quot;_blank&quot;&gt;linkedin&lt;/a&gt;&quot; gem in your Gemfile and bundle .&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;gem &#39;linkedin&#39;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Route file:&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;&amp;nbsp;match &#39;/linkedin_share/auth&#39; &amp;nbsp; =&amp;gt; &#39;linkedin_share#auth&#39; , :method =&amp;gt; :get , :as =&amp;gt; :linkedin_auth

&amp;nbsp;match &#39;/linkedin_share/callback&#39; =&amp;gt; &#39;linkedin_share#callback&#39; , :method =&amp;gt; :get , :as =&amp;gt; &amp;nbsp;:linkedin_callback

&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;LinkedinShare Controller &amp;amp; Actions :&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;class LinkedinShareController &amp;lt; ApplicationController

  def init_client
    
    key = &quot;APP KEY&quot;
    secret = &quot;SECRET KEY&quot;

    linkedin_configuration = { :site =&amp;gt; &#39;https://api.linkedin.com&#39;,
        :authorize_path =&amp;gt; &#39;/uas/oauth/authenticate&#39;,
        :request_token_path =&amp;gt;&#39;/uas/oauth/requestToken?scope=rw_nus&#39;,
        :access_token_path =&amp;gt; &#39;/uas/oauth/accessToken&#39; }

    @linkedin_client = LinkedIn::Client.new(key, secret,linkedin_configuration )
  end

  def auth
    init_client
  
    cookies[&quot;title&quot;] = { :value =&amp;gt; &quot;#{params[:title]}&quot;, :expires =&amp;gt; 1.minute.from_now }
    cookies[&quot;url&quot;] = { :value =&amp;gt; &quot;#{params[:url]}&quot;, :expires =&amp;gt; 1.minute.from_now }
  
    request_token = @linkedin_client.request_token(:oauth_callback =&amp;gt; &quot;http://#  {request.host_with_port}/linkedin_share/callback&quot;)
    session[:rtoken] = request_token.token
    session[:rsecret] = request_token.secret
  
    redirect_to @linkedin_client.request_token.authorize_url
  end

  def callback
    init_client
  
    if session[:atoken].nil?
      pin = params[:oauth_verifier]
      atoken, asecret =  @linkedin_client.authorize_from_request(session[:rtoken], session[:rsecret], pin)
      session[:atoken] = atoken
      session[:asecret] = asecret
    else
      @linkedin_client.authorize_from_access(session[:atoken], session[:asecret])
    end

    c = @linkedin_client
    
    title = &quot;#{cookies[&quot;title&quot;]}&quot;
    url = &quot;#{cookies[&quot;url&quot;]}&quot;

    c.add_share({
        :comment =&amp;gt; title,
        :content =&amp;gt; {
          :title =&amp;gt; title,
          :submitted_url =&amp;gt; url,
          :submitted_image_url =&amp;gt; &quot;IMAGE PATH&quot;,
          :description =&amp;gt; &#39;YOUR DESCRIPTION&#39;
        }
      })

    redirect_to root_path
  end
end


&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/2872642189912878511/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2013/05/linkedin-gem-for-rails-how-to-share.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/2872642189912878511'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/2872642189912878511'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2013/05/linkedin-gem-for-rails-how-to-share.html' title='Linkedin Gem for Rails : How to share dynamic contents to Linkedin from your Rails Application'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-8798113048697287016</id><published>2013-05-08T02:46:00.000-07:00</published><updated>2013-05-11T00:30:42.897-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ruby on Rails"/><category scheme="http://www.blogger.com/atom/ns#" term="Twitter share"/><title type='text'>Twitter gem for Rails : How to share dynamic contents to Twitter from your Rails Application</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Before going through this post . I would suggest you to go through my previous &lt;a href=&quot;http://sreeharikmarar.blogspot.in/2013/05/fb-graph-gem-for-rails-how-to-post.html&quot; target=&quot;_blank&quot;&gt;FB share &lt;/a&gt;&amp;nbsp;post. You will get to know the basic functionality &amp;amp; working from the prev post .After that please go through &lt;a href=&quot;https://github.com/sferik/twitter&quot; target=&quot;_blank&quot;&gt;Twitter gem&lt;/a&gt;&amp;nbsp;description.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I hope you have gone through the prev post and you have got some idea about it.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now we will start with Twitter share implementation.You have to include &amp;nbsp;&quot;twitter&quot; &amp;amp; &quot;oauth&quot; gems into your Gemfile.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;gem &#39;twitter&#39;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;gem &#39;oauth&#39;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Compared to FB share , here we need to include &quot;&lt;b&gt;Oauth&lt;/b&gt;&quot; gem for authenticating the user to twitter and redirect the user back to your applications Callback action.After getting the Oauth Secret Key i.e&amp;nbsp;returning&amp;nbsp;from Twitter you can configure the Twitter gem settings and you can post to twitter from your Rails app.&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Route :&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;&amp;nbsp; match &quot;/twitter_share/auth&quot; =&amp;gt; &quot;twitter_share#auth&quot; &amp;nbsp;, :method =&amp;gt; :get , :as =&amp;gt; :twitter_auth

&amp;nbsp; match &quot;/twitter_share/callback&quot; =&amp;gt; &quot;twitter_share#callback&quot; &amp;nbsp;, :method =&amp;gt; :post , :as =&amp;gt; :twitter_callback

&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Twitter Share Controller &amp;amp; Actions :&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;&amp;nbsp;def auth

&amp;nbsp; &amp;nbsp; cookies[&quot;title&quot;] = { :value =&amp;gt; &quot;#{params[:title]}&quot;, :expires =&amp;gt; 1.minute.from_now }

&amp;nbsp; &amp;nbsp; cookies[&quot;url&quot;] = { :value =&amp;gt; &quot;#{params[:url]}&quot;, :expires =&amp;gt; 1.minute.from_now }

&amp;nbsp;
&amp;nbsp; &amp;nbsp; consumer_key = &quot;APP ID&quot;

&amp;nbsp; &amp;nbsp; consumer_secret = &quot;SECRET KEY&quot;

&amp;nbsp; &amp;nbsp; oauth_consumer = OAuth::Consumer.new(consumer_key, consumer_secret,

&amp;nbsp; &amp;nbsp; &amp;nbsp; :site =&amp;gt; &#39;http://api.twitter.com&#39;,

&amp;nbsp; &amp;nbsp; &amp;nbsp; :request_endpoint =&amp;gt; &#39;http://api.twitter.com&#39;,

&amp;nbsp; &amp;nbsp; &amp;nbsp; :sign_in =&amp;gt; true)

&amp;nbsp; &amp;nbsp; request_token = oauth_consumer.get_request_token(:oauth_callback =&amp;gt; &quot;http://#{request.host_with_port}/twitter_share/callback&quot;)


&amp;nbsp; &amp;nbsp; session[:request_token] = request_token.token

&amp;nbsp; &amp;nbsp; session[:request_token_secret] = request_token.secret

&amp;nbsp; &amp;nbsp; redirect_to request_token.authorize_url

&amp;nbsp; end

&amp;nbsp; def callback 

&amp;nbsp; &amp;nbsp; consumer_key =&amp;nbsp;&quot;APP ID&quot;

&amp;nbsp; &amp;nbsp; consumer_secret =&amp;nbsp;&amp;nbsp;&quot;SECRET KEY&quot;

&amp;nbsp; &amp;nbsp; oauth_consumer = OAuth::Consumer.new(consumer_key, consumer_secret,

&amp;nbsp; &amp;nbsp; &amp;nbsp; :site =&amp;gt; &#39;http://api.twitter.com&#39;,

&amp;nbsp; &amp;nbsp; &amp;nbsp; :request_endpoint =&amp;gt; &#39;http://api.twitter.com&#39;,

&amp;nbsp; &amp;nbsp; &amp;nbsp; :sign_in =&amp;gt; true)

&amp;nbsp; &amp;nbsp; r_token = session[:request_token]

&amp;nbsp; &amp;nbsp; r_stoken = session[:request_token_secret]

&amp;nbsp; &amp;nbsp; atoken = OAuth::RequestToken.new(oauth_consumer,r_token, r_stoken).get_access_token(:oauth_verifier =&amp;gt; params[:oauth_verifier])


&amp;nbsp; &amp;nbsp; Twitter.configure do |conf|

&amp;nbsp; &amp;nbsp; &amp;nbsp; conf.consumer_key = consumer_key

&amp;nbsp; &amp;nbsp; &amp;nbsp; conf.consumer_secret = consumer_secret

&amp;nbsp; &amp;nbsp; &amp;nbsp; conf.oauth_token = atoken.token

&amp;nbsp; &amp;nbsp; &amp;nbsp; conf.oauth_token_secret = atoken.secret

&amp;nbsp; &amp;nbsp; end

&amp;nbsp; &amp;nbsp; Twitter.update(&quot;My new post on &amp;nbsp;#{cookies[&quot;title&quot;]} &amp;nbsp;#{cookies[&quot;url&quot;]}&quot;)

&amp;nbsp; &amp;nbsp; redirect_to root_path

&amp;nbsp; end

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/8798113048697287016/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2013/05/twitter-gem-for-rails-how-to-share.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/8798113048697287016'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/8798113048697287016'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2013/05/twitter-gem-for-rails-how-to-share.html' title='Twitter gem for Rails : How to share dynamic contents to Twitter from your Rails Application'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-3207845521888838759</id><published>2013-05-07T06:11:00.005-07:00</published><updated>2013-12-04T23:27:48.277-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Facebook share"/><category scheme="http://www.blogger.com/atom/ns#" term="Ruby on Rails"/><title type='text'>Fb Graph Gem for Rails : How to Post dynamic contents to Facebook Wall from your Rails Application </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This post will introduce the usage of fb_graph Gem with your existing Rails Application.&lt;b&gt;fb_graph&lt;/b&gt; has already done a lot for you guys to exploit the FB API features with your Rails Application , you can have an eye on this &lt;a href=&quot;https://github.com/nov/fb_graph&quot; target=&quot;_blank&quot;&gt;fb_graph Gem&lt;/a&gt;&amp;nbsp;before going through this post.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Suppose you have a blogger kind of application, and when you compose a new post , you would like to share the same in your Facebook wall, and also would like to give the same option for all the users ,those who liked your post and would like to share the same in their Facebook Wall.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I think now almost all the websites are using this feature to increase their user traffic , to popularize their sites, &amp;nbsp;Since Facebook turned out to be a great option for advertising and marketing your site content.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;One day i also felt the same and after one complete days of effort ..... i was successful. &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;I thought i should share the same for you guys to reduce your one days effort ( or may be less ) for implementing this FB share option.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I hope i am not boring you , anyway stop to all kind of rubbish introduction and lets start coding ..&lt;/span&gt;&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;As usual first of all add &lt;b&gt;fb_graph&lt;/b&gt;&amp;nbsp;Gem to your Gemfile&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;gem &#39;fb_graph&#39;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;After that we have to create 2 actions for authenticating the User to Facebook and After authenticating the user we need a Callback action and this will share the Contents to that particular Users Facebook Wall.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here we start from the Route file , mention your roots and controller actions here.&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;route file&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;&amp;nbsp;match &quot;/fb_share/auth&quot; =&amp;gt; &quot;fb_share#auth&quot; &amp;nbsp;, :method =&amp;gt; :get , :as =&amp;gt; :fb_auth

&amp;nbsp;match &quot;/fb_share/callback&quot; =&amp;gt; &quot;fb_share#callback&quot; &amp;nbsp;, :method =&amp;gt; :get , :as =&amp;gt; :fb_callback
&lt;/pre&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Before get in to the serious part , i would like to tell you more about How i implemented this or what was my requirement.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Like i said before , suppose we have a blogger application , we are going to display the FB share button just below each post.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;

&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Requirements&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;When user clicks on the share button, it should redirect the user to Facebook login, and after allowing the&amp;nbsp;permission&amp;nbsp;to post , The content should post on the Users FB Wall.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Contents should be,&lt;/span&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Title of my Blogpost.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Title should be a link to my Blog Posts detail page.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Small Descrition.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Thumbnail Image (If you want ).&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Steps&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;When User clicks on share button, We should call an action and here that probably be an Auth Action.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;But after&amp;nbsp;authorizing&amp;nbsp;the user , Facebook will redirect the user back to our Applications Callback action . So at that time , from where will we able to get the Contents like (Title , Description , URL, Image path) ?&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;For that reason , i just implemented a cookie for storing all these information .&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;When User Clicks on share button , We will pass all these&amp;nbsp;information to Auth action.We Will Assign all these details to Each cookie.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;After Authenticating the User with (Key , Secret) pair, Facebook will redirect the user back to the Callback Action with Authorization code.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Then we will call the &lt;b&gt;feed&lt;/b&gt; action provided by the FB gem and will assign all these&amp;nbsp;contents like ( Title, Description , image path &amp;amp; URL) from the cookie .&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The Rest of the things you dont need to care about . FB Gem will do it for you.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;FBShare Controller Actions&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;class FbShareController &amp;lt; ApplicationController


&amp;nbsp; def auth

&amp;nbsp; &amp;nbsp; &amp;nbsp;cookies[&quot;title&quot;] = { :value =&amp;gt; &quot;#{params[:title]}&quot;, :expires =&amp;gt; 1.minute.from_now }
&amp;nbsp; &amp;nbsp; &amp;nbsp;cookies[&quot;url&quot;] = { :value =&amp;gt; &quot;#{params[:url]}&quot;, :expires =&amp;gt; 1.minute.from_now }
&amp;nbsp; &amp;nbsp; &amp;nbsp;cookies[&quot;desc&quot;] = { :value =&amp;gt; &quot;#{params[:desc]}&quot;, :expires =&amp;gt; 1.minute.from_now }

&amp;nbsp; &amp;nbsp;

&amp;nbsp; @client = client

&amp;nbsp; &amp;nbsp; redirect_to @client.authorization_uri(
&amp;nbsp; &amp;nbsp; &amp;nbsp; :scope =&amp;gt; [ :offline_access , :publish_stream]
&amp;nbsp; &amp;nbsp; )

&amp;nbsp; end


&amp;nbsp; def callback

&amp;nbsp; &amp;nbsp; @client = client
&amp;nbsp; &amp;nbsp; @client.authorization_code = params[:code]

&amp;nbsp; &amp;nbsp; access_token = @client.access_token! :client_auth_body # =&amp;gt; Rack::OAuth2::AccessToken

&amp;nbsp; &amp;nbsp; me = FbGraph::User.me(access_token)

&amp;nbsp; &amp;nbsp; title = cookies[&quot;title&quot;]
&amp;nbsp; &amp;nbsp; url =&amp;nbsp;cookies[&quot;url&quot;]
&amp;nbsp; &amp;nbsp; desc &amp;nbsp;= cookies[&quot;desc&quot;]

&amp;nbsp; &amp;nbsp; me.feed!(

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; :message =&amp;gt;&amp;nbsp;&amp;nbsp;title&amp;nbsp;,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; :picture =&amp;gt; / Your Image path / ,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; :link =&amp;gt; url,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; :name =&amp;gt; title,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; :description =&amp;gt; desc
&amp;nbsp; &amp;nbsp; )

&amp;nbsp; &amp;nbsp; redirect_to root_path ( You Application Action path After sharing the content to FB)

&amp;nbsp; end


&amp;nbsp; private


&amp;nbsp; def client

&amp;nbsp; &amp;nbsp; key = &quot;APP KEY&quot;
&amp;nbsp; &amp;nbsp; secret = &quot;SECRET KEY&quot;
&amp;nbsp; &amp;nbsp; fb_auth = FbGraph::Auth.new(key, secret)
&amp;nbsp; &amp;nbsp; client = fb_auth.client
&amp;nbsp; &amp;nbsp; client.redirect_uri = &quot;http://#{request.host_with_port}/fb_share/callback&quot;

&amp;nbsp; &amp;nbsp; client

&amp;nbsp; end

end

&lt;/pre&gt;
Checkout my &lt;a href=&quot;http://sreeharikmarar.blogspot.in/2013/05/twitter-gem-for-rails-how-to-share.html&quot; target=&quot;_blank&quot;&gt;Twitter&lt;/a&gt; &amp;amp; &lt;a href=&quot;http://sreeharikmarar.blogspot.in/2013/05/linkedin-gem-for-rails-how-to-share.html&quot; target=&quot;_blank&quot;&gt;Linkedin&lt;/a&gt; Share posts also ...&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/3207845521888838759/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2013/05/fb-graph-gem-for-rails-how-to-post.html#comment-form' title='7 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/3207845521888838759'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/3207845521888838759'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2013/05/fb-graph-gem-for-rails-how-to-post.html' title='Fb Graph Gem for Rails : How to Post dynamic contents to Facebook Wall from your Rails Application '/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>7</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-46560369868981135</id><published>2013-01-17T02:32:00.000-08:00</published><updated>2014-03-18T22:55:57.191-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Devise"/><category scheme="http://www.blogger.com/atom/ns#" term="Omniauth"/><category scheme="http://www.blogger.com/atom/ns#" term="Ruby on Rails"/><title type='text'>Ruby On Rails: Omniauth Devise Authentication using Facebook , Google &amp; Twitter.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This post is just a simple straightforward description of &lt;a href=&quot;https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview&quot; target=&quot;_blank&quot;&gt;Omniauth:Overview&lt;/a&gt; , intended for the beginners , those who wants to try the OmniAuth for the first time with Facebook , Google &amp;amp; Twitter. This post will cover all the basic information i.e From creating the app in Facebook, Google &amp;amp; Twitter for getting the secret key To connect these Apps to your Rails Application.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;Things in common :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;add Devise &amp;amp; omniauth gem to your Gemfile.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: Verdana, sans-serif;&quot;&gt;&lt;i&gt;gem &#39;omniauth&#39;&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: Verdana, sans-serif;&quot;&gt;&lt;i&gt;gem &#39;devise&#39;&amp;nbsp;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: Verdana, sans-serif;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;First of all install Devise into your application.&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;rails generate devise:install &amp;nbsp;&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;You have to create user model using devise ,&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;rails g devise user &amp;nbsp;&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;and after that we need to add 2 more columns&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;i.e &quot;uid&quot; and &#39;provider&#39; to our user model.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;

&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;rails g migration AddColumnsToUsers provider:string uid:string
rake db:migrate
&lt;/pre&gt;
&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;also dont forget to add &quot;:provider&quot; and &quot;:uid&quot; to your attr_accessible also.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;We have done with the things that is common in authentication using facebook,Google, Twitter.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;We will start with Facebook Authentication first&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&lt;b&gt;Facebook Authentication :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;add &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;i&gt;gem &#39;omniauth-facebook&#39;&lt;/i&gt; &lt;/span&gt;to your gem file.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;First of all you need to create an application in &lt;a href=&quot;https://developers.facebook.com/&quot; target=&quot;_blank&quot;&gt;facebook&lt;/a&gt; to get the secret key out .&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6m7I36PWSMQP9JPC7cttjXNgJbss5poGmeeJoGXmzGzUC2sZdvkwf0La8_o4JXZ4v6uPuUVC11vO4st-CW8RRFETeKFHTWR9fXxK11K_6VyjNyinbenS6quUo8mh9dM1wyI73PcWBq2I/s1600/facebook.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6m7I36PWSMQP9JPC7cttjXNgJbss5poGmeeJoGXmzGzUC2sZdvkwf0La8_o4JXZ4v6uPuUVC11vO4st-CW8RRFETeKFHTWR9fXxK11K_6VyjNyinbenS6quUo8mh9dM1wyI73PcWBq2I/s1600/facebook.jpg&quot; height=&quot;506&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Next, you need to declare the provider in your (&lt;/span&gt;&lt;i style=&quot;font-family: Verdana, sans-serif;&quot;&gt;config/initializers/devise.rb&lt;/i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;) and require it&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;/span&gt;

&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;require &quot;omniauth-facebook&quot;
config.omniauth :facebook, &quot;APP_ID&quot;, &quot;APP_SECRET&quot;&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;if you have done with all the above , you need to make your model (e.g.&lt;i&gt; app/models/user.rb&lt;/i&gt;) omniauthable:&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;devise :omniauthable
&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Better restart your server to&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;recognize the changes you have made in&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;Devise Initializer.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now Devise will create the following url methods.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;user_omniauth_authorize_path(provider)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;user_omniauth_callback_path(provide)&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;use the below line of code in your view file wherever you want to provide the Facebook link to authorize for the users.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;&amp;lt;%= link_to &quot;Sign in with Facebook&quot;, user_omniauth_authorize_path(:facebook) %&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;When the user clicks on the above link, they will redirects to the Facebook login page, after entering their credentials it will again redirect the user back to our applications Callback method . Its time to create Callback method for our application.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;To implement the callback method, &amp;nbsp;first of all we need to again return back to our &lt;i&gt;config/routes.rb&lt;/i&gt; file and need to tell Devise , in which controller we are going to create that callback action.&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;devise_for :users, :controllers =&amp;gt; { :omniauth_callbacks =&amp;gt; &quot;users/omniauth_callbacks&quot; }&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 21px;&quot;&gt;Now we we are going to add a new controller file inside our Rails controller directory &quot;app/controllers/users/omniauth_callbacks_controller.rb&quot; and put the following line code &amp;nbsp;in your&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: Verdana, sans-serif; line-height: 21px;&quot;&gt;omniauth_callbacks_controller.rb&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 21px;&quot;&gt;&amp;nbsp;file.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 21px;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 21px;&quot;&gt;We will start with Facebook provider first .You have to care about one thing that the action name should be the same as the provider name.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;class Users::OmniauthCallbacksController &amp;lt; Devise::OmniauthCallbacksController
  def facebook
    # You need to implement the method below in your model (e.g. app/models/user.rb)
    @user = User.find_for_facebook_oauth(request.env[&quot;omniauth.auth&quot;], current_user)

    if @user.persisted?
      sign_in_and_redirect @user, :event =&amp;gt; :authentication #this will throw if @user is not activated
      set_flash_message(:notice, :success, :kind =&amp;gt; &quot;Facebook&quot;) if is_navigational_format?
    else
      session[&quot;devise.facebook_data&quot;] = request.env[&quot;omniauth.auth&quot;]
      redirect_to new_user_registration_url
    end
  end
end&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;What is happening inside this callback action ?&lt;/b&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;When the user enters the credentials in the Facebook sign in form, Facebook actually  returns the default information&#39;s regarding the particular user , and all that information&#39;s retrieved from Facebook by omniauth will be available as a hash at &lt;/span&gt;&lt;b style=&quot;font-family: Verdana, sans-serif;&quot;&gt;request.env[&quot;omniauth.auth&quot;]. &lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;try to print this hash for better understanding of what information&#39;s are retrieved from Facebook.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Then we are actually calling a method in user model (we are going to add soon ) with request hash as an argument.If the user logs in for the first time &lt;b&gt;&quot;find_for_facebook_oauth()&quot; &lt;/b&gt;function will create a new entry in our user model,when the new user user has been saved properly in our database, it return that user and assigns to  an instance variable &lt;b&gt;@user.&lt;/b&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If the User model returns a valid user , we should sign in and redirect that user to our application , that is why we are passing the &lt;b&gt;:event =&amp;gt; :authentication&lt;/b&gt; to the &lt;b&gt;sign_in_and_redirect method&lt;/b&gt; to force all authentication callbacks to be called.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In case the user is not persisted , we store the omniauth data in the session.Notice we store this data using &quot;devise.&quot; as key namespace. This is useful because Devise removes all the data starting with &quot;devise.&quot; from the session whenever a user signs in, so we get automatic session clean up. At the end, we redirect the user back to our registration form.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Suppose you doesn&#39;t want to provide an external registration event (i.e you want to remove the Registerable module from your app ) . you can comment the &lt;b&gt;Registerable&lt;/b&gt; module in the devise User model, it will automatically removes  all the links and routes to the registration page. and after that we can redirect to root_path if the user is not persisted.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now we are going to implement the &lt;/span&gt;&lt;b style=&quot;font-family: Verdana, sans-serif;&quot;&gt;find_for_facebook_oauth &lt;/b&gt;&lt;span style=&quot;font-family: Verdana, sans-serif;&quot;&gt;method in our user model (e.g. app/models/user.rb) : &lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;def self.find_for_facebook_oauth(auth, signed_in_resource=nil)
    user = User.where(:provider =&amp;gt; auth.provider, :uid =&amp;gt; auth.uid).first
    if user
      return user
    else
      registered_user = User.where(:email =&amp;gt; auth.info.email).first
      if registered_user
        return registered_user
      else
        user = User.create(name:auth.extra.raw_info.name,
                            provider:auth.provider,
                            uid:auth.uid,
                            email:auth.info.email,
                            password:Devise.friendly_token[0,20]
                          )
      end
      
    end
  end
&lt;/pre&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here you will find some changes compared to the github omniauth documentation.the reason why i have made these changes , you can get it from this &lt;a href=&quot;http://stackoverflow.com/questions/13246802/how-to-accomplish-multiple-authentication-using-devise-omniauth-facebook-tw&quot; target=&quot;_blank&quot;&gt;stckoverflow question &lt;/a&gt;&amp;nbsp;.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The method above simply tries to find an existing user by using the provider , but if the user is already registered in our application using the same email id but different provider, then we need to restrict the user from creating again the same user entry, otherwise if the user tries to register with the same email account but different provider, Devise will throw error and will restrict the user from signing&amp;nbsp;in&amp;nbsp;to our application. so that is why we are checking again whether the use have already signed in our application using any provider and we have created the user entry&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;in our application&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;. suppose if we finds the registered user , we need to return the registered&amp;nbsp;user, else if the user is not at all registered in our application we are actually creates that user with attributes name, provider, email &amp;nbsp;and with a random password.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;So that is all you want , we have completed the Facebook authentication using omniauth.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;Google Authentication :&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This is just the same as Facebook&amp;nbsp;authentication, first of all you need to register your app in &lt;a href=&quot;https://code.google.com/apis/console/&quot; target=&quot;_blank&quot;&gt;Google&lt;/a&gt; to get the API key.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;You need to update the redirect uri for the API access, if you are using localhost use the following &quot;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;i&gt;http://localhost:3000/users/auth/google_oauth2/callback&lt;/i&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&quot; like shown in the image.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzugL3rFIRazIsv5q_W_c7gnwtJUROS43_9khPjJJnIKe8igj8xYYIpORtD2CCRBGYsJ_JAAx9Oevqa_yTSga18OIvXZd8TBpZOaLEhXiOTVkkFxXtELtKDonYJPvlXd3Cei3gAQ2wYZY/s1600/google.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzugL3rFIRazIsv5q_W_c7gnwtJUROS43_9khPjJJnIKe8igj8xYYIpORtD2CCRBGYsJ_JAAx9Oevqa_yTSga18OIvXZd8TBpZOaLEhXiOTVkkFxXtELtKDonYJPvlXd3Cei3gAQ2wYZY/s1600/google.jpg&quot; height=&quot;261&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;add &#39;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;i&gt;gem &#39;omniauth-google-oauth2&#39;&lt;/i&gt;&lt;/span&gt;&amp;nbsp;&#39; to your Gemfile. then bundle install&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;require it in &#39;&lt;i&gt;config/initializers/devise.rb&lt;/i&gt;&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;require &quot;omniauth-google-oauth2&quot;
config.omniauth :google_oauth2, &quot;APP_ID&quot;, &quot;APP_SECRET&quot;, { access_type: &quot;offline&quot;, approval_prompt: &quot;&quot; }
&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Add the following link to your view file where you want to put the google sign in option.&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;&amp;lt;%= link_to &quot;Sign in with Google&quot;, user_omniauth_authorize_path(:google_oauth2) %&amp;gt;
&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;When the user clicks on the above link, they will redirects to the Google login page, after entering their credentials it will again redirect the user back to our applications Callback method.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;

&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Inside &quot;&lt;i&gt;omniauth_callback_controller&quot; &amp;nbsp;&lt;/i&gt;add the following function &quot;&lt;i&gt;google_oauth2&quot;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;class Users::OmniauthCallbacksController &amp;lt; Devise::OmniauthCallbacksController
  def google_oauth2
    
    @user = User.find_for_google_oauth2(request.env[&quot;omniauth.auth&quot;], current_user)

    if @user.persisted?
      flash[:notice] = I18n.t &quot;devise.omniauth_callbacks.success&quot;, :kind =&amp;gt; &quot;Google&quot;
      sign_in_and_redirect @user, :event =&amp;gt; :authentication
    else
      session[&quot;devise.google_data&quot;] = request.env[&quot;omniauth.auth&quot;]
      redirect_to new_user_registration_url
    end
  end
end
&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Inside the user model. &quot;&lt;i&gt;app/models/user.rb&lt;/i&gt;&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;def self.find_for_google_oauth2(access_token, signed_in_resource=nil)
    data = access_token.info
    user = User.where(:provider =&amp;gt; access_token.provider, :uid =&amp;gt; access_token.uid ).first
    if user
      return user
    else
      registered_user = User.where(:email =&amp;gt; access_token.info.email).first
      if registered_user
        return registered_user
      else
        user = User.create(name: data[&quot;name&quot;],
          provider:access_token.provider,
          email: data[&quot;email&quot;],
          uid: access_token.uid ,
          password: Devise.friendly_token[0,20]
        )
      end
   end
end
&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Google Authentication is now ready to use.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;Twitter Authentication :&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Important thing in Twitter authentication is Twitter will not provide you email address for any reason , so for the&amp;nbsp;authentications&amp;nbsp;like we did in Facebook and Google, we cant identify a user by using an email whether the user is already registered (i.e have already created in our&amp;nbsp;application) or not.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;What i did here is , i have created &amp;nbsp;a fake email by appending the provider id with the domain string &quot;twitter.com&quot; like &quot;2312234@twitter.com&quot;.this will be a unique entry.but this also will not solve our problem, because ones the user have registered in our application for the first time the twitter account , we cant get the email that is for sure , but we are creating one with provider id and domain that is also fine. but we cant identify the user whether he is already registered or not when he/she tries to login for the second time by using Facebook or Google provider.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If you are fine with it you can go forward, i know this is not a good solution. but here we cant leave the column email as blank, we have to enter something in email column when creating a user.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;So first of all creates your twitter application here for getting the API key. put the website field as the following &lt;i&gt;&quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;http://127.0.0.1:3000/&lt;/span&gt;&quot;&lt;/i&gt; if your are using localhost and callback URL also as following &lt;i&gt;&lt;b&gt;&quot;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;http://127.0.0.1:3000/auth/twitter/callback&lt;/span&gt;&lt;/i&gt;&quot;.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDBt37Kf4Wwyk2gTjsnjM0i258r7GAgVNP5HepeuGZHafYQF4ZnYIO66MD-8Q8gjRYJe6ut_7IvHLmGF6os57Dv7kmkXdk209LypuSn8Azc0zB1gKEXA0mcXQNJ8OEXiLkU7QKHiPDAvk/s1600/twitter.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDBt37Kf4Wwyk2gTjsnjM0i258r7GAgVNP5HepeuGZHafYQF4ZnYIO66MD-8Q8gjRYJe6ut_7IvHLmGF6os57Dv7kmkXdk209LypuSn8Azc0zB1gKEXA0mcXQNJ8OEXiLkU7QKHiPDAvk/s1600/twitter.jpg&quot; height=&quot;314&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Add the gem&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&lt;i&gt;gem &#39;omniauth-twitter&lt;/i&gt;&lt;/span&gt;&#39; to your Gemfile. and bundle install.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Require it in &quot;config/initializers/devise.rb&quot;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;require &#39;omniauth-twitter&#39;
config.omniauth :twitter ,&quot;APP_ID&quot;, &quot;APP_SECRET&quot;
&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Add the following link to your view file for twitter sign in option.&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;&amp;lt;%= link_to &quot;Sign in with Twitter&quot;, user_omniauth_authorize_path(:twitter) %&amp;gt;
&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;When the user clicks on the above link, they will redirects to the Twitter login page, after entering their credentials it will again redirect the user back to our applications Callback method.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Inside &quot;&lt;i&gt;omniauth_callback_controller&quot;&lt;b&gt;&amp;nbsp;&lt;/b&gt;create a function named &quot;twitter&quot; like following,&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;class Users::OmniauthCallbacksController &amp;lt; Devise::OmniauthCallbacksController
  def twitter
    auth = env[&quot;omniauth.auth&quot;]
    #Rails.logger.info(&quot;auth is **************** #{auth.to_yaml}&quot;)
    @user = User.find_for_twitter_oauth(request.env[&quot;omniauth.auth&quot;],current_user)
    if @user.persisted?
      flash[:notice] = I18n.t &quot;devise.omniauth_callbacks.success&quot;
      sign_in_and_redirect @user, :event =&amp;gt; :authentication
    else
      session[&quot;devise.twitter_uid&quot;] = request.env[&quot;omniauth.auth&quot;]
      redirect_to new_user_registration_url
    end
  end
end
&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;inside your&lt;b&gt;&amp;nbsp;&quot;&lt;/b&gt;&lt;i&gt;User&quot;&lt;/i&gt; model, add the following method.&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: ruby&quot;&gt;  def self.find_for_twitter_oauth(auth, signed_in_resource=nil)

    user = User.where(:provider =&amp;gt; auth.provider, :uid =&amp;gt; auth.uid).first
    if user
      return user
    else
      registered_user = User.where(:email =&amp;gt; auth.uid + &quot;@twitter.com&quot;).first
      if registered_user
        return registered_user
      else
        user = User.create(name:auth.info.name,
          provider:auth.provider,
          uid:auth.uid,
          email:auth.uid+&quot;@twitter.com&quot;,
          password:Devise.friendly_token[0,20]
        )
      end
    end
  end
&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;That is all you need about Facebook,Google &amp;amp; Twitter&amp;nbsp;authentication! ,&amp;nbsp;&amp;nbsp;try it yourself , have fun coding.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/46560369868981135/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2013/01/omniauth-devise-authentication-using.html#comment-form' title='17 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/46560369868981135'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/46560369868981135'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2013/01/omniauth-devise-authentication-using.html' title='Ruby On Rails: Omniauth Devise Authentication using Facebook , Google &amp; Twitter.'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj6m7I36PWSMQP9JPC7cttjXNgJbss5poGmeeJoGXmzGzUC2sZdvkwf0La8_o4JXZ4v6uPuUVC11vO4st-CW8RRFETeKFHTWR9fXxK11K_6VyjNyinbenS6quUo8mh9dM1wyI73PcWBq2I/s72-c/facebook.jpg" height="72" width="72"/><thr:total>17</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-5224215897276624098</id><published>2012-12-09T23:54:00.002-08:00</published><updated>2012-12-10T21:14:25.090-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ruby"/><title type='text'>Operator Overloading in Ruby </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I expect many of you know that Ruby permits Operator overloading .Many of Ruby&#39;s operators are implemented as methods, you can define or redefine how these methods or &amp;nbsp;operators should work in your own classes , here i am trying to mention some fun facts that we can do with ruby.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I expect all of you should be knowing this , may be better than me as well . But this is a just a simple but strait forward example for the beginners like me, &amp;nbsp;those who wanted to experiment more on Ruby.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Creating a class called &lt;b&gt;ClassA&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;class ClassA
&amp;nbsp; attr_accessor :value
&amp;nbsp; def initialize(value)
&amp;nbsp; &amp;nbsp; @value = value
&amp;nbsp; &amp;nbsp; &amp;nbsp;puts &quot;Object of ClassA with value #{@value} has been created&quot;
&amp;nbsp; end
&amp;nbsp;end
&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;and Instantiating one obj of&lt;b&gt; ClassA,&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;a=ClassA.new(10)
Object of ClassA with value 10 has been created&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;What if ruby permits a behavior like you can add objects of 2 different classes , then you are receiving the output without creating any scene , it will be fun right.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Creating another class called &lt;b&gt;ClassB,&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;class ClassB
&amp;nbsp; attr_accessor :value
&amp;nbsp; def initialize(value)
&amp;nbsp; &amp;nbsp; @value = value
&amp;nbsp; &amp;nbsp; &amp;nbsp;puts &quot;Object of ClassB with value #{@value} has been created&quot;
&amp;nbsp; end
&amp;nbsp;end
&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;and instantiating the&lt;b&gt; ClassB&lt;/b&gt; obj like,&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;b=ClassB.new(20)
Object of ClassB with value 20 has been created&lt;/pre&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now we are overloading the behavior of&lt;b&gt; &#39;+&#39;&lt;/b&gt; operator by defining a function like ,&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;class ClassA
&amp;nbsp; attr_accessor :value
&amp;nbsp; def initialize(value)
&amp;nbsp; &amp;nbsp; @value = value
&amp;nbsp; &amp;nbsp; &amp;nbsp;puts &quot;Object of ClassA with value #{@value} has been created&quot;
&amp;nbsp; end
&amp;nbsp; def +(obj)
&amp;nbsp; &amp;nbsp; return ClassA.new(self.value + obj.value)
&amp;nbsp; end
&amp;nbsp;end

class ClassB
&amp;nbsp; attr_accessor :value
&amp;nbsp; def initialize(value)
&amp;nbsp; &amp;nbsp; @value = value
&amp;nbsp; &amp;nbsp; &amp;nbsp;puts &quot;Object of ClassB with value #{@value} has been created&quot;
&amp;nbsp; end
&amp;nbsp; def +(obj)
&amp;nbsp; &amp;nbsp; return ClassB.new(self.value + obj.value)
&amp;nbsp; end
&amp;nbsp;end

&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;What will happen if we are performing an addition using these 2 objects a &amp;amp; b,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;c = a + b&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;the fun begins here,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;try to print &lt;b&gt;c.value&lt;/b&gt; you will get the value 30,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;How this magic happens ,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Operators are just methods in Ruby , &amp;nbsp;all the arithmetic operators are behaves like methods and we are passing values as arguments , like in the above example &lt;b&gt;a + b , &lt;/b&gt;we are calling the method called&lt;b&gt;&amp;nbsp;&#39;+&#39; &lt;/b&gt;and passing &lt;b&gt;b&lt;/b&gt; as an argument &amp;nbsp;. This is same with all the arithmetic operators.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If you have created 3rd class also like &lt;b&gt;ClassC&lt;/b&gt;, and have created &lt;b&gt;obj c = ClassC.new(30)&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;You will get the results while trying all the possible way like,&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;a+b+c&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;a+(b+c)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;(a+b)+c&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/5224215897276624098/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2012/12/operator-overloading-in-ruby.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/5224215897276624098'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/5224215897276624098'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2012/12/operator-overloading-in-ruby.html' title='Operator Overloading in Ruby '/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-4126737887129218620</id><published>2012-03-24T01:10:00.004-07:00</published><updated>2012-03-25T23:02:21.437-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ruby on Rails"/><title type='text'>Ruby on Rails : How to include a page specific JavaScript file in Rails 3.1?</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Rails 3.1 application has a new effective way to include a&amp;nbsp;JavaScript file for a particular page without compromising the loading time by using Asset pipeline.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;You all know that&amp;nbsp;&amp;nbsp;in previous versions of Rails, all assets were located in subdirectories of public such as images,javascripts and stylesheets. With the asset pipeline, the preferred location for these assets is now the app/assets directory.Assets can still be placed in the public hierarchy. Any assets under public will be served as static files by the application or web server.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;In production, Rails precompiles these files to public/assets by default. The precompiled copies are then served as static assets by the web server. The files in app/assets are never served directly in production.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;a name=&#39;more&#39;&gt;&lt;/a&gt; &lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;If you want to add a&amp;nbsp;JavaScript&amp;nbsp;file for a particular page in your Rails 3.1 application,just follow the steps below ,its working fine for me.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Mention the&amp;nbsp;JavaScript&amp;nbsp;file name that you want to access from a particular page in &lt;b&gt;Config -&amp;gt; environments -&amp;gt; production.rb&lt;/b&gt; like shown below.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: js&quot; style=&quot;text-align: left;&quot;&gt;Demo::Application.configure do

       .
       .
   config.assets.precompile += %w( application.css application.js flexpaper.js data_table.js public.js jquery.Jcrop.js jquery.Jcrop.min.js google_org_chart_query_wrapper.js jquery.jstree.js)
       .
       .   
end&lt;/pre&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Mention the JavaScript file name that you want to include in a particular view page by using the JavaScript include tag like.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;pre class=&quot;brush: js&quot;&gt;&amp;lt;%= javascript_include_tag &quot;jquery.jstree&quot; %&amp;gt;&lt;/pre&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;After that you need to precompile the assets.You all know that Rails comes bundled with a rake task to compile the asset manifests and other files in the pipeline to the disk.Compiled assets are written to the location specified in config.assets.prefix. By default, this is the public/assets directory.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; The rake task is:&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre class=&quot;brush: js&quot;&gt;bundle exec rake assets:precompile&amp;nbsp;&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/4126737887129218620/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2012/03/ruby-on-rails-how-to-include-page.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/4126737887129218620'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/4126737887129218620'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2012/03/ruby-on-rails-how-to-include-page.html' title='Ruby on Rails : How to include a page specific JavaScript file in Rails 3.1?'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-3065030210736181742</id><published>2012-01-23T23:38:00.001-08:00</published><updated>2012-09-24T03:04:36.540-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Jcrop"/><category scheme="http://www.blogger.com/atom/ns#" term="Ruby on Rails"/><title type='text'>Ruby on Rails :Cropping images in runtime using Jcrop &amp; ImageMagick</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In the previous &lt;a href=&quot;http://sreeharikmarar.blogspot.com/2012/01/ruby-on-rails-image-hiding-using-jcrop.html&quot; target=&quot;_blank&quot;&gt;post&lt;/a&gt; i have mentioned about integrating the Jcrop functionality with ImageMagick to hide the selected&amp;nbsp;coordinates&amp;nbsp;&amp;nbsp;of &amp;nbsp;the image using a specific color.But here i &amp;nbsp;am describing on the core feature of Jcrop i.e cropping the image in runtime with the selected&amp;nbsp;coordinates.Here also , we are using ImageMagick in server side to accomplish the whole process.&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;You all know that Jcrop is a powerful image cropping engine for jQuery. It’s been designed so developers can easily integrate an advanced image cropping functionality directly into any web-based application without sacrificing their time ,flexibility and&amp;nbsp;performance.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: &#39;Times New Roman&#39;; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;ImageMagick is a software suite&amp;nbsp;to create, edit, compose, or convert bitmap images.&amp;nbsp;It can read and write images in a variety of fomats (over 100) like&amp;nbsp;&amp;nbsp; DPX,&amp;nbsp;EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. We can use ImageMagick to&amp;nbsp;resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves. ImageMagick have a power full command line tool known as “Convert”. Convert has around 265 &amp;nbsp;options for manipulating images .&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: &#39;Times New Roman&#39;; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;So now we are going to integrate this two with Rails ,i wont go in depth of how to create the whole process.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: &#39;Times New Roman&#39;; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;In summery :&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: &#39;Times New Roman&#39;; list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 24px; margin-left: 1.5em; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;User choose an image and uploads to a server using paperclip.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Wep app shows the images to user and allows him/her to select the desired piece of selection of the image to hide using Jcrop.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Using an Ajax post request ,we are sending the parameters&amp;nbsp;(X-cord,Y-cord,Height,Width) to the sever which responsible to crop the portion of the image.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The appropriate action in the controller will accept the parameters,and then crop the parameters by using a&amp;nbsp;piece&amp;nbsp;of Image-magic&amp;nbsp;code.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: &#39;Times New Roman&#39;; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Jcrop Action :&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: &#39;Times New Roman&#39;; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In the client side ,where we are showing the uploaded image to the user.Here we have to add the Jcrop functionality to select the&amp;nbsp;coordinates&amp;nbsp;of the selection that the user want to crop .&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here you could see a button for “CROP” . I will brief you the actions behind this button.The CROP button will captures the desired&amp;nbsp;parameters of the &amp;nbsp;selection on the click event ,and then add it to a list called &quot;crop_list&quot;.when the user clicks the button the&amp;nbsp;coordinates&amp;nbsp;will push to the crop_list and then sending the&amp;nbsp;coordinates&amp;nbsp;as a parameter by using an AJAX post request to the desired URL which accepting the parameters.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;&amp;lt;img src=&quot; // your image source&quot; id=&quot;target&quot; /&amp;gt;

&amp;lt;form id=&quot;coords&quot;
class=&quot;coords&quot;
onsubmit=&quot;return false;&quot;
action=&quot;http://example.com/post.php&quot;&amp;gt;
&amp;lt;div&amp;gt;
&amp;lt;input type=&quot;hidden&quot; size=&quot;4&quot; id=&quot;x1&quot; name=&quot;x1&quot; /&amp;gt;
&amp;lt;input type=&quot;hidden&quot; size=&quot;4&quot; id=&quot;y1&quot; name=&quot;y1&quot; /&amp;gt;
&amp;lt;input type=&quot;hidden&quot; size=&quot;4&quot; id=&quot;x2&quot; name=&quot;x2&quot; /&amp;gt;
&amp;lt;input type=&quot;hidden&quot; size=&quot;4&quot; id=&quot;y2&quot; name=&quot;y2&quot; /&amp;gt;
&amp;lt;input type=&quot;hidden&quot; size=&quot;4&quot; id=&quot;w&quot; name=&quot;w&quot; /&amp;gt;
&amp;lt;input type=&quot;hidden&quot; size=&quot;4&quot; id=&quot;h&quot; name=&quot;h&quot; /&amp;gt;

&amp;lt;/div&amp;gt;
&amp;lt;button id = &quot;crop&quot; &amp;gt;CROP&amp;lt;/button&amp;gt;


&amp;lt;/form&amp;gt;
&amp;lt;div style=&quot;clear:both;display: block;height: 5px;&quot; &amp;gt;&amp;lt;/div&amp;gt;
 &amp;lt;div id=&quot;outer&quot;&amp;gt;
  &amp;lt;div class=&quot;jcExample&quot;&amp;gt;
   &amp;lt;div class=&quot;article&quot;&amp;gt;
    &amp;lt;div id=&quot;interface&quot; style=&quot;margin: 1em 0;&quot;&amp;gt;&amp;lt;/div&amp;gt;

  &amp;lt;/div&amp;gt;
 &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;



&amp;lt;/style&amp;gt;

&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
jQuery(function($){

$(&#39;#target&#39;).Jcrop({
onChange: showCoords,
onSelect: showCoords,
onRelease: clearCoords
});

});
function showCoords(c)
{
$(&#39;#x1&#39;).val(c.x);
$(&#39;#y1&#39;).val(c.y);
$(&#39;#x2&#39;).val(c.x2);
$(&#39;#y2&#39;).val(c.y2);
$(&#39;#w&#39;).val(c.w);
$(&#39;#h&#39;).val(c.h);
};

function clearCoords()
{
$(&#39;#coords input&#39;).val(&#39;&#39;);
$(&#39;#h&#39;).css({color:&#39;red&#39;});
window.setTimeout(function(){
$(&#39;#h&#39;).css({color:&#39;inherit&#39;});
},500);
};

&amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: &#39;Times New Roman&#39;; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now the crop_list contains all the&amp;nbsp;selected coordinates that the user wants to crop ,and then we are sending all these&amp;nbsp;coordinates&amp;nbsp;to a server using Ajax post&amp;nbsp;request&amp;nbsp;with the&amp;nbsp;selected&amp;nbsp;coordinates&amp;nbsp;as&amp;nbsp;parameters&amp;nbsp;.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;

var crop_list=[];
var cord_list=[];

jQuery(document).ready(function(){
  jQuery(&quot;#crop&quot;).click(function(){

    var X1 = jQuery(&quot;#x1&quot;).val();
    var Y1 = jQuery(&quot;#y1&quot;).val();
    var X2 = jQuery(&quot;#x2&quot;).val();
    var Y2 = jQuery(&quot;#y2&quot;).val();
    var W = jQuery(&quot;#w&quot;).val();
    var H = jQuery(&quot;#h&quot;).val();

    cord_list= [W,H,X1,Y1];

    crop_list.push(cord_list);

 
    var val = crop_list;
    jQuery.ajax({
      type: &quot;POST&quot;,
      url: &quot;/image/crop&quot;,
      data: {&quot;cordinates&quot;: val},
      complete: function () {
      window.location.reload(true);
      }});
   }):
});

&amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: &#39;Times New Roman&#39;; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;ImageMagick Action :&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-family: &#39;Times New Roman&#39;; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now we comes to the server side.I have created an action called &quot;crop&quot; in my rails application&#39;s controller.Here the &quot;crop&quot; action will accept the parameters, and then the magic comes with that snippet of &amp;nbsp;ImageMagic as shown below.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;def crop
    cordinates = params[&quot;cordinates&quot;]
    image_path = &quot;# specify your image path &quot;
    coordinates.each do |item|
       coordinate = item[1]
       cord = coordinate[0].to_s + &#39;x&#39; + coordinate[1].to_s + &#39;+&#39; + coordinate[2].to_s + &#39;+&#39; +        coordinate[3].to_s

       system &quot;convert #{img_path} -crop #{cord} #{img_path}&quot;
    end
end.&lt;/pre&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The main keyword that you have to notice in the above snippet is&amp;nbsp;&lt;b&gt;&quot;crop&quot;&lt;/b&gt;.The &lt;b&gt;&quot;cord&quot;&lt;/b&gt; variable&amp;nbsp;is nothing but the coordinates that we are sending via an ajax post request to the server.The coordinates are nothing but&amp;nbsp;&lt;b&gt;&quot;Height&quot;,&quot;Width&quot;,&quot;X-cord&quot;,&quot;Y-cord&quot;&lt;/b&gt;.Here we are accepting that coordinates using params key word and assigning it to a variable .Then we have to specify the &lt;b&gt;image_path&lt;/b&gt; of the desired image that you wants to crop.&lt;b&gt;&quot;crop&quot;&lt;/b&gt;&amp;nbsp;keyword will do the cropping function by an amount that we are specified.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here we are iterating the loop and executing the command number of times equal to the number of selection.&lt;b&gt;&quot;System&quot;&lt;/b&gt;&amp;nbsp;is the command in ruby to execute shell commands from the script.After executing the above script we will get the modified picture and then as a response we can send it to a client.But here in the Ajax post request i just coded the command to reload the whole page again as response to affect the changes in the client side.Now the client will see the new image with the applied changes.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I have hosted this application in Heroku. Check out the below link,&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;a href=&quot;http://cropimage.herokuapp.com/&quot;&gt;http://cropimage.herokuapp.com/&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/3065030210736181742/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2012/01/ruby-on-rails-cropping-images-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/3065030210736181742'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/3065030210736181742'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2012/01/ruby-on-rails-cropping-images-in.html' title='Ruby on Rails :Cropping images in runtime using Jcrop &amp; ImageMagick'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-8827144027735139333</id><published>2012-01-12T19:49:00.001-08:00</published><updated>2012-09-24T03:07:32.110-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Jcrop"/><category scheme="http://www.blogger.com/atom/ns#" term="Ruby on Rails"/><title type='text'>Ruby on Rails : Image hiding using Jcrop &amp; ImageMagick</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; color: #333333; font-size: 16px; line-height: 24px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;You all know that Jcrop is a powerful image cropping engine for jQuery. It’s been designed so developers can easily integrate an advanced image cropping functionality directly into any web-based application without sacrificing their time ,flexibility and&amp;nbsp;performance.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;ImageMagick is a software suite&amp;nbsp;to create, edit, compose, or convert bitmap images.&amp;nbsp;It can read and write images in a variety of fomats (over 100) like&amp;nbsp;&amp;nbsp; DPX,&amp;nbsp;EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. We can use ImageMagick to&amp;nbsp;resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves. ImageMagick have a power full command line tool known as “Convert”. Convert has around 265 &amp;nbsp;options for manipulating images .&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;So now we are going to integrate this two with Rails ,i wont go in depth of how to create the whole process.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;b&gt;In summery :&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 24px; margin-left: 1.5em; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;User choose an image and uploads to a server using paperclip.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Wep app shows the images to user and allows him/her to select the desired piece of selection of the image to hide using Jcrop.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Using an Ajax post request ,we are sending the parameters&amp;nbsp;(X-cord,Y-cord,Height,Width) to the sever which responsible to hide the portion of the image.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The appropriate action in the controller will accept the parameters,and then hide the parameters by using a&amp;nbsp;piece&amp;nbsp;of Image-magic&amp;nbsp;code.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Jcrop Action :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In the client side ,where we are showing the uploaded image to the user.Here we have to add the Jcrop functionality to select the&amp;nbsp;coordinates&amp;nbsp;of the selection that the user want to hide .&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here you could see 2 buttons for “ADD” &amp;amp; “SAVE”. I will brief you the actions behind this buttons.Here we are providing a functionality to user that ,he/she can select multiple selections using Jcrop and then we add it to a list called “cord_list”.Here each time user have to click the add button to store the each selection into a “cord_list”, and after that we are pushing the each selction list into another list called “adj_list”.Now it will act like a list of list.&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;&amp;lt;img src=&quot; // your image source&quot; id=&quot;target&quot; /&amp;gt;

&amp;lt;form id=&quot;coords&quot;
class=&quot;coords&quot;
onsubmit=&quot;return false;&quot;
action=&quot;http://example.com/post.php&quot;&amp;gt;
&amp;lt;div&amp;gt;
&amp;lt;input type=&quot;hidden&quot; size=&quot;4&quot; id=&quot;x1&quot; name=&quot;x1&quot; /&amp;gt;
&amp;lt;input type=&quot;hidden&quot; size=&quot;4&quot; id=&quot;y1&quot; name=&quot;y1&quot; /&amp;gt;
&amp;lt;input type=&quot;hidden&quot; size=&quot;4&quot; id=&quot;x2&quot; name=&quot;x2&quot; /&amp;gt;
&amp;lt;input type=&quot;hidden&quot; size=&quot;4&quot; id=&quot;y2&quot; name=&quot;y2&quot; /&amp;gt;
&amp;lt;input type=&quot;hidden&quot; size=&quot;4&quot; id=&quot;w&quot; name=&quot;w&quot; /&amp;gt;
&amp;lt;input type=&quot;hidden&quot; size=&quot;4&quot; id=&quot;h&quot; name=&quot;h&quot; /&amp;gt;

&amp;lt;/div&amp;gt;
&amp;lt;button id = &quot;add&quot; &amp;gt;ADD&amp;lt;/button&amp;gt;
&amp;lt;button id =&quot;save&quot; &amp;gt;SAVE&amp;lt;/button&amp;gt;%&amp;gt;

&amp;lt;/form&amp;gt;
&amp;lt;div style=&quot;clear:both;display: block;height: 5px;&quot; &amp;gt;&amp;lt;/div&amp;gt;
 &amp;lt;div id=&quot;outer&quot;&amp;gt;
  &amp;lt;div class=&quot;jcExample&quot;&amp;gt;
   &amp;lt;div class=&quot;article&quot;&amp;gt;
    &amp;lt;div id=&quot;interface&quot; style=&quot;margin: 1em 0;&quot;&amp;gt;&amp;lt;/div&amp;gt;

  &amp;lt;/div&amp;gt;
 &amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;



&amp;lt;/style&amp;gt;

&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
jQuery(function($){

$(&#39;#target&#39;).Jcrop({
onChange: showCoords,
onSelect: showCoords,
onRelease: clearCoords
});

});
function showCoords(c)
{
$(&#39;#x1&#39;).val(c.x);
$(&#39;#y1&#39;).val(c.y);
$(&#39;#x2&#39;).val(c.x2);
$(&#39;#y2&#39;).val(c.y2);
$(&#39;#w&#39;).val(c.w);
$(&#39;#h&#39;).val(c.h);
};

function clearCoords()
{
$(&#39;#coords input&#39;).val(&#39;&#39;);
$(&#39;#h&#39;).css({color:&#39;red&#39;});
window.setTimeout(function(){
$(&#39;#h&#39;).css({color:&#39;inherit&#39;});
},500);
};

&amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now the adj_list contains all the&amp;nbsp;selection&amp;nbsp;coordinates that the user wants to hide ,and then we are sending all these&amp;nbsp;coordinates&amp;nbsp;to a server using Ajax post&amp;nbsp;request&amp;nbsp;with the&amp;nbsp;selected&amp;nbsp;coordinates&amp;nbsp;as&amp;nbsp;parameters&amp;nbsp;.&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;

var adj_list=[];
var cord_list=[];

jQuery(document).ready(function(){
  jQuery(&quot;#add&quot;).click(function(){

    var X1 = jQuery(&quot;#x1&quot;).val();
    var Y1 = jQuery(&quot;#y1&quot;).val();
    var X2 = jQuery(&quot;#x2&quot;).val();
    var Y2 = jQuery(&quot;#y2&quot;).val();
    var W = jQuery(&quot;#w&quot;).val();
    var H = jQuery(&quot;#h&quot;).val();

    cord_list= [W,H,X1,Y1];

    adj_list.push(cord_list);

  });

  jQuery(&quot;#save&quot;).click(function(){
    
    var val = adj_list;
    jQuery.ajax({
      type: &quot;POST&quot;,
      url: &quot;/image/save&quot;,
      data: {&quot;cordinates&quot;: val},
      complete: function () {
      window.location.reload(true);
      }});
  });
});

&amp;lt;/script&amp;gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;ImageMagic Action :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now we comes to the server side.I have created an action called save in my controller.Here the save action will accept the parameters, and then the magic comes with that snippet of &amp;nbsp;ImageMagic as shown below.&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;def save
    cordinates = params[&quot;cordinates&quot;]
    image_path = &quot;# specify your image path &quot;
    coordinates.each do |item|
       coordinate = item[1]
       cord = coordinate[0].to_s + &#39;x&#39; + coordinate[1].to_s + &#39;+&#39; + coordinate[2].to_s + &#39;+&#39; +        coordinate[3].to_s

       system &quot;convert #{img_path} -region #{cord} -fill white -colorize 100% #{img_path}&quot;
    end
end.&lt;/pre&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The main keywords that you have to notice in the above snippet,is that &lt;b&gt;&quot;region&quot;&lt;/b&gt; ,&lt;b&gt;&quot;fill&quot;&lt;/b&gt; &amp;amp; &lt;b&gt;&quot;colorize&quot;&lt;/b&gt;.The &quot;region&quot; is nothing but the coordinates that we are sending via an ajax post request to the server.The coordinates are nothing but &lt;b&gt;&quot;Height&quot;,&quot;Width&quot;,&quot;X-cord&quot;,&quot;Y-cord&quot;&lt;/b&gt;.Here we are accepting that coordinates using params key word and assigning it to a variable .Then we have to specify the image_path of the desired image that you wants to hide.&lt;b&gt;&quot;fill&quot; &lt;/b&gt;keyword indicates nothing but the color that the user wants to hide with.&lt;b&gt;&quot;Colorize&quot;&lt;/b&gt; keyword is used to colorize the image by an amount that we specified. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here we are iterating the loop and executing the command number of times equal to the number of selection.&lt;b&gt;&quot;System&quot;&lt;/b&gt; is the command in ruby to execute shell commands from the script.After executing the above script we will get the modified picture and then as a response we can send it to a client.But here in the Ajax post request i just put the command to reload the whole page again to affect the changes in the client side.Now the client will see the new image with the applied changes.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I have hosted this application in Heroku. Check out this,&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;a href=&quot;http://magicalcoloring.herokuapp.com/&quot;&gt;http://magicalcoloring.herokuapp.com/&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/8827144027735139333/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2012/01/ruby-on-rails-image-hiding-using-jcrop.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/8827144027735139333'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/8827144027735139333'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2012/01/ruby-on-rails-image-hiding-using-jcrop.html' title='Ruby on Rails : Image hiding using Jcrop &amp; ImageMagick'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-2219677751299481590</id><published>2012-01-03T22:04:00.001-08:00</published><updated>2012-10-21T07:46:33.480-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ruby on Rails"/><title type='text'>Ruby on Rails : Hosting your Ruby on Rails application in Heroku</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-size: 16px; line-height: 24px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;entry-content&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; clear: both; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 12px; vertical-align: baseline;&quot;&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;In my previous post,i have mentioned about creating a Ruby on Rails application using devise,Now in this tutorial we are going to host Ruby on Rails database backed application (Rails community web site) to Heroku.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;you all know that Heroku&amp;nbsp;is a polyglot cloud application platform. With Heroku, you don’t need to think about servers at all. You can write apps in&amp;nbsp;the programming language of your choice, back it with add-on resources such as&amp;nbsp;SQL&amp;nbsp;and&amp;nbsp;NoSQL&amp;nbsp;databases.You can manage your app using the Heroku command-line tool and you deploy code using the&amp;nbsp;Git&amp;nbsp;revision control system, all running on the&amp;nbsp;powerful Heroku infrastructure.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;We have created our Rails community website application with a MySQL database support.The only problem that you have to face while hosting your application in Heroku is that Heroku&amp;nbsp;doesn’t&amp;nbsp;support MySQL , Heroku only supports PostgreSQL database for your application.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Sign up :&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;/strong&gt;Before all, you have to create an account in Heroku,&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Install the Heroku Toolbelt on your system :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If you are using a Ubuntu/Linux machine,follow the steps below.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;$ apt-add-repository &#39;deb http://toolbelt.herokuapp.com/ubuntu ./&#39;

$ curl http://toolbelt.herokuapp.com/apt/release.key | apt-key add -

$ apt-get update

$ apt-get install heroku-toolbelt&lt;/pre&gt;
&lt;a name=&#39;more&#39;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Login :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;After installing the Toolbelt, you’ll have access to the&amp;nbsp;&lt;code style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;b&gt;heroku&lt;/b&gt;&lt;/code&gt;&amp;nbsp;command from your command shell. Log in using the email address and password you used when creating your Heroku account:&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;$ heroku login

Enter your Heroku credentials.
Email: adam@example.com
Password:
Could not find an existing public key.
Would you like to generate one? [Yn]
Generating new SSH public key.
Uploading ssh public key /Users/adam/.ssh/id_rsa.pub&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Install the Heroku Command-line Client :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Install the Heroku client by running the below command.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;$ gem install heroku&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Change the directory to where your application resides.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;$ cd rails-club&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Since Heroku doesnt support MySQL,You have to edit your gem file and the change the line&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;gem &#39;mysql2&#39;, &#39;0.3.6&#39;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;to this,&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;gem &#39;pg&#39;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Before that you should have to install the &lt;b&gt;PostgreSQL&lt;/b&gt; in your system.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once you have done all steps detailed above,then run the command&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;“bundle install”&lt;/strong&gt;&amp;nbsp;to&amp;nbsp;re-install your dependencies (to generate a new Gemfile.lock)&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;$ bundle install&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Initialize git to store your application in git :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;$ git init
$ git add .
$ git commit -m &quot;init&quot;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Deploy to Heroku/Cedar :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Create the app on the Cedar stack:&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;$ heroku create --stack cedar                                        
Creating fierce-fog-5356... done, stack is cedar
http://fierce-fog-5356.herokuapp.com/ | git@heroku.com:fierce-fog-5356.git
Git remote heroku added&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Deploy your code:&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;$ git remote add heroku git@heroku.com:fierce-fog-5356.git&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If you found an error reporting like,&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;fatal: remote heroku already exists.&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;run the following command,&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;$ git remote rm heroku&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;then you have to run the above command again.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ git remote add heroku git@heroku.com:fierce-fog-5356.git&lt;/span&gt;&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;and finally run the following command to deploy your application in Heroku&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;$ git push heroku master&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If the application hosted successfully in Heroku you will see something like&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;Launching... done, v5
       http://fierce-fog-5356.herokuapp.com deployed to Heroku&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;on your console.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;After that you have to run the&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;rake&lt;/strong&gt;&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;db:migrate&lt;/strong&gt;&amp;nbsp;command in Heroku, Rake can be run as an attached process exactly like the console.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;$ heroku run rake db:migrate&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;copy and paste the Heroku application URL (“&amp;nbsp;http://fierce-fog-5356.herokuapp.com “)&amp;nbsp;in your browser search bar.Now &amp;nbsp;you have successfully hosted your Rails application in Heroku.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If you have just pushed to Heroku and want to make sure that you are up-to-date, just run,&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; line-height: 21px; white-space: pre;&quot;&gt;$ git remote show heroku  &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace; font-size: x-small;&quot;&gt;       &lt;/span&gt;&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;then you will get output like this in your console.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: Verdana, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #222222; font-family: &#39;Courier 10 Pitch&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 15px; line-height: 21px; white-space: pre;&quot;&gt;* remote heroku
  Fetch URL: git@heroku.com:xxxx.git
  Push  URL: git@heroku.com:xxxx.git
  HEAD branch: master
  Remote branch:
    master tracked
  Local ref configured for &#39;git push&#39;:
    master pushes to master (up to date)&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;div class=&quot;sharedaddy sd-sharing-enabled&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; border-bottom-left-radius: 0px 0px !important; border-bottom-right-radius: 0px 0px !important; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-left-radius: 0px 0px !important; border-top-right-radius: 0px 0px !important; border-top-width: 0px; clear: both; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline; zoom: 1;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/2219677751299481590/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2012/01/hosting-your-ruby-on-rails-application.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/2219677751299481590'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/2219677751299481590'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2012/01/hosting-your-ruby-on-rails-application.html' title='Ruby on Rails : Hosting your Ruby on Rails application in Heroku'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-8375323996406188039</id><published>2012-01-03T05:01:00.000-08:00</published><updated>2013-10-18T04:56:01.302-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Devise"/><category scheme="http://www.blogger.com/atom/ns#" term="Ruby on Rails"/><title type='text'>Ruby on Rails : Creating a simple Ruby on Rails application using Devise.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #333333; font-family: Georgia, &#39;Bitstream Charter&#39;, serif; font-size: 16px; line-height: 24px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;entry-content&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; clear: both; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 12px; vertical-align: baseline;&quot;&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;If you have heard about rails and not yet&amp;nbsp;experienced&amp;nbsp;the power or features that , only rails can give ! &amp;nbsp;this tutorial will help you to create &amp;nbsp;Simple Ruby on Rails application without worrying too much about the syntax or working of Ruby on Rails.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here in this tutorial we will create a database backed simple Rails community website application, so that all members can register and sign-in to the website.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: Verdana, sans-serif;&quot;&gt;About Rails :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Rails is a web development frame work written in ruby language,which has a general MVC ( Model, View, Controller ) architecture.Using a Rails framework will make everything effortless for the developers,who wants to build a powerful/fast application with a less set of code and rails will also help them to&amp;nbsp;achieve&amp;nbsp;more than any other framework can provide.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: Verdana, sans-serif;&quot;&gt;About Devise :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Simply Devise is a flexible authentication solution for Rails based on Warden. It:&lt;/span&gt;&lt;/div&gt;
&lt;ul style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 24px; margin-left: 1.5em; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Is Rack based.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Is a complete MVC solution based on Rails engines.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Allows you to have multiple roles (or models/scopes) signed in at the same time.&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Is based on a modularity concept: use just what you really need.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: Verdana, sans-serif;&quot;&gt;Lets start coding:&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;/strong&gt;We are going to create a simple rails community website with the help of devise,Before wr entering to our application you should have to gone through the basics of devise.please refer the following link if you want to learn more about devise and rails.&lt;/span&gt;&lt;/div&gt;
&lt;ul style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 24px; margin-left: 1.5em; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;a href=&quot;http://railsforzombies.org/&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;http://railsforzombies.org/&lt;/a&gt;&amp;nbsp;(one of the best tutorial session for Rails&amp;nbsp;beginners&amp;nbsp;)&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;https://github.com/plataformatec/devise&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;https://github.com/plataformatec/devise&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;http://guides.rubyonrails.org/&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;http://guides.rubyonrails.org/&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;http://railscasts.com/episodes/310-getting-started-with-rails&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;http://railscasts.com/episodes/310-getting-started-with-rails&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: Verdana, sans-serif;&quot;&gt;Installation :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I am using ubuntu 11.04, if you are using ubuntu you can follow the below link to install rails in your system.You can also install rails in windows or mac as well.&lt;/span&gt;&lt;/div&gt;
&lt;ul style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; list-style-image: initial; list-style-position: initial; list-style-type: square; margin-bottom: 24px; margin-left: 1.5em; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;li style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&amp;nbsp;&lt;a href=&quot;http://stuffingabout.blogspot.com/2011/04/installing-rails-3-on-ubuntu-1104.html&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;http://stuffingabout.blogspot.com/2011/04/installing-rails-3-on-ubuntu-1104.html&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: Verdana, sans-serif;&quot;&gt;Creating your application :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once you have installed every dependencies,you can start creating your first application in rails.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Use&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;“rails new”&amp;nbsp;&lt;/strong&gt;command to create your application in rails,here we are going to create an application named rails-club.rails&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ rails new rails-club

$ cd rails-club&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;once you run the above command in your system, you can see that rails has generated so many files and folders inside your rails-club directory.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: Verdana, sans-serif;&quot;&gt;Editing the Gemfile :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;We are going to create this application by using a devise, i have already told you that this is a database backed application.If you are using mysql as your database system then you have to edit your ‘Gemfile’ inside your rails-club directory and add the following line to your ‘Gemfile’.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ gem &#39;mysql2&#39;, &#39;0.3.6&#39;&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once you have edited the Gemfile,please go through the files and directories the rails has generated,there is file called&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;“database.yml “&lt;/strong&gt;&amp;nbsp;in your&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;“config”&lt;/strong&gt;&amp;nbsp;directory.Change the&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;adapter&lt;/strong&gt;&amp;nbsp;to&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;mysql2,&lt;/strong&gt;and then specify your database,username and password . My “&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;database.yml”&lt;/strong&gt;&amp;nbsp;file contains the following data.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Filepath : config/database.yml&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;development:
adapter: mysql2
encoding: utf8
reconnect: false
database: mydb
pool: 5
username: root
password: asdfgh

production:
adapter: mysql2
encoding: utf8
reconnect: false
database: mydb
pool: 5
username: root
password: asdfgh
socket: /var/run/mysqld/mysqld.sock

test:
adapter: mysql2
encoding: utf8
reconnect: false
database: mydb_testing
pool: 5
username: root
password: asdfgh
socket: /var/run/mysqld/mysqld.sock&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once you have done all the changes then run the “bundle install” command.&amp;nbsp;This command tells “bundler”, a library used by Rails, to fetch and install all the libraries it needs.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ bundle install&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: Verdana, sans-serif;&quot;&gt;Installing Devise :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;You can use the latest Rails 3 gem with the latest Devise gem, to install the Devise run the following command.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ gem install devise&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;After you have installed Devise, you should have to specify the Devise gem to your Gemfile.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ gem &#39;devise&#39;&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;After that you need to run the generator by using the command below.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ rails generate devise:install&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;The generator will install an initializer which describes ALL Devise’s configuration options and you MUST take a look at it. When you are done, you are ready to add Devise to any of your models using the generator.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: Verdana, sans-serif;&quot;&gt;Creating Models :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here in this application we mainly needs 2 models,one is&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;member&lt;/strong&gt;&amp;nbsp;model and the other one is&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;contact&lt;/strong&gt;&amp;nbsp;model,the Member model should contain the member name, email, password, password confirmation etc.So now we are going to create our&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;member&lt;/strong&gt;&amp;nbsp;model using devise.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ rails generate devise member&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This will create a model member and configure it with default Devise modules.And will also create some more files in your directory. The migration file will located in db/migrate/devise_create_members.rb.After that you should have to run&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;db:migrate&lt;/strong&gt;&amp;nbsp;as the generator will have created a migration file.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ rake db:migrate

== DeviseCreateMembers: migrating ==================================
-- create_table(:members)
-&amp;gt; 0.2575s
-- add_index(:members, :email, {:unique=&amp;gt;true})
-&amp;gt; 0.3146s
-- add_index(:members, :reset_password_token, {:unique=&amp;gt;true})
-&amp;gt; 0.4259s
== DeviseCreateMembers: migrated (0.9986s) =========================&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once you run the db:migrate command,rails will create a table called members with the following field that the Devise specified in the migration file.Check the tables has created&amp;nbsp;successfully.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now we have successfully generated our model.Just run the server by typing “&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;rails server”&lt;/strong&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ rails server

=&amp;gt; Booting WEBrick
=&amp;gt; Rails 3.1.3 application starting in development on http://0.0.0.0:3000
=&amp;gt; Call with -d to detach
=&amp;gt; Ctrl-C to shutdown server
[2012-01-01 16:40:49] INFO WEBrick 1.3.1
[2012-01-01 16:40:49] INFO ruby 1.9.2 (2011-07-09) [i686-linux]
[2012-01-01 16:40:49] INFO WEBrick::HTTPServer#start: pid=5268 port=3000&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;copy and past the address&amp;nbsp;&lt;a href=&quot;http://0.0.0.0:3000/&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;http://0.0.0.0:3000/&lt;/a&gt;&amp;nbsp;to your browser search bar,you can see the rails home page .then you also try the following one. The Devise’s magic is comes here.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;http://0.0.0.0:3000/members/sign_up&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;http://0.0.0.0:3000/members/sign_up&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;http://0.0.0.0:3000/members/sign_in&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;http://0.0.0.0:3000/members/sign_in&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here you could see that devise has generated the sign-up and sign-in forms for you.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Here the sign-up form contains only 3 fields email,password &amp;amp; password confirmation,No we have to add the username to the sign-up form.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;run the following command to add the username field to members migration.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ rails generate migration add_username_to_members username:string&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;This command will&amp;nbsp;generate&amp;nbsp;another migration file in your “db/migrate” directory.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;And then again you have to run the “&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;db:migrate”&amp;nbsp;&lt;/strong&gt;command.Then only the field will add to the members table.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ rake db:migrate

== AddUsernameTomembers: migrating =================================
-- add_column(:members, :username, :string)
-&amp;gt; 0.3149s
== AddUsernameTomembers: migrated (0.3151s) ========================&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now you check the members table,username field will be added to it.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: Verdana, sans-serif;&quot;&gt;Creating Views :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once you have done this you have to generate the&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;Devise views,&lt;/strong&gt;then only we can edit the sign-up form and add the username field to the form.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ rails generate devise:views&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once you run this command the devise will generate the whole view files for the members.check&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;“app/views/devise” ,&lt;/strong&gt;you could see the whole form structure for sign-in,sign-up,forgot password etc.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Then edit the form for sign-up and add the username field to it.Go to&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;“app/views/devise/registration/new.html.erb”&lt;/strong&gt;&amp;nbsp;and then edit the form like given below.&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;&amp;lt;h2&amp;gt;Sign up&amp;lt;/h2&amp;gt;

&amp;lt;%= form_for(resource, :as =&amp;gt; resource_name, :url =&amp;gt; registration_path(resource_name)) do |f| %&amp;gt;

&amp;lt;%= devise_error_messages! %&amp;gt;

&amp;lt;div&amp;gt;&amp;lt;%= f.label :username %&amp;gt;&amp;lt;br /&amp;gt;
&amp;lt;%= f.text_field :username %&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;div&amp;gt;&amp;lt;%= f.label :email %&amp;gt;&amp;lt;br /&amp;gt;
&amp;lt;%= f.email_field :email %&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;div&amp;gt;&amp;lt;%= f.label :password %&amp;gt;&amp;lt;br /&amp;gt;
&amp;lt;%= f.password_field :password %&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;div&amp;gt;&amp;lt;%= f.label :password_confirmation %&amp;gt;&amp;lt;br /&amp;gt;
&amp;lt;%= f.password_field :password_confirmation %&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;div&amp;gt;&amp;lt;%= f.submit &quot;Sign up&quot; %&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;% end %&amp;gt;

&amp;lt;%= render :partial =&amp;gt; &quot;devise/shared/links&quot; %&amp;gt;&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now check the sign-up form again you can see the username field in it.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Lets create our second model&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;Contact.&lt;/strong&gt;Here we&amp;nbsp;doesn’t&amp;nbsp;use devise generator&amp;nbsp;,in contact model we need only 2 fields, phone number, address.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ rails generate model contact&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Edit the migration file of contact and specify the 2 fields as shown below.&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;class CreateContacts &amp;lt; ActiveRecord::Migration
    def up
        create_table :contacts do |t|
       
        t.string :mobile , :null =&amp;gt; false, :default =&amp;gt; “”
        t.string :address , :null =&amp;gt; false, :default =&amp;gt; “”

    end

end

    def down
        drop_table :contacts

    end
end&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;After that run&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;db:migrate&lt;/strong&gt;&amp;nbsp;command to create a table contacts in our database.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ rake db:migrate

== CreateContacts: migrating =======================================

-- create_table(:contacts)
-&amp;gt; 0.2141s
== CreateContacts: migrated (0.2142s) ==============================&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: Verdana, sans-serif;&quot;&gt;Creating Controller :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;We&amp;nbsp;haven’t&amp;nbsp;created an home page yet,so now we are going to create a controller for that.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ rails generate controller home&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;And then create a new index file for home controller like&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;“app/views/home/index.html.erb”&lt;/strong&gt;&amp;nbsp;and then add the following .&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;&amp;lt;% if member_signed_in? %&amp;gt;

&amp;lt;h3&amp;gt;you have succesfully signed in&amp;lt;/h3&amp;gt;
&amp;lt;%= link_to &quot;Sign Out&quot;, destroy_member_session_path, :method =&amp;gt; :delete %&amp;gt;

&amp;lt;% else %&amp;gt;

&amp;lt;h1&amp;gt; welcom to rails community&amp;lt;/h1&amp;gt;
&amp;lt;%= link_to &quot;Sign In&quot;, new_member_session_path, :method =&amp;gt; :get %&amp;gt;
&amp;lt;%= link_to &quot;Sign up&quot;, new_member_registration_path, :method =&amp;gt; :get %&amp;gt;

&amp;lt;% end %&amp;gt;
&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once you have done ,you have to remove the index page in public folder,and then you should have to reset the root path to&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;“home#index”&lt;/strong&gt;&amp;nbsp;page.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;app/config/routes.rb&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;add the line&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;root :to =&amp;gt;&#39;home#index&#39;&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now we have to override the devise controller ,then only we can call the objects from 2 models (contact,members),so now we are going to create a new controller called “registration”.&lt;/span&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ rails generate controller registration&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Open the controller file in “&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;app/controllers/registration_controller.rb”,&lt;/strong&gt;and then edit the file as shown below.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;Filepath :&lt;/strong&gt;&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;app/controllers/registration_controller.rb&lt;/strong&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;class RegistrationController &amp;lt; Devise::RegistrationsController

    def new

        @member= Member.new
        @contact = Contact.new

    end

    def create

        @member = Member.new
        @member.username = params[:member][:username]
        @member.email = params[:member][:email]
        @member.password = params[:member][:password]
        @member.password_confirmation =params[:member][:password_confirmation]

        @contact = Contact.new
        @contact.mobile = params[:contact][:mobile]
        @contact.address = params[:contact][:address]
        @member.valid?

        if @member.errors.blank?

            @member.save
            @contact.member = @member
            @contact.save
            redirect_to dashboard_path

        else
            render :action =&amp;gt; &quot;new&quot;
        end
    end

end&lt;/pre&gt;
&lt;br /&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Once you have done the above step,we are going to create a view for our registration controller, create file called&amp;nbsp;&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;“new.html.erb”,&lt;/strong&gt;in your&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;“app/views/registration/” directory&lt;/strong&gt;and then add the following.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Filepath : app/views/registration/new.html.erb&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;&amp;lt;h2&amp;gt;Sign up&amp;lt;/h2&amp;gt;

&amp;lt;%= form_tag(member_registration_path,:method =&amp;gt; &#39;post&#39;) %&amp;gt;
&amp;lt;%= devise_error_messages! %&amp;gt;
&amp;lt;table&amp;gt;

&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Username : &amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;%=text_field_tag &quot;member[username]&quot;,@member.username %&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;

&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Email : &amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;%=email_field_tag &quot;member[email]&quot;,@member.email %&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;

&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Password : &amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;%=password_field_tag &quot;member[password]&quot;,@member.password %&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;

&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Retype password : &amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;%=password_field_tag &quot;member[password_confirmation]&quot;,@member.password_confirmation %&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;

&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Mobile : &amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;%=text_field_tag &quot;contact[mobile]&quot; ,@contact.mobile %&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;

&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;Address : &amp;lt;/td&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;%=text_area_tag &quot;contact[address]&quot; ,@contact.address ,:rows =&amp;gt; 10, :cols =&amp;gt; 25 %&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;

&amp;lt;tr&amp;gt;
&amp;lt;td&amp;gt;&amp;lt;%= submit_tag nil, :class =&amp;gt; &quot;form_submit&quot;%&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;
&amp;lt;br /&amp;gt;
&amp;lt;%= render :partial =&amp;gt; &quot;devise/shared/links&quot; %&amp;gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;We have to mention the&amp;nbsp;relationships&amp;nbsp;between 2 models (member ,contact ).here the relationship will be as follows.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Filepath : app/models/member.rb&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;class Member &amp;lt; ActiveRecord::Base

devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable

attr_accessible :email, :password, :password_confirmation, :remember_me, :username
has_one :contact
end&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Filepath : app/models/contact.rb&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;class Contact &amp;lt; ActiveRecord::Base
   &amp;nbsp;
   belongs_to :member
end&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Now refer the registration controller file in app/controllers/registration,here after completing the registration &amp;amp; the values that the member entered is stored in the table&amp;nbsp;successfully&amp;nbsp;,i just redirected the member to the dashboard page.So we have to add that page to our home controller.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Filepath : app/views/home/dashboard.html.erb&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;pre class=&quot;brush: js&quot;&gt;&amp;lt;p&amp;gt;hi welcome to Ruby community. you have successfully registered to your rails club account&amp;lt;/p&amp;gt;
&amp;lt;%= link_to &quot;Sign out&quot;, destroy_member_session_path, :method =&amp;gt; :delete %&amp;gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;You have to specify this path in our routes.rb file&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Filepath : app/config/routes.rb&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;pre style=&quot;background-attachment: initial; background-clip: initial; background-color: #f7f7f7; background-image: initial; background-origin: initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #222222; font-size: 15px; line-height: 21px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; overflow-x: auto; overflow-y: auto; padding-bottom: 1.5em; padding-left: 1.5em; padding-right: 1.5em; padding-top: 1.5em; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;devise_for :members,:controllers =&amp;gt; { :registrations =&amp;gt;&#39;registration&#39;}
match &#39;dashboard&#39; =&amp;gt; &#39;home#dashboard&#39;&lt;/span&gt;&lt;/pre&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;strong style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; font-weight: bold; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: Verdana, sans-serif;&quot;&gt;Conclusion :&lt;/span&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;Finally &amp;nbsp;the application has almost done,so run the server and try our application in your machine whether everything working perfectly or not.This is just a skeleton of our application,we can add a lot more css to design our application to make everything looks&amp;nbsp;perfect.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I hope that this tutorial will help you to start&amp;nbsp;experiencing on&amp;nbsp;Ruby on Rails&amp;nbsp;application.If you facing any problems when you start trying out this application on your working environment,feel free to shoot your questions or suggestions. If you wants to get the fullcode of this application,please refer.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;https://github.com/sreeharikmarar/simple-application-in-rails-using-devise&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;https://github.com/sreeharikmarar/simple-application-in-rails-using-devise&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;I have also uploaded this application in Heroku.Check out the following link.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; margin-bottom: 24px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;
&lt;a href=&quot;http://railscommunity.herokuapp.com/&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #0066cc; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Verdana, sans-serif;&quot;&gt;http://railscommunity.herokuapp.com/&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;sharedaddy sd-sharing-enabled&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-left-radius: 0px 0px !important; border-bottom-right-radius: 0px 0px !important; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-left-radius: 0px 0px !important; border-top-right-radius: 0px 0px !important; border-top-width: 0px; clear: both; font-family: &#39;Helvetica Neue&#39;, Helvetica, Arial, sans-serif; font-size: 12px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline; zoom: 1;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/8375323996406188039/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2012/01/creating-simple-ruby-on-rails.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/8375323996406188039'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/8375323996406188039'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2012/01/creating-simple-ruby-on-rails.html' title='Ruby on Rails : Creating a simple Ruby on Rails application using Devise.'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-970000480125856860</id><published>2011-10-22T08:51:00.000-07:00</published><updated>2011-10-23T04:46:11.172-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AJAX"/><category scheme="http://www.blogger.com/atom/ns#" term="Exercises"/><category scheme="http://www.blogger.com/atom/ns#" term="web.py"/><title type='text'>AJAX &amp; Web.py : how to load a data from a server by using jQuery.get() method.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;We have already discussed some basic ideas about ajax and web.py in the previous post ,so now we are going to discuss some more functions that you can perform with ajax.&lt;br /&gt;
&lt;br /&gt;
The Jquery.get() method is used to perform AJAX HTTP GET request.This is an easy way to send a simple GET request to a server.It allows a single callback function to be specified,that will be executed when the request is completed.&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;&lt;i&gt;Syntax&lt;/i&gt; : &amp;nbsp;&lt;/b&gt;   &lt;b&gt;jQuery.get ( url , [data] , [callback] , [type] )&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;url &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: &amp;nbsp;&lt;/b&gt;The corresponding URL to load.&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;data &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: &amp;nbsp;&lt;/b&gt;key/value pair that will be send to the sever (*optional).&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;callback : &amp;nbsp;&lt;/b&gt;(Function) A function to be executed whenever the data is loaded successfully (*optional).&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;type &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;: &amp;nbsp;&lt;/b&gt;Type of data to be returned to callback function  &quot;xml&quot;,&quot;html&quot;,&quot;script&quot;,&quot;json&quot; etc (*optional).&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Now lets look at  the working of &lt;i&gt;JQuery.get()&lt;/i&gt; method here with the help of an example.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;Qn: &lt;/b&gt;create a web.py URL that should return a random number between 1 &amp;amp; 1000,and create another URL it should display a text box and a button,when you hit the button,random numbers should be displayed inside the text box.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
Before we are going to start You have to create a directory named static in the same folder where you are going to create this application.The HTML template will put in this directory.&lt;br /&gt;
First of all you all know that you have to map the URL&#39;s to the corresponding classes,here the root URL will map to &#39;rand_num&#39; class and the second URL (&#39;/random&#39;) will map to the &#39;return_num&#39; class.&lt;br /&gt;
&lt;br /&gt;
If we are using any HTML templates you have to define it by using the line &#39;render=web.template.render(&#39;template/&#39;),then only it can fetch the code from the template directory,that why we already created a directory called template.&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;our web.py program displayed below.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;program name : random.py&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: js&quot;&gt;import web
import random

urls = (
    &#39;/&#39;, &#39;rand_num&#39;,
    &#39;/random&#39;,&#39;return_num&#39;)

app = web.application(urls, globals(), True)
render = web.template.render(&#39;templates/&#39;)


class rand_num:
    def GET(self):
      return render.random()

class return_num:
    def GET(self):
      return  random.randint(1,1000)

if __name__ == &quot;__main__&quot;:
    app.run()
&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Then we have to define the class(&#39;/rand_num&#39;) for the root URL. the root URL should have to display a text box and a button,so that you have to call the corresponding HTML template ,here the method render.random() will returns a rendering of the HTML template  &#39;random&#39;.you have to specify the exact name of the html template that located in the templates directory here to fetch it from the directory when the code runs.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
After that we have to define the class (&#39;return_num&#39;) for the random number generation i.e when the browser get form this URL,it should return a random number between 1 - 1000 .We have a module in python called random ,by importing this module we can call random.randint() method to get random numbers between certain ranges,here we can use random.randint(1,1000) to get the random numbers between 1-1000.&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Now lets look at the html template &#39;random.html&#39; located in the templates directory.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: js&quot;&gt;&amp;lt;html&amp;gt;
        &amp;lt;head&amp;gt;
        &amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
        
        &amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
        jQuery(document).ready(function(){
        jQuery(&quot;button&quot;).click(function(){
          jQuery.get(&quot;/random&quot;,function(result){
             jQuery(&quot;#text1&quot;).val(result);
          });
        });});
        &amp;lt;/script&amp;gt;
        &amp;lt;/head&amp;gt;

        &amp;lt;body&amp;gt;

        &amp;lt;input type = &quot;text&quot; id = &quot;text1&quot; /&amp;gt;

        &amp;lt;h2&amp;gt;Hit the button to view random numbers&amp;lt;/h2&amp;gt;

        &amp;lt;button&amp;gt;Click&amp;lt;/button&amp;gt;

        &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/pre&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Here the url (&quot;/random&quot;) specified in the&lt;i&gt; jQuery.get() &lt;/i&gt;method specifies the corresponding url to load.and then the callback function specified here will execute when the data is loaded successfully.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Here when we press the button the&lt;i&gt; jQuery.get() &lt;/i&gt;method will invoke and it will load the url &quot;/random&#39;.we have already defined the &quot;return_num&quot; class for the &quot;/random&quot; url that ,it returns only a random number between 1-1000.So when the data i.e (random number) is loaded successfully,then the callback function will execute and variable name &quot;result&quot; will contain the returned value.Then finally we just displayed it inside the text box.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/970000480125856860/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/10/ajax-webpy-how-to-load-data-from-server.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/970000480125856860'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/970000480125856860'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/10/ajax-webpy-how-to-load-data-from-server.html' title='AJAX &amp; Web.py : how to load a data from a server by using jQuery.get() method.'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-803381215406480550</id><published>2011-08-07T12:33:00.000-07:00</published><updated>2011-10-21T03:46:10.917-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><title type='text'>Unix tool : make</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;The&amp;nbsp;make&amp;nbsp;utility&amp;nbsp;is a software engineering tool for managing and&amp;nbsp;maintaining&amp;nbsp;computer programs.Make &amp;nbsp;provides most help when the program consists of many component files.&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;By creating a&amp;nbsp;descriptor&amp;nbsp;file containing&amp;nbsp;dependency&amp;nbsp;rules,macros and suffix rules,you can instruct make to automatically rebuild your program whenever one of the program&#39;s component files is modified.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;To prepare to use make ,You must write a file called makefile the describes the relationships among files in your program,and the states the commands for updating each file.In a program,typically the executable file is updated from object files to&amp;nbsp;decide&amp;nbsp;which of the file needs to be updated.For each of those files,it issues the commands recorded in the data base.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;b&gt;Simple example:&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;This is an example descriptor file to build an executable file called prog1.it requires the source file file1.cc,file2.cc,and file3.cc.An include file mydefs.h,is required by files file1.cc and file2.cc.If you wanted to compile this file from the command line using C++ the command would be&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;% &amp;nbsp;CC -o prog1 file1.cc file2.cc file3.cc&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This command line is rather long to be entered many times as a program is developed and is prone to typing errors. A descriptor file could run the same command better by using the simple command&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;% make  prog1&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/ul&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;or if prog1 is the first target defined in the descriptor file&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;% make&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/ul&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;No we are going to see how to write a descriptor file,this example descriptor file is much longer than the&amp;nbsp;necessary but it is useful for describing what is gong on.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;pre class=&quot;brush: js&quot;&gt;prog1 : file1.o file2.o file3.o
        CC -o prog1 file1.o file2.o file3.o
  
file1.o : file1.cc mydefs.h
        CC -c file1.cc
  
file2.o : file2.cc mydefs.h
        CC -c file2.cc
  
file3.o : file3.cc
        CC -c file3.cc
  
clean :
        rm file1.o file2.o file3.o
 
&lt;/pre&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Let&#39;s go through the example to see what&amp;nbsp;make&amp;nbsp;does by executing with the command&amp;nbsp;make prog1&amp;nbsp;and assuming the program has never been compiled.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;ol&gt;&lt;li&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Make  finds the target&amp;nbsp;prog1&amp;nbsp;and sees that it depends on the  object files&amp;nbsp;file1.o file2.o file3.o&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;
&lt;li&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;make  next looks to see if any of the three object files are listed as  targets. They are so make looks at each target to see what it  depends on.&amp;nbsp;make&amp;nbsp;sees that&amp;nbsp;file1.o&amp;nbsp;depends on  the files file1.cc&amp;nbsp;andmydefs.h.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Now&amp;nbsp;make&amp;nbsp;looks  to see if either of these files are listed as targets and since they  aren&#39;t it executes the commands given in&amp;nbsp;file1.o&#39;s rule and  compiles&amp;nbsp;file1.cc&amp;nbsp;to get the object file.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;make&amp;nbsp;looks  at the targets&amp;nbsp;file2.o&amp;nbsp;and&amp;nbsp;file3.o&amp;nbsp;and compiles  these object files in a similar fashion.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;make&amp;nbsp;now  has all the object files required to make&amp;nbsp;prog1&amp;nbsp;and does  so by executing the commands in its rule.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ol&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/803381215406480550/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/08/unix-tool-make.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/803381215406480550'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/803381215406480550'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/08/unix-tool-make.html' title='Unix tool : make'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-7829915696751010047</id><published>2011-08-07T08:55:00.000-07:00</published><updated>2011-10-21T03:50:48.546-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><title type='text'>Unix tool : AWK</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;What is AWK?&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;AWK is a programming language designed for processing text-based data, either in files or data streams. It is an example of a programming language that extensively uses the string datatype, associative arrays , and regular expressions.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;There are three variations of AWK:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;AWK - the original from AT&amp;amp;T&lt;br /&gt;
NAWK - A newer, improved version from AT&amp;amp;T&lt;br /&gt;
GAWK - The Free Software foundation&#39;s version&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;AWK is an excellent filter and report writer.AWK also has string manipulation functions, so it can search for particular strings and modify the output.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;The essential organization of an AWK program follows the form:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;i&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;pattern&amp;nbsp;{ action }&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/i&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;The pattern specifies when the action is performed.i.e&amp;nbsp;the pattern specifies a test that is performed with each line read as input. If the condition is true, then the action is taken.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Lets look some examples,First of all create a file named &quot;file1.txt&quot;, and write somthing like &quot;unix tool awk &quot; in the body and then save,then type the following command in terminal&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;$awk &#39;{print $1}&#39; file1.txt&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;/span&gt; &lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
The output will be&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &#39;unix&#39;, &lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;i.e it will print the first word in the body of the file.&lt;/span&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Two other important patterns can be specified by the keywords &quot;BEGIN&quot; and &quot;END.&quot;,these two words specify actions to be taken before any lines are read.and after the last line is read.THe AWK program below:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;nbsp;BEGIN &amp;nbsp;( print &quot;START&quot; )&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ( print &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&amp;nbsp;END &amp;nbsp; &amp;nbsp; &amp;nbsp; ( print &quot;STOP&quot; &amp;nbsp; &amp;nbsp;)&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;We can make this into a typical AWK program :&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Firt of create two files like &quot;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;sample1.txt&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&quot;with body &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&quot; sam 15 groupA&quot;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &amp;amp; &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&quot;sample2.txt&quot;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; with body &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&quot;neil 13 groupB&quot;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; ,then write our AWK program as described below and save the file&amp;nbsp;with extention (.awk)&amp;nbsp;in the same directory that your sample file resides &amp;nbsp;,Here my awk program will be &quot;file1.awk&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;nbsp;AWK is also an interpreter,Here we making the file executable by adding the first line in the&amp;nbsp;beginning&amp;nbsp;of the file i.e (&quot; #!/bin/awk &amp;nbsp;-f &quot;).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;programe name : file1.awk&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: normal;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: js&quot;&gt;
#!/bin/awk -f

  BEGIN { print &quot;Name\tAge\tGroup&quot; }

  { print $1, &quot;\t&quot; ,$2, &quot;\t&quot; ,$3 }

  END { print &quot; - DONE -&quot; }

&lt;/pre&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Then change the permission with the &lt;/span&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;chmod &lt;/span&gt;&lt;/i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;nbsp;command (i.e &lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&quot;chmod +x file1.awk&quot;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; ),and then the script becomes a new command.Here the &lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&quot;-f&quot;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; option following &quot;#!/bin/awk&quot; &amp;nbsp;make the file execute directly i.e &quot; awk -f file1.awk&quot;.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; &lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Then run the file by typing &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&quot;$&amp;nbsp;awk -f file1.awk sample1.txt sample2.txt&quot;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; in your terminal.then you will get the following output.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: js&quot;&gt;sreehari@~/sed awk make/awk09:54:02$ $awk -f file1.awk sample1.txt sample2.txt

    Name &amp;nbsp; &amp;nbsp; Age &amp;nbsp; Group

    sam &amp;nbsp; &amp;nbsp; &amp;nbsp;15 &amp;nbsp; &amp;nbsp;groupA

    neil &amp;nbsp; &amp;nbsp; 13 &amp;nbsp; &amp;nbsp;groupB

    - DONE -

&lt;/pre&gt;&lt;div style=&quot;margin-bottom: 0cm; margin-left: 0px; margin-right: 0px; margin-top: 0px; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;This is just a brief introduction to on AWK,You can find more about AWK by using the following document. &lt;/span&gt;&lt;a href=&quot;http://www.grymoire.com/Unix/Awk.html&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;AwK-Tutorial&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/7829915696751010047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/08/unix-tool-awk.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/7829915696751010047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/7829915696751010047'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/08/unix-tool-awk.html' title='Unix tool : AWK'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-2606787174107846858</id><published>2011-08-07T08:52:00.000-07:00</published><updated>2011-08-07T10:29:21.932-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><title type='text'>Unix tool : Sed</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div&gt;&lt;br /&gt;
&lt;div&gt;&lt;b&gt;What is Sed?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This post will help you to get the answer of the above question,The same question persuaded me to understand the concept and also to write this post about what i have learned about Sed.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;sed(stream editor)&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;is a tool which allows you to perform large-scale, noninteractive editing tasks. For example,&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;sed&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;can replace all the occurrences of a given word in a file with a different word, or delete all lines containing a target string from a file.&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Sed&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;is particularly used when working with large files .&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;u&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Substitution command &amp;nbsp;S:&lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Sed has several commands,but the essential command i.e used by most is substitute command :&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;S&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;The substitute command changes all occurrences of the regular expression into a new value.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;To try this command , create a file named &quot;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;file1.txt&quot;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;and write something like&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&quot;sed is fun&quot;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;in the body of that file,then run the following command in terminal.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;$sed s/fun/cool/ &amp;lt;file1.txt &amp;gt;file2.txt&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;After you run the command you can see a new file created in the same directory with a name file2.txt , when you open the file you can see that the text is changed to &quot;sed is cool&quot;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;.&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;here the command will substitute the content &quot;fun&quot; in the old file (file1.txt) to &quot;cool&quot; in the new file (file2.txt).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Try the following command those who want to test the working in terminal.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;$echo fun | sed s/fun/cool/&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This will output as&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&quot;cool&quot;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;in termina&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;l.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;$echo sed is fun | sed &#39;s/fun/cool/&#39;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This will output as&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&quot;sed is cool&quot;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;in terminal.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;There are four parts to this substitute command:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;s &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Substitute command.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;/ . . / . . / &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Delimiter.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;fun &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Regular Expression Pattern Search Pattern&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;cool &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Replacement string.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;The search pattern is on the left hand side and the replacement string is on the right hand side.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;u&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Using &quot;&amp;amp;&quot;as the matched string :&lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;B&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;y using the &quot;&amp;amp;&quot; symbol you can match the patterns as you like,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;$echo sed is fun | sed &#39;s/[a-z][a-z][a-z]/(&amp;amp;)/&#39;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This will ouput as&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&quot;&amp;nbsp;(sed) is fun &quot;,&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;[a-z] matches single letter ,here 3 [a-z] will match 3 letters like(sed).&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;You can have any number of &amp;nbsp;&quot;&amp;amp;&quot; &amp;nbsp;in the replacement string,like&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;$echo sed is fun | sed &#39;s/[a-z][a-z][a-z]/(&amp;amp;&amp;amp;)/&#39;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This will output as&lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&quot;(sedsed) is fun&quot;.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;If you want to match the entire string then you have to make changes like,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;$echo sed is fun | sed &#39;s/[a-z]* [a-z]* [a-z]*/(&amp;amp;)/&#39;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;It will output as&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&quot;&amp;nbsp;(sed is fun)&quot;.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;If you want to display the matched string 3 times then try,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;$echo sed is fun | sed &#39;s/[a-z]* [a-z]* [a-z]*/(&amp;amp;)(&amp;amp;)(&amp;amp;)/&#39;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;The output will be&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&quot;(sed is fun)(sed is fun)(sed is fun)&quot;.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;If&amp;nbsp;&lt;/span&gt;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;we have a text file like &quot;sed is fun 123&quot;,then you should change the code like this to get the whole text inside the bracket.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;$echo &quot;sed is fun 123&quot; | sed &#39;s/[a-z]* [a-z]* [a-z]* [0-9]*/(&amp;amp;)/&#39;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Then the output will be&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&quot;(sed is fun 123)&quot;.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;u&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Using \1 to keep part of the pattern:-&lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;If you want to remove the numbers from the above example,then you should try like,&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;$echo sed is fun 123 | sed &#39;s/\([a-z]* [a-z]* [a-z]*\).*/\1/&#39;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;It will remove the numbers and the output will be&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&quot;sed is fun&quot;.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;If you want to switch the words around, you can remember the patterns and change the order around:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;$echo sed is fun 123 | sed &#39;s/\([a-z]*\) \([a-z]*\) \([a-z]*\).*/\3 \2 \1/&#39;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;The output will be&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&quot;fun is sed&quot;.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;u&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Substitute flags:&lt;/span&gt;&lt;/b&gt;&lt;/u&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;You can add additional flags after the last delimiter. These flags can specify what happens when there is more than one occurrence of a pattern on a single line, and what to do if a substitution is found.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;$sed &#39;s/[^ ]*/(&amp;amp;)/&#39; &amp;lt;file1.txt&amp;gt;file2.txt&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This will put parenthesis around the first word, i.e the first word in the body of your second file have a parenthesis around it.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;If you want it to make change of &amp;nbsp;every word&amp;nbsp;add a &quot;g&quot; after the last delimiter and use the work-around:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;$sed &#39;s/[^ ]*/(&amp;amp;)/g&#39; &amp;lt;file1.txt&amp;gt;file2.txt&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;The output will be&amp;nbsp;&lt;/span&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&quot;(sed) (is) (fun)&quot;.&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; font-weight: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span style=&quot;color: black;&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;These are some basic commands ,there are several other commands that can be used with Sed.&lt;/div&gt;&lt;div align=&quot;LEFT&quot; style=&quot;margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/2606787174107846858/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/08/unix-tool-sed.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/2606787174107846858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/2606787174107846858'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/08/unix-tool-sed.html' title='Unix tool : Sed'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-4056503139621363178</id><published>2011-07-26T11:53:00.000-07:00</published><updated>2011-10-21T04:38:38.177-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="AJAX"/><category scheme="http://www.blogger.com/atom/ns#" term="Exercises"/><category scheme="http://www.blogger.com/atom/ns#" term="web.py"/><title type='text'>AJAX &amp; web.py : some quick reference</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;This post will give you some basic ideas about how to use AJAX with web.py.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;You all know that web.py is a simple web framework for python,the main thing i liked about web.py is that it is very simple to use and more effective too.web.py frame work can run its own basic web server .&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;About AJAX(Asynchronous Java script and XML) you all know that it is very helpful to create interactive web applications.With&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Ajax, web applications can send data to, and retrieve data from, a server&amp;nbsp;asynchronously , i.e you can updates the parts of web page without reloading the whole page.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;So here i would like to&amp;nbsp;describe&amp;nbsp;some examples that we can experiment with AJAX &amp;amp; web.py.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px;&quot;&gt;The Ajax application that we are going to discuss here contain one &quot;div&quot; section and a button. The &quot;div&quot; section will be used to display the contents return form the server.&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: js&quot;&gt;&amp;lt;html&amp;gt;
&amp;lt;body&amp;gt;
          
&amp;lt;div&amp;gt;&amp;lt;h2&amp;gt;Let AJAX change this text&amp;lt;/h2&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;button&amp;gt;Change Content&amp;lt;/button&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/pre&gt;&lt;br /&gt;
&lt;div&gt;&lt;div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;With jQuery AJAX, you can request TXT, HTML, XML or JSON data from a remote server using both HTTP Get and HTTP Post.And you can load remote data directly into selected HTML elements of your web page!&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Next, add a &amp;lt;script&amp;gt; tag to the page&#39;s head section. The script section contains&amp;nbsp;the AJAX load function.&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Th&lt;/span&gt;e jQuery load() method is a simple AJAX function. It has the following syntax:&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;&lt;i&gt;$(selector).load(url,&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;data,callback&lt;/b&gt;&lt;/span&gt;&lt;/i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;&lt;i&gt;)&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Next we are adding the &amp;lt;script&amp;gt; tag &amp;nbsp;under &amp;lt;head&amp;gt; section,This section contains jQuery load method.&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;pre class=&quot;brush: js&quot;&gt;&amp;lt;head&amp;gt;
      &amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery 1.4.2.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
      &amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
      $(document).ready(function(){
        $(&quot;button&quot;).click(function(){
           $(&quot;div&quot;).load(&quot;http://127.0.0.1:8080/static/test.txt&quot;);    
        });
      });
      &amp;lt;/script&amp;gt;
 &amp;lt;/head&amp;gt;

&lt;/pre&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
Here the &amp;nbsp;load function will load desired contents from the specified URL.(What this URL actually functions is described in the below section,you will get exact picture after you read the whole thing)&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Next we are going to implement this code with web.py.&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
Before we move on to web.py,We have to create a folder named &quot;static&quot; in the same folder that your&amp;nbsp;program&amp;nbsp;resides,and put your text file (here the file is &quot;test.txt&quot; ) inside the &quot;static&quot; folder.Then check that you are able to access the file by typing the URL (&quot;&amp;nbsp;&lt;a href=&quot;http://127.0.0.1:8080/static/test.txt&quot;&gt;http://127.0.0.1:8080/static/test.txt&lt;/a&gt;&amp;nbsp;&quot;) in your browser search bar.If the browser&amp;nbsp;displays&amp;nbsp;the contents properly then you can implement this on aJax load function.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The whole program&amp;nbsp;described&amp;nbsp;below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Program&amp;nbsp;name -- Code.py&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;pre class=&quot;brush: js&quot;&gt;import web

  urls = (
    &#39;/&#39;, &#39;main&#39;)


  app = web.application(urls, globals(),True)


  class main:
      def GET(self):
          return&#39;&#39;&#39;
          &amp;lt;html&amp;gt;
          &amp;lt;head&amp;gt;
          &amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
          &amp;lt;script type=&quot;text/javascript&quot;&amp;gt;
          $(document).ready(function(){
            $(&quot;button&quot;).click(function(){
              $(&quot;div&quot;).load(&quot;http://127.0.0.1:8080/static/test.txt&quot;);
            });
          });

          &amp;lt;/script&amp;gt;
          &amp;lt;/head&amp;gt;
          &amp;lt;body&amp;gt;
            
          &amp;lt;div&amp;gt;&amp;lt;h2&amp;gt;Let AJAX change this text&amp;lt;/h2&amp;gt;&amp;lt;/div&amp;gt;
          &amp;lt;button&amp;gt;Change Content&amp;lt;/button&amp;gt;

          &amp;lt;/body&amp;gt;
          &amp;lt;/html&amp;gt;&#39;&#39;&#39;


  if __name__ == &quot;__main__&quot;:
      app.run()
&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How to run the program:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Web.py comes with a built-in web server that you all know. We have created our program file called &amp;nbsp;&quot; code.py &quot;,just save the file and &amp;nbsp;run the &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;following command in terminal to start your application.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre style=&quot;background-color: #f3f3f3;&quot;&gt;sreehari@sreehari-desktop:~/web.py$ python code.py
  http://0.0.0.0:8080/

&lt;/pre&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Then goto your browser and type &quot;&amp;nbsp;&lt;a href=&quot;http://127.0.0.1:8080/&quot;&gt;http://127.0.0.1:8080/&lt;/a&gt;&amp;nbsp;&quot; in your search bar , you will get a web page with a text &quot; Let AJAX change this text &quot; and it also contains a button,when you hit the button the text will change and new text from the text file will be loaded and displayed in your browser.&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/4056503139621363178/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/07/ajax-webpy-some-quick-reference.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/4056503139621363178'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/4056503139621363178'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/07/ajax-webpy-some-quick-reference.html' title='AJAX &amp; web.py : some quick reference'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-411188171460819898</id><published>2011-07-18T04:26:00.000-07:00</published><updated>2011-10-21T04:55:12.979-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Exercises"/><title type='text'>A simple exercise in web.py</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&amp;nbsp;This is just a simple exercise that will help you to understand the basics of web.py.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Qn:&lt;/b&gt; Create a webpage that should contain a text box,so that you can input your names,the page should also provide a submit button to submit the details that you entered in a text box.when you submit it the names should be saved in a text file and whole the names that we&amp;nbsp;entered&amp;nbsp;should be&amp;nbsp;displayed&amp;nbsp;in another&amp;nbsp;URL.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1st step:&lt;/b&gt; Import the module Web.py,to use the tools provided by web.py. Map the first URL (&quot; / &quot;) to a class named &quot;main&quot;.and map the second URL (&quot;/Details&quot;) to a class named &amp;nbsp;&quot;details&quot;.&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: normal;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre class=&quot;brush: js&quot;&gt;import web

  urls = (
  &amp;nbsp;&amp;nbsp;&#39;/&#39;,&#39;main&#39;,
  &amp;nbsp;&amp;nbsp;&#39;/Details&#39;,&#39;details&#39;)

  app = web.application(urls, globals(), True)

&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;2nd step:&lt;/b&gt; Next we&amp;nbsp;have to define the class named &quot;main&quot;.The function GET() is actually displays the content in your browser when you opens a webpage.When you opens the first page it should displays a form,so thats why ,we are writing the HTML code to create a form under GET() function.Here we are specifying the method&amp;nbsp;attribute&amp;nbsp;of form as POST to&amp;nbsp;invoke the POST request&amp;nbsp;.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: js&quot;&gt;class main:
    def GET(self):
    return&#39;&#39;&#39;
    &amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;web.py&amp;lt;/title&amp;gt;
    &amp;lt;/head&amp;gt;

    &amp;lt;body&amp;gt;

    &amp;lt;h1&amp;gt;A simple exercise in web.py&amp;lt;/h1&amp;gt;

    &amp;lt;form name=&quot;form&quot; method = &quot;POST&quot;&amp;gt;

    Name: &amp;lt;input type=&quot;text&quot; name=&quot;user&quot;/&amp;gt;

    &amp;lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&amp;gt;

    &amp;lt;/form&amp;gt;
    &amp;lt;/body&amp;gt;
    &amp;lt;/html&amp;gt;&#39;&#39;&#39;

&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3rd step:&lt;/b&gt;&amp;nbsp;The GET() function that we&amp;nbsp;introduced above will only serve the pages&amp;nbsp;,but here we have to update the values to another webpage.Thats why we are using a POST function.The line &quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;form = web.input()&quot; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;creates a storage objects that&amp;nbsp;contains&amp;nbsp;all &amp;nbsp;variables passed into it.Then we open a file named &quot;file.txt&quot; in append mode,then write the input values &amp;nbsp;into the file by using &quot; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;f.write(form.user)&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt; &quot;. Then&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;Web.redirect(&#39;/Details&#39;) &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;will redirect the user to a new URL(&quot; /Details &quot;) ,i.e when we submit the form it will guide you to the next page that contain all the details that you entered before.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: js&quot;&gt;def POST(self):

   form = &amp;nbsp;web.input()
   f=open(&quot;file.txt&quot;,&#39;a&#39;)
   f.write(form.user)
   f.write(&quot;\n&quot;)
   f.close()

   raise web.redirect(&#39;/Details&#39;)
&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;4th step:&lt;/b&gt; We have to define the class for the URL(&quot;/Define&quot;).Here we are using GET() function to display the contents.so to displays the contents in the text file we just simply opens the file in read mode.and then read the values by using &quot;f.read()&quot; function and then assigned it to a variable named data,when we return the variable it will displays all the values that we read from the text file in the next URL.&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: js&quot;&gt;class details:

  def GET(self):

    f=open(&quot;file.txt&quot;,&#39;r&#39;)
    data=f.read()
    return data
    f.close()

&lt;/pre&gt;&lt;br /&gt;
&lt;b&gt;Complete code:&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
Program name: Code.py&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush: js&quot;&gt;import web

urls = (
&amp;nbsp;&amp;nbsp;&#39;/&#39;,&#39;main&#39;,
&amp;nbsp;&amp;nbsp;&#39;/Details&#39;,&#39;details&#39;)

app = web.application(urls, globals(), True)

class main:
   def GET(self):
    return&#39;&#39;&#39;
    &amp;lt;html&amp;gt;
    &amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;web.py&amp;lt;/title&amp;gt;
    &amp;lt;/head&amp;gt;

    &amp;lt;body&amp;gt;

    &amp;lt;h1&amp;gt;A simple exercise in web.py&amp;lt;/h1&amp;gt;

    &amp;lt;form name=&quot;form&quot; method = &quot;POST&quot;&amp;gt;

    Name: &amp;lt;input type=&quot;text&quot; name=&quot;user&quot;/&amp;gt;

    &amp;lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&amp;gt;

    &amp;lt;/form&amp;gt;
    &amp;lt;/body&amp;gt;
    &amp;lt;/html&amp;gt;&#39;&#39;&#39;

    def POST(self):
 
      form =  web.input()
      f=open(&quot;file.txt&quot;,&#39;a&#39;)
      f.write(form.user)
      f.write(&quot;\n&quot;)
      f.close()

    
      raise web.redirect(&#39;/Details&#39;)
    
class details:
    
    def GET(self):

      f=open(&quot;file.txt&quot;,&#39;r&#39;)
      data=f.read()
      return data
      f.close()

if __name__ == &quot;__main__&quot;:
    app.run()

&lt;/pre&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/411188171460819898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/07/simple-exercise-in-webpy.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/411188171460819898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/411188171460819898'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/07/simple-exercise-in-webpy.html' title='A simple exercise in web.py'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-5870279505668588942</id><published>2011-07-10T13:14:00.000-07:00</published><updated>2011-07-26T12:02:23.066-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="web.py"/><title type='text'>Web.py :  Installation and working</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;span style=&quot;color: black; font-size: 13.5pt;&quot;&gt;Web.py is a simple web frame work that is written in python for the&amp;nbsp;development of python related web applications.The main feature about web .py is that it is very simple and&amp;nbsp;efficient compared to others&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-size: 13.5pt;&quot;&gt;Installation:-&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;ul type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black; line-height: normal; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;&quot;&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;Download web.py from the below link.Then extract and      copy it into to any directory that your application resides or make it      accessible to all applications.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;span style=&quot;color: black; font-size: 13.5pt;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Courier; font-size: 13.5pt;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;a href=&quot;http://webpy.org/static/web.py-0.36.tar.gz&quot;&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;http://webpy.org/static/web.py-0.36.tar.gz&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black; line-height: normal; mso-list: l2 level1 lfo2; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;&quot;&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;Type &quot;cd&quot; in Terminal to &quot;change the      directory &quot;where you copied web.py, If you list the contents you&amp;nbsp; can see a &lt;/span&gt;&lt;span style=&quot;color: #0b5394; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;setup.py&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt; file      inside it. To install the file type the below command.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0b5394; font-family: Courier; font-size: 13.5pt;&quot;&gt;python setup.py install.&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul type=&quot;disc&quot;&gt;&lt;li class=&quot;MsoNormal&quot; style=&quot;color: black; line-height: normal; mso-list: l1 level1 lfo3; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .5in;&quot;&gt;&lt;span style=&quot;font-size: 13.5pt;&quot;&gt;when you found      any permission denied messages when installing in unix like systems,switch      to root user and then try the below command.&lt;/span&gt;&lt;span style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;color: #0b5394; font-family: Courier; font-size: 13.5pt;&quot;&gt;sudo python setup.py install&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in; mso-line-height-alt: 10.95pt;&quot;&gt;&lt;span style=&quot;color: #0b5394; font-family: Courier; font-size: 13.5pt;&quot;&gt;&lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;b&gt;&lt;span style=&quot;color: black; font-size: 13.5pt;&quot;&gt;Working:-&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in; mso-line-height-alt: 10.95pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 13.5pt;&quot;&gt;&lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;span style=&quot;color: black; font-size: 13.5pt;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; when you installed it properly you can try it by creating some simple webpages.Open any of your favorite&amp;nbsp; editor and&amp;nbsp; creating a file named &lt;/span&gt;&lt;span style=&quot;color: #0b5394; font-size: 13.5pt;&quot;&gt;&quot;hello.py&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 13.5pt;&quot;&gt;&quot; as shown below.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;, serif; font-size: medium;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background: #F9F9F9; border: solid #DDDDDD 1.0pt; mso-border-alt: solid #DDDDDD .5pt; mso-element: para-border-div; padding: 6.0pt 14.0pt 6.0pt 14.0pt;&quot;&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-line-height-alt: 10.95pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;color: #272727;&quot;&gt;import web&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;color: #272727;&quot;&gt;urls = (&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;color: #272727;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;color: #272727;&quot;&gt;&amp;nbsp; &#39;/&#39;, &#39;hello&#39;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;color: #272727;&quot;&gt;app = web.application(urls, globals())&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;color: #272727;&quot;&gt;class hello:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;color: #272727;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;color: #272727;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; def GET(self):&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;color: #272727;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;color: #272727;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return &#39;Hello, web!&#39;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;color: #272727;&quot;&gt;if __name__ == &quot;__main__&quot;:&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;color: #272727;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;background: #F9F9F9; border: none; line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in; mso-border-alt: solid #DDDDDD .5pt; mso-padding-alt: 6.0pt 14.0pt 6.0pt 14.0pt; padding: 0in; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt;&quot;&gt;&lt;span style=&quot;color: #272727;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; app.run()&lt;/span&gt;&lt;span style=&quot;color: #272727; font-family: &#39;Courier New&#39;;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: 10.95pt; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in; mso-line-height-alt: 10.95pt;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;span style=&quot;color: #272727; font-size: 13.5pt;&quot;&gt;Here&amp;nbsp; first you need to import the module web.py to use the tools provided by web.py i.e the first line actually refers.&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in; mso-line-height-alt: 10.95pt;&quot;&gt;&lt;span style=&quot;color: #272727; font-size: 13.5pt;&quot;&gt;&lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;span style=&quot;color: #272727; font-size: 13.5pt;&quot;&gt;In the second line we are actually mapping the web address(URL) i.e &quot;&lt;/span&gt;&lt;span style=&quot;color: black; font-size: 13.5pt;&quot;&gt;http://webpy.org/&quot;&lt;/span&gt;&lt;span style=&quot;color: #272727; font-size: 13.5pt;&quot;&gt; to a python class&amp;nbsp;&amp;nbsp;&amp;nbsp; named &quot;hello&quot;.&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in; mso-line-height-alt: 10.95pt;&quot;&gt;&lt;span style=&quot;color: #272727; font-size: 13.5pt;&quot;&gt;&lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;span style=&quot;color: #272727; font-size: 13.5pt;&quot;&gt;Inside the class you can see a function named&amp;nbsp; &quot;GET()&quot;.This&amp;nbsp; function &quot;GET()&quot; is actually displays the content&amp;nbsp; in your browser when your browser opens a web page.Here it will display the string &quot;Hello,web&quot; .&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in; mso-line-height-alt: 10.95pt;&quot;&gt;&lt;span style=&quot;color: #0b5394; font-family: Courier; font-size: 13.5pt;&quot;&gt;&lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;span style=&quot;color: black; font-size: 13.5pt;&quot;&gt;In the third line we are creating an instance .It will handle the all duties like handling the browser request and&amp;nbsp;&amp;nbsp; serving the desired pages.&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in; mso-line-height-alt: 10.95pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 13.5pt;&quot;&gt;&lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;The last line will start the web application to handle your requests.&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in; mso-line-height-alt: 10.95pt;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;Save the above file and run by using the command &lt;/span&gt;&lt;span style=&quot;color: #0b5394; font-family: Courier; font-size: 13.5pt;&quot;&gt;python hello.py.&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;margin-bottom: .0001pt; margin-bottom: 0in; mso-line-height-alt: 10.95pt;&quot;&gt;&lt;span style=&quot;color: black; font-size: 13.5pt;&quot;&gt;&lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;br style=&quot;mso-special-character: line-break;&quot; /&gt; &lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot; style=&quot;line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;&quot;&gt;&lt;span style=&quot;color: black; font-size: 13.5pt;&quot;&gt;when you run the file,the output will be the address of your website ,by default it is (&lt;/span&gt;&lt;span style=&quot;color: #0b5394; font-size: 13.5pt;&quot;&gt;http://localhost:8080/).&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: black; font-size: 13.5pt;&quot;&gt;when you copy it and paste it in your browser search bar you will get the resultant web page.&lt;/span&gt;&lt;span style=&quot;color: black; font-family: &#39;Times New Roman&#39;, serif; font-size: 13.5pt;&quot;&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;MsoNormal&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;line-height: 19px; white-space: pre;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: arial, helvetica, clean, sans-serif; font-size: 13px; white-space: normal;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/5870279505668588942/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/07/webpy-installation-and-working.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/5870279505668588942'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/5870279505668588942'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/07/webpy-installation-and-working.html' title='Web.py :  Installation and working'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-5972408833936365702</id><published>2011-06-28T09:27:00.000-07:00</published><updated>2011-06-28T11:26:04.549-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Python : Interesting String &amp; List</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Here i would like to share some interesting&amp;nbsp;behavior&amp;nbsp;of String &amp;amp; List when you use python interpreter.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;String:-&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;We all know that the fundamental thing about Python Strings is that they are &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&quot;Immutable&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; ,once you created a string you&amp;nbsp;couldn&#39;t change it.&amp;nbsp;See some examples....&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s = &#39;fun with string&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;fun with string&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;you can just add another string by using &amp;nbsp;&#39;+&#39; &amp;nbsp;as shown below...&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s + &#39;!!!!&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;fun with string!!!!&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Another important feature is String Slices. Just see how &quot;slice&quot; syntax behaves in python.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s = &#39;fun with string&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s[0] &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;f&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s[1:4]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;un &#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s[1:]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;un with string&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s[:]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;fun with string&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s[-1]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;g&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s[-4]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;r&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s[:-3]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;fun with str&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s[-3:]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;ing&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;So now we have a string &#39;s&#39; and we can apply all the methods (i.e functions) that are related to string to &#39;s&#39; as shown below...&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black; font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s.upper()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;FUN WITH STRING&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s.lower()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;fun with string&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s.startswith(&#39;fun&#39;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;True&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s.endswith(&#39;string&#39;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;True&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s.replace(&#39;string&#39;,&#39;python&#39;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;fun with python&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;But my favorite is the method called &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39; s.split() &#39;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;. Just see what happens if i&amp;nbsp;assigned &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;s.split()&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; function in to a variable &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;s&#39;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt; itself. If we print it you can see a list of elements.It just transformed into a list.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s = s.split()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;[&#39;fun&#39;, &#39;with&#39;, &#39;string&#39;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;List:-&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;So now the variable &#39;s&#39; will behave like &amp;nbsp;a list.Now you can apply all the methods related to list here with &#39;s&#39;.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s.append(&#39;&amp;amp; list&#39;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;[&#39;fun&#39;, &#39;with&#39;, &#39;string&#39;, &#39;&amp;amp; list&#39;]&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s.insert(0,&#39;some&#39;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;[&#39;some&#39;, &#39;fun&#39;, &#39;with&#39;, &#39;string&#39;, &#39;&amp;amp; list&#39;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s.index(&#39;some&#39;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;0&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s.index(&#39;string&#39;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s.sort()&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;[&#39;&amp;amp; list&#39;, &#39;fun&#39;, &#39;some&#39;, &#39;string&#39;, &#39;with&#39;]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s.pop(0)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;&amp;amp; list&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;See what&amp;nbsp;happens if i call the function &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;join() &quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;,and&amp;nbsp;assigned&amp;nbsp;it to same variable &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&#39;s&#39;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;.When you print &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black;&quot;&gt;&#39;s&#39;&lt;/span&gt; you could see the first string.Is it interesting?&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s = [&#39;fun&#39;, &#39;with&#39;, &#39;string&#39;, &#39;&amp;amp; list&#39;]&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s = &#39; &#39;.join(s)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace; font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt;&amp;gt;&amp;gt;&amp;gt; s&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt;&#39;fun with string &amp;amp; list&#39;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: purple;&quot;&gt;&amp;gt;&amp;gt;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Thank You.... &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/5972408833936365702/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/06/python-interesting-string-list.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/5972408833936365702'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/5972408833936365702'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/06/python-interesting-string-list.html' title='Python : Interesting String &amp; List'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-3770707986249996195</id><published>2011-06-24T22:33:00.000-07:00</published><updated>2020-05-26T02:29:44.867-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="General"/><category scheme="http://www.blogger.com/atom/ns#" term="Linux"/><title type='text'>Unix to Linux story</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;The story has begun from the well known &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;AT&amp;amp;T’s Bell Laboratories&lt;/span&gt; in the early 1960 ’s.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;At that time AT&amp;amp;T needed an operating system for their computer center because they were running various batch jobs .The BESYS &amp;nbsp;operating system was created for at Bell Labs to deal with these needs. so at the year of 1965 Bell Labs was adopting third generation computer equipment and decided to join with General Electric and MIT to create a Multics (Multiplexed information and Computer service).But at the year of 1969 they made a change that ,to withdraw from Multics and go with GECOS.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;When Multics was withdrawn &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Ken Thompson&lt;/span&gt; and &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Dennis Ritchie&lt;/span&gt; needed to rewrite the operating system, And finally they made a system called &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;UNICS (UNiplexed Information and Computing Service)&lt;/span&gt; ,&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;The UNIX operating system was first developed in Assembly language but , by the year of 1973 it had been almost entirely recoded in C. The first edition of the UNIX Programmers Manual includes over 60 commands like : b , boot , cat , chdir , chmod , cp , ls , mv etc.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Second edition of UNIX was released in 1972.But now you all know that it has been split in to various branches developed by AT&amp;amp;T for various commercial purposes.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;AT&amp;amp;T made UNIX available to Universities and commercial firms as well as the United States government, under licenses. The licenses include all source code including the machine dependent parts of the kernel. The copies of the UNIX kernel sources circulated widely in late 1970s&amp;nbsp; in the form of much copied Book by &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;John lions&lt;/span&gt; of the &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;University of new south Wales&lt;/span&gt;. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Intel&lt;/span&gt; created the first commercially available microprocessor (Intel 4004) in 1971, and one of the first microcomputers in 1972.They emerged from versions to versions like 80386.80486,80586 etc. Pentium i.e Intel 80586 was introduced in 1993.They mainly focused on making it useful for the ordinary people. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;nbsp;At the year of 1975 the software is emerged as an independent entity. Companies like &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;HP&lt;/span&gt; and &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;SUN &lt;/span&gt;started to using UNIX as an operating system for their machines. &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;HP-UX 1.0&lt;/span&gt; is released in 1980.SUN unveils &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Solaris 2&lt;/span&gt; Operating system, specially tuned for symmetric multiprogramming at the year of 1991&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;AT&amp;amp;T Licensed UNIX system III , and continued to issue license for the older versions . So to end the confusion between all its versions , AT&amp;amp;T combined them into&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt; UNIX System V&lt;/span&gt; release 1.This introduced a few features like vi editor and courses from the &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Berkeley Software Distribution&lt;/span&gt; of Unix developed at the University of California, Berkeley&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;This move of AT&amp;amp;T , that to commercialize UNIX system v .actually killed UNIX. The &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Free Software Foundation (FSF)&lt;/span&gt; was founded the same year by &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Richard Stallman.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Richard Stallman’s contribution&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQDtqgENkQLIY5biPw54s7NWxo-e51V4AAm5Lf6_gxYCsseszm0xiEbkTHkD7KGqSKdgTA0kiRGi5qWmdwM0X5BMNFIcNkueUqKbbE6YYoMyp2TaWqZOz6EmWhX6vpOm8ZXLcCzM3vAnY/s1600/images.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQDtqgENkQLIY5biPw54s7NWxo-e51V4AAm5Lf6_gxYCsseszm0xiEbkTHkD7KGqSKdgTA0kiRGi5qWmdwM0X5BMNFIcNkueUqKbbE6YYoMyp2TaWqZOz6EmWhX6vpOm8ZXLcCzM3vAnY/s1600/images.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Richard Mathew Satallman&lt;/span&gt; (rms),was against the &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;U.S Copy write&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Act&lt;/span&gt; ,i.e restricting the unlicensed access to the software. Stallman proclaimed it and argued that it is blocking the user’s freedom to use it.In 1984 he quit his job from MIT to work full time on GNU project.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;The main intention behind GNU Project is to create free Unix-like operating system. With the launch of the GNU Project he founded the &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Free Software Foundation(FSF)&lt;/span&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Stallman popularize the concept of &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Copyleft&lt;/span&gt; ,a legal mechanism to protect the modification and redistribution rights for free software. In 1989 the first program independent GNU &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;General Public License&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;(GPL)&lt;/span&gt; was released. &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;The GNU system was almost completed by then,he was contributing many naccessary features like &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Text editor&lt;/span&gt; (Emacs), &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Compiler&amp;nbsp;&lt;/span&gt;(GCC) , &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Debugger&lt;/span&gt; (gdb).But one important thing was missing , i.e Kernel. The GNU kernel ,called &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Hurd&lt;/span&gt; ,failed to attract enough attention from developers leaving GNU incomplete. &lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Linus Torwalds donated the kernel&lt;/span&gt;.The existing programs for the GNU projects were ported to run in the new platform. and then formed the GNU/LINUX projects.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;Linus Torvalds’s contribution&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBiX_c7ojr6IdayAwlqcA7LilOHhKBe6_r7XxoyGm_zdAPU0rVTDkb0n71__rTCyASWvB26Q-EfiEskN0Qzp2bNVY8BrFiIu89j_N4OiByeIkbkIIBrbzfStlWPOmqgK9bGtBpdbNSh0o/s1600/220px-Linus_Torvalds.jpeg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgBiX_c7ojr6IdayAwlqcA7LilOHhKBe6_r7XxoyGm_zdAPU0rVTDkb0n71__rTCyASWvB26Q-EfiEskN0Qzp2bNVY8BrFiIu89j_N4OiByeIkbkIIBrbzfStlWPOmqgK9bGtBpdbNSh0o/s320/220px-Linus_Torvalds.jpeg&quot; width=&quot;208&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;When he was studied at Helsinki, he began a project that later becomes the Linux kernel.The main intention behind the project was to write a program specifically for the hardware that he was using and that should function independent of&amp;nbsp; an operating system.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;The development was done on&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt; MINIX&lt;/span&gt; operating system,using the &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;GNU C Compiler&lt;/span&gt;. He wrote on his book that he eventually realized that he had written an operating system, and he made a post in &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Usenet&lt;/span&gt;,that “ I am doing a (free) operating system, I’d like any feedback on things people like/dislike on MINIX…”&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;He made it successful,and the first version of Linux has released.He first published the Linux kernel under its own license, but later licensed under &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;GNU General Public License(GPL)&lt;/span&gt;. In the first release of &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;Linux 0.01&lt;/span&gt; Torwalds lists the GNU software that is required to run Linux.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Now Linux has many versions and distributions,and proves itself as &amp;nbsp;one of the worthy opponent to Windows giants.Many IT&amp;nbsp;industries&amp;nbsp;are now started to use Linux as a better alternative.&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Thank You..&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;MsoNormal&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/3770707986249996195/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/06/unix-to-linux-story.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/3770707986249996195'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/3770707986249996195'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/06/unix-to-linux-story.html' title='Unix to Linux story'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQDtqgENkQLIY5biPw54s7NWxo-e51V4AAm5Lf6_gxYCsseszm0xiEbkTHkD7KGqSKdgTA0kiRGi5qWmdwM0X5BMNFIcNkueUqKbbE6YYoMyp2TaWqZOz6EmWhX6vpOm8ZXLcCzM3vAnY/s72-c/images.jpg" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-8609999990488366431</id><published>2011-06-20T11:46:00.000-07:00</published><updated>2016-04-11T21:50:16.372-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Python"/><title type='text'>Python : Script mode</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;We have already discussed that python is an interpreted language and mainly there are two ways to use the interpreter , i.e&amp;nbsp;Interactive mode &amp;amp; Script modes&amp;nbsp;. In the&amp;nbsp;interactive&amp;nbsp;mode it just displays the result of expressions , We can have the python interpreter to execute our script file also.&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0cm;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;In script mode we can store the code in a file and use the&amp;nbsp;interpreter&amp;nbsp;to execute the content of the file which we called a script.The scripts must have saved with the extension .py.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;To edit the scripts, you can have common editors like &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;gedit&lt;/span&gt; , &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;VIM ,eric4 and eric5&lt;/span&gt; etc , Several type of editors are available for Unix and Windows.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;But when you edit python scripts the &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;indentation&lt;/span&gt; must be accurate, In all our files we use 2-spaces as the indent and 4-spaces is another popular choice.&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Script mode&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div align=&quot;LEFT&quot; style=&quot;font-style: normal; margin-bottom: 0cm; orphans: 2; widows: 2;&quot;&gt;
&lt;span style=&quot;color: black; font-family: inherit; font-size: large;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;There are several ways to use the interpreter and have execute our scripts.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Explicit Command line execution:&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Here python script is executed by providing the script file name as parameter to the python interpreter.In this style we explicitly name both the interpreter and the input script.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;we have a sample python script file called &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;sample.py&lt;/span&gt; is shown below.When you type &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;python sample.py&lt;/span&gt; ,it will provide &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;sample.py&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black;&quot;&gt;file&lt;/span&gt;&lt;/span&gt; to the python interpreter for execution.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLBLagsOtPbLH5aiDtqylGVk8ChlzAXkSFr19oj07FLTcbJGCoc8edO5P-EvnpVUpr0cu8qAkUkRpKz8E-wlag_0sGEXNqWXMR6KANiBCTHD928T4YBEDkkwe1aoupO9gUBvyWzka7i7Y/s1600/Screenshot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLBLagsOtPbLH5aiDtqylGVk8ChlzAXkSFr19oj07FLTcbJGCoc8edO5P-EvnpVUpr0cu8qAkUkRpKz8E-wlag_0sGEXNqWXMR6KANiBCTHD928T4YBEDkkwe1aoupO9gUBvyWzka7i7Y/s1600/Screenshot.png&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;You could see an import statement on top of the program ,by using this syntax you can pass command line arguments,i.e &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;sys.argv[1]&lt;/span&gt; will print the argument that you passed along with the file name.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;if __name__ == &#39;__main__&#39;&lt;/span&gt; is the boilerplate syntax to call the function&amp;nbsp;main().It is mainly used when a python file is run directly.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Output of the following program is displayed below .&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7cdC6OFrksNwgXfG9sRDj7Y1AN-n2KIT-qfW3jxqP1LVfbSuSDw0DUM5nU4Zqn0hv_ISA81wi0u5XdS8NfEEM7giVUO98Nui_HpEi4Z_s3ezcOfLA2lgC86eioRG16K8JInqzbf4QmLM/s1600/Screenshot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7cdC6OFrksNwgXfG9sRDj7Y1AN-n2KIT-qfW3jxqP1LVfbSuSDw0DUM5nU4Zqn0hv_ISA81wi0u5XdS8NfEEM7giVUO98Nui_HpEi4Z_s3ezcOfLA2lgC86eioRG16K8JInqzbf4QmLM/s1600/Screenshot.png&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Implicit command line&amp;nbsp;execution:&lt;/span&gt;&lt;/b&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;We can make the script file itself &amp;nbsp;executable and directing the shell to locate the python interpreter.For windows we can associate our script file &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;.py &lt;/span&gt;with &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;python.exe&lt;/span&gt;&amp;nbsp;.There are one or two steps to do this.&lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;when you creating a script file make sure that first line of the file contain the following &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;#!/usr/bin/env python.&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;If you enter the above code, the whole file will look as follows.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgybdC2vhywTPmpGb6mTUyK6YPVydKs8MiiaBGUHldi6p-wjfNa6LZ07DnKI0NKfL-_3xaJ2lU9z1LiDyPpKofeNWduDDfHA45diKdnAhx-pnv26BHB7SB0VlhOnmiMWb5aDJ3YOPlGxsY/s1600/Screenshot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgybdC2vhywTPmpGb6mTUyK6YPVydKs8MiiaBGUHldi6p-wjfNa6LZ07DnKI0NKfL-_3xaJ2lU9z1LiDyPpKofeNWduDDfHA45diKdnAhx-pnv26BHB7SB0VlhOnmiMWb5aDJ3YOPlGxsY/s1600/Screenshot.png&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;For POSIX-standard operating systems,do&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt; chmod +x sample2.py&lt;/span&gt; to make the file sample2.py executable.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Then you can run the file by using &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;./sample2.py&lt;/span&gt; command.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;when you run the file ,you will get the &lt;span style=&quot;font-family: inherit;&quot;&gt;expected&lt;/span&gt; output as follows.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUd8aTU1MsXMYn5UjSGB8oAFu2edxcuIbwELPbKuUbYmU42HPcmqOsbc2eRHksKAlGeP-YC8nFFhQ_42Bj7eME-qDlBagQNHUK5UvcNcwq8KX8xKXLqnH6Jwapce33YtllyJCLB3QVuUE/s1600/Screenshot.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUd8aTU1MsXMYn5UjSGB8oAFu2edxcuIbwELPbKuUbYmU42HPcmqOsbc2eRHksKAlGeP-YC8nFFhQ_42Bj7eME-qDlBagQNHUK5UvcNcwq8KX8xKXLqnH6Jwapce33YtllyJCLB3QVuUE/s1600/Screenshot.png&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Thank You..&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/8609999990488366431/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/06/python-script-mode.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/8609999990488366431'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/8609999990488366431'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/06/python-script-mode.html' title='Python : Script mode'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLBLagsOtPbLH5aiDtqylGVk8ChlzAXkSFr19oj07FLTcbJGCoc8edO5P-EvnpVUpr0cu8qAkUkRpKz8E-wlag_0sGEXNqWXMR6KANiBCTHD928T4YBEDkkwe1aoupO9gUBvyWzka7i7Y/s72-c/Screenshot.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5785907677647112110.post-2781065496353284225</id><published>2011-04-28T22:18:00.000-07:00</published><updated>2011-05-20T19:58:04.749-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Project"/><title type='text'>Project on ExpEYES</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;A FRAME WORK FOR CONTROLLING&lt;a href=&quot;http://www.blogger.com/goog_301739376&quot;&gt; &lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #3d85c6;&quot;&gt;&lt;a href=&quot;http://expeyes.in/&quot;&gt;expEYES&lt;/a&gt; &lt;/span&gt;(Brief)&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #b45f06; font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #535353; font-family: inherit; font-size: large; line-height: 16px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div class=&quot;rtejustify&quot; style=&quot;margin-bottom: 0.9em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&amp;nbsp;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #073763;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;b style=&quot;color: #b45f06;&quot;&gt;&amp;nbsp;&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #0b5394;&quot;&gt;expEYES&lt;/span&gt; is from the&amp;nbsp;PHOENIX&amp;nbsp;project of&amp;nbsp;Inter-University Accelerator Centre, New Delhi. It is a&amp;nbsp;hardware &amp;amp; software framework&amp;nbsp;for developing science experiments, demonstrations and projects and learn science and engineering by exploration. Capable of doing real time measurements and analysing the data in&amp;nbsp; different ways. Analog&amp;nbsp; voltages, in +/- 5 volts range, are measured with 12 bit resolution (around 1.25 millivolts) and time intervals with one microsecond.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;rtejustify&quot; style=&quot;margin-bottom: 0.9em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;&quot;&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxm-lJM6TExYJzvCjZu3vsaGJ0HEHVHJ975NlyfrQbZKfVBlHXHHYo2bWkPkeDZTym4rnoUMalq-3T20Kmb2-REyt_p3s_VfbJAagXYKoEGp_I-jY6kb18GZx1ZuLSYUlprMQBLSqPU18/s1600/eyes.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxm-lJM6TExYJzvCjZu3vsaGJ0HEHVHJ975NlyfrQbZKfVBlHXHHYo2bWkPkeDZTym4rnoUMalq-3T20Kmb2-REyt_p3s_VfbJAagXYKoEGp_I-jY6kb18GZx1ZuLSYUlprMQBLSqPU18/s320/eyes.jpg&quot; width=&quot;320&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;rtejustify&quot; style=&quot;margin-bottom: 0.9em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;&quot;&gt;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;This&lt;/span&gt;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&amp;nbsp; project is based on Free and Open Source software, mostly written in Python programming language. The hardware design is also open. A science laboratory at home becomes an affordable idea, with expEYES, costing around Rs.3000/- and the stuctured design supports adding more experiments without much effort.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;rtejustify&quot; style=&quot;margin-bottom: 0.9em; margin-left: 0px; margin-right: 0px; margin-top: 0.5em; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-align: justify;&quot;&gt;&lt;div&gt;&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&amp;nbsp;&amp;nbsp; The expEYES hardware is interfaced and powered by USB&lt;/span&gt;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;, having a size of 11 x 9 x 1.5 cm and weighs 150 gm. There are 32 terminals arranged in two rows where you can connect external signals, within +/-5 volts range, for control and measurement.&amp;nbsp;&lt;span style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;It can function as a signal generator, frequency counter and low frequency oscilloscope&lt;/span&gt;&lt;span style=&quot;color: mediumblue; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt; .&amp;nbsp;&lt;/span&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;I actually planning to do this project with the support of online functionality.i.e you can control any devices that you already connected with these expeEYES through web.Here i use Javascrpt/HTML as my Front-end support and Python would be the back-end.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;Here you could connect several other devices with this&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #b45f06;&quot;&gt;&amp;nbsp;&lt;/span&gt;expEYES&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #b45f06;&quot;&gt;&amp;nbsp;&lt;/span&gt;, and can do several &amp;nbsp;experiments with the support of expEYES.The accessory set that could connect with this expEYES&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #b45f06;&quot;&gt;&amp;nbsp;&lt;/span&gt;is shown below.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJjHpHQKji24QgLGTt_xFZ5c_m9R1c0CVemQ0BmA7TGKUh0raTmwodt89lteB4Ru7pq-u-_yhKaInKrFy5WuWdTXeVMwwPkZajJJ-dUNG6T82WIducJoCZeoZf8HJVm3baRDeApkuNF0s/s1600/Untitled.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;291&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJjHpHQKji24QgLGTt_xFZ5c_m9R1c0CVemQ0BmA7TGKUh0raTmwodt89lteB4Ru7pq-u-_yhKaInKrFy5WuWdTXeVMwwPkZajJJ-dUNG6T82WIducJoCZeoZf8HJVm3baRDeApkuNF0s/s320/Untitled.jpg&quot; width=&quot;320&quot; /&gt;&lt;/span&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;The communication with the &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black;&quot;&gt;expEYES&lt;/span&gt; is done using a library written in Python language.Programs with GUI have been written for many experiments.They will run on any computer having a Python interpreter and a Python module to access &amp;nbsp;the USB port.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style=&quot;font-family: inherit; font-size: large; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Debian packages are available for Debian and Ubuntu GNU/Linux distributions.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Further updates about this experiment will &amp;nbsp;publish soon......&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Will see you ..&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://sreeharikmarar.blogspot.com/feeds/2781065496353284225/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/04/my-first-experiment.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/2781065496353284225'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5785907677647112110/posts/default/2781065496353284225'/><link rel='alternate' type='text/html' href='http://sreeharikmarar.blogspot.com/2011/04/my-first-experiment.html' title='Project on ExpEYES'/><author><name>Sreehari</name><uri>http://www.blogger.com/profile/10650353955257578043</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhxm-lJM6TExYJzvCjZu3vsaGJ0HEHVHJ975NlyfrQbZKfVBlHXHHYo2bWkPkeDZTym4rnoUMalq-3T20Kmb2-REyt_p3s_VfbJAagXYKoEGp_I-jY6kb18GZx1ZuLSYUlprMQBLSqPU18/s72-c/eyes.jpg" height="72" width="72"/><thr:total>2</thr:total></entry></feed>