<?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-4112751891986525508</id><updated>2024-09-02T02:45:06.293+05:30</updated><title type='text'>Create your own future</title><subtitle type='html'>This is the platform where we can grow knowledge and share it to each other for helping the junior and the needed  persion.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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>33</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4112751891986525508.post-2722224438846137631</id><published>2014-04-02T11:04:00.002+05:30</published><updated>2014-04-02T19:08:00.041+05:30</updated><title type='text'>Git create branch in local sysyteam from remote branch &amp; fetch the remote branch </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; id=&quot;docs-internal-guid-9ba5132a-20ec-6249-2c00-2b607986ad26&quot; style=&quot;line-height: 1.5; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; font-weight: bold; vertical-align: baseline;&quot;&gt;Today Is New Day&lt;/span&gt;&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt; : One of my friend stuck in the git branching problem . He was working work the project and in particular branch from last 3 days and last night he pushed the code and delete that branch next day morning He found the code he pushed yesterday need one more changes and for that he need to pull that branch , But when he created that name branch with development and take the pull request he found merging conflict because in that branch some of the code which already implemented inside the development branch was not there and that was new for me also because I did not face this type of issue previously that I told him to create the new branch from master and then take that branch pull and it works, He was happy that I resolved his issue, But one question was roaming inside my mind that was if master branch also have some changes which I do not want inside that branch then how i can pull that branch in to my system , Then I have google and referred some of site and found my question answer that was.&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;

&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;when we pull the project from github and do &lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;

&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; font-weight: bold; vertical-align: baseline;&quot;&gt;git branch&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;

&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;it only shows us master, But it also take all the branch which is inside github for seeing that we have to run &lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;

&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; font-weight: bold; vertical-align: baseline;&quot;&gt;git branch -a &lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;

&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;so my solution was if I want to change in particular branch so with the help of &lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;

&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;git branch -a , First I will find that branch name and with the help of that branch I will create the new branch with same name in my local system for work for that we have to use the command &lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;

&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; font-weight: bold; vertical-align: baseline;&quot;&gt; git checkout -b &#39;branch name which i want to create &#39; origin/&#39;branch name from which i want to create new branch&#39;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;

&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;color: #1155cc; font-family: Arial; font-size: 15px; text-decoration: underline; vertical-align: baseline;&quot;&gt;&lt;a href=&quot;http://stackoverflow.com/questions/67699/how-do-i-clone-all-remote-branches-with-git&quot; style=&quot;text-decoration: none;&quot;&gt;http://stackoverflow.com/questions/67699/how-do-i-clone-all-remote-branches-with-git&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
And also if you want to fetch all the remote branch in your local system then run the command&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;b&gt;git fetch origin&amp;nbsp;&lt;/b&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/2722224438846137631/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2014/04/git-create-branch-in-local-sysyteam.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/2722224438846137631'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/2722224438846137631'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2014/04/git-create-branch-in-local-sysyteam.html' title='Git create branch in local sysyteam from remote branch &amp; fetch the remote branch '/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-9174346875065717208</id><published>2014-01-10T10:37:00.000+05:30</published><updated>2014-01-10T10:37:10.691+05:30</updated><title type='text'>HAML in rails3</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; id=&quot;docs-internal-guid-3ab038cb-7a8a-a572-d12e-4a88b0f4c675&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: #3c78d8; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;&amp;nbsp;I started learning Haml , My first need was how i can use it in rails , so first i found &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: #b7b7b7; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;1. How to create a rails application with Haml ? , Then i got the nice answer that &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: #b7b7b7; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;first&lt;/span&gt;&lt;span style=&quot;background-color: #3c78d8; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;When&lt;/span&gt;&lt;span style=&quot;background-color: #b7b7b7; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt; we have to add two gems inside are rails 3 application &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: #b7b7b7; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt; 1.gem &#39;haml&#39;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: #b7b7b7; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt; 2.gem &#39;haml-rails&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;span style=&quot;font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: #d9d9d9; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;Then bundle install then can use to create the rails application with scaffold it will &amp;nbsp;create the rails application with haml.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: #d9d9d9; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;I also found the screencast video for this &lt;/span&gt;&lt;a href=&quot;http://screencasts.org/episodes/introduction-to-haml&quot; style=&quot;text-decoration: none;&quot;&gt;&lt;span style=&quot;background-color: #d9d9d9; color: #1155cc; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; text-decoration: underline; vertical-align: baseline;&quot;&gt;http://screencasts.org/episodes/introduction-to-haml&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;background-color: #d9d9d9; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt; &amp;nbsp;for knowing what we have to follow to create any div and and how we can create the haml page .&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: #d9d9d9; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;Then I found how we can convert the html to haml for that i also found some screencast but they were not working with the rails4 , then i found this link &lt;/span&gt;&lt;a href=&quot;http://screencasts.org/episodes/using-haml-with-rails-3&quot; style=&quot;text-decoration: none;&quot;&gt;&lt;span style=&quot;background-color: #d9d9d9; color: #1155cc; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; text-decoration: underline; vertical-align: baseline;&quot;&gt;http://screencasts.org/episodes/using-haml-with-rails-3&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;background-color: #d9d9d9; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;, i went through that but did not get any sucess with the rails4 &lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;span style=&quot;background-color: #d9d9d9; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: #d9d9d9; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;When I watched the screencast and referred the stackoverflow then i also found , for changing html to haml there are three gem required , one gem already included inside the activerecord gem and the rest two are &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: #d9d9d9; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;1. gem ‘hpricot&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: #d9d9d9; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;2.gem ‘ruby-parser’’&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;b&gt;&lt;span style=&quot;color: #0b5394;&quot;&gt;gem for html to haml conversion&amp;nbsp;https://github.com/haml/html2haml&lt;/span&gt;&lt;/b&gt;&lt;span style=&quot;font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/9174346875065717208/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2014/01/haml-in-rails3.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/9174346875065717208'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/9174346875065717208'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2014/01/haml-in-rails3.html' title='HAML in rails3'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-6886401725142564831</id><published>2014-01-07T17:49:00.002+05:30</published><updated>2014-01-10T22:23:05.641+05:30</updated><title type='text'>ROR + A server is already running</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; id=&quot;docs-internal-guid-34fc3b7c-6ca4-2780-ef94-c46c4617f83a&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;This is the problem which i have to face many time , they best way to solve this&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;First just put this command &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 8pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: #eeeeee; color: red; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;netstat -plntu | grep 3000&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 8pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;You will get this output , pick the last ID &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 8pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: #6aa84f; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;tcp &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; color: maroon; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; color: maroon; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; color: maroon; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;0.0&lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; color: maroon; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;0.0&lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; color: maroon; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;3000&lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt; &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;background-color: #6aa84f; color: maroon; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;0.0&lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; color: maroon; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;0.0&lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;:* &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;LISTEN &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; color: maroon; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;132324&lt;/span&gt;&lt;span style=&quot;background-color: #6aa84f; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;/ruby&lt;/span&gt;&lt;span style=&quot;background-color: #eeeeee; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; vertical-align: baseline;&quot;&gt;The last column shows the PID and the process name, then use this command to kill that process :&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 8pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: cyan; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;kill -&lt;/span&gt;&lt;span style=&quot;background-color: cyan; color: maroon; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;9&lt;/span&gt;&lt;span style=&quot;background-color: cyan; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt; &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: cyan; color: maroon; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;132324&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;Then &amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #eeeeee; font-family: Consolas; font-size: 15px; vertical-align: baseline;&quot;&gt;rails s&lt;/span&gt;&lt;span style=&quot;background-color: white; font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;Chressssss!!!!!!!!!&lt;/span&gt;&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #cccccc; font-family: Arial; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: #cccccc; font-family: Verdana, sans-serif; font-size: 15px; vertical-align: baseline;&quot;&gt;Added two more commands told my friends Ruk &amp;nbsp;those are&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: #cccccc; font-family: Verdana, sans-serif; font-size: 15px; vertical-align: baseline;&quot;&gt;&lt;br style=&quot;font-size: 13px; line-height: normal; text-align: justify;&quot; /&gt;&lt;span style=&quot;font-size: 13px; line-height: normal; text-align: justify;&quot;&gt;$ lsof -wni tcp:3000&lt;/span&gt;&lt;br style=&quot;font-size: 13px; line-height: normal; text-align: justify;&quot; /&gt;&lt;span style=&quot;font-size: 13px; line-height: normal; text-align: justify;&quot;&gt;$ kill -9 Process_id&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/6886401725142564831/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2014/01/ror-server-is-already-running.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/6886401725142564831'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/6886401725142564831'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2014/01/ror-server-is-already-running.html' title='ROR + A server is already running'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-3014983675842698785</id><published>2014-01-07T15:22:00.001+05:30</published><updated>2014-01-07T15:22:34.229+05:30</updated><title type='text'>GitSubmodule &amp; git submodule issue with git-ignore </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;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; color: black; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;When i was working with rails i need to edit the file of bootstrap but also want every time updated that file from there master branch , to resolve this Problem I found git submodule, which solved my problem.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; color: black; font-family: &#39;News Cycle&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Suppose you want to add the bootstrap-translation then you can use git submodule add &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #a61c00; font-family: &#39;News Cycle&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;git://github.com/bootstrap-translation/bootstrap-translation.git bootstrap-translation&lt;/span&gt;&lt;/div&gt;
&lt;b id=&quot;docs-internal-guid-79b31301-6c1d-9ff3-c26a-64def2436bdd&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;background-color: transparent; color: #666666; font-family: &#39;Trebuchet MS&#39;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/b&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: red; color: black; font-family: Verdana; font-size: 15px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Note :- If you have a project with submodules then first you have to clone the project and You must run two commands: git submodule init to initialize your local configuration file, and git submodule update to fetch all the data from that project and check out the appropriate commit listed in your superproject:&lt;/span&gt;&lt;span style=&quot;background-color: #cc0000; color: black; font-family: Verdana; font-size: 15px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;background-color: white; color: #d9d9d9; font-family: Verdana; font-size: 15px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;b style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;a href=&quot;http://git-scm.com/book/en/Git-Tools-Submodules#Cloning-a-Project-with-Submodules&quot; style=&quot;text-decoration: none;&quot;&gt;&lt;span style=&quot;background-color: white; color: #d9d9d9; font-family: Verdana; font-size: 15px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&lt;/b&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; color: black; font-family: &#39;Comic Sans MS&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;I found some command for remove the submodule . &lt;/span&gt;&lt;/div&gt;
&lt;ol style=&quot;margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;li dir=&quot;ltr&quot; style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: decimal; margin-left: 31px; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Delete the relevant section from the &lt;/span&gt;&lt;span style=&quot;background-color: #eeeeee; color: black; font-family: &#39;Courier New&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;.gitmodules&lt;/span&gt;&lt;span style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; file.&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li dir=&quot;ltr&quot; style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: decimal; margin-left: 31px; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Stage the &lt;/span&gt;&lt;span style=&quot;background-color: #eeeeee; color: black; font-family: &#39;Courier New&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;.gitmodules&lt;/span&gt;&lt;span style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; changes &lt;/span&gt;&lt;span style=&quot;background-color: #eeeeee; color: black; font-family: &#39;Courier New&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;git add .gitmodules&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li dir=&quot;ltr&quot; style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: decimal; margin-left: 31px; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Delete the relevant section from &lt;/span&gt;&lt;span style=&quot;background-color: #eeeeee; color: black; font-family: &#39;Courier New&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;.git/config&lt;/span&gt;&lt;span style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;.&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li dir=&quot;ltr&quot; style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: decimal; margin-left: 31px; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Run &lt;/span&gt;&lt;span style=&quot;background-color: #eeeeee; color: black; font-family: &#39;Courier New&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;git rm --cached path_to_submodule&lt;/span&gt;&lt;span style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; (no trailing slash).&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li dir=&quot;ltr&quot; style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: decimal; margin-left: 31px; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Run &lt;/span&gt;&lt;span style=&quot;background-color: #eeeeee; color: black; font-family: &#39;Courier New&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;rm -rf .git/modules/path_to_submodule&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li dir=&quot;ltr&quot; style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: decimal; margin-left: 31px; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Commit &lt;/span&gt;&lt;span style=&quot;background-color: #eeeeee; color: black; font-family: &#39;Courier New&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;git commit -m &quot;Removed submodule &amp;lt;name&amp;gt;&quot;&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li dir=&quot;ltr&quot; style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: decimal; margin-left: 31px; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Delete the now untracked submodule files&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li dir=&quot;ltr&quot; style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; list-style-type: decimal; margin-left: 31px; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.2272727272727273; margin-bottom: 11pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: #eeeeee; color: black; font-family: &#39;Courier New&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;rm -rf path_to_submodule&lt;/span&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;b style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/b&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Then there was the last problem with me that “&lt;/span&gt;&lt;span style=&quot;background-color: white; color: #990000; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;HOW TO PUT IT IN GITIGNORE FILE&lt;/span&gt;&lt;span style=&quot;background-color: white; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;”&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;for solving this i have added the &lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: #cc0000; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;“ignore = dirty”&lt;/span&gt;&lt;/div&gt;
&lt;b style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;background-color: #6aa84f; color: white; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;h2 dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 10pt;&quot;&gt;
&lt;span style=&quot;background-color: #6aa84f; color: white; font-family: Arial; font-size: 17px; font-style: normal; font-variant: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;[submodule &quot;bundle/bootstrap-translation&quot;]&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;path = bundle/bootstrap-translation&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;url = git://github.com/bootstrap-translation/bootstrap-translation.git&lt;br class=&quot;kix-line-break&quot; /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ignore = dirty&lt;/span&gt;&lt;/h2&gt;
&lt;b style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: &#39;Times New Roman&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: &#39;Times New Roman&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: &#39;Times New Roman&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;For more please find out the link &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: &#39;Times New Roman&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;for gitignore&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: #1155cc; font-family: &#39;Times New Roman&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: underline; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;a href=&quot;http://www.nils-haldenwang.de/frameworks-and-tools/git/how-to-ignore-changes-in-git-submodules&quot; style=&quot;text-decoration: none;&quot;&gt;http://www.nils-haldenwang.de/frameworks-and-tools/git/how-to-ignore-changes-in-git-submodules&lt;/a&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: &#39;Times New Roman&#39;; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&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://vyasarvind.blogspot.com/feeds/3014983675842698785/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2014/01/gitsubmodule-git-submodule-issue-with.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/3014983675842698785'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/3014983675842698785'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2014/01/gitsubmodule-git-submodule-issue-with.html' title='GitSubmodule &amp; git submodule issue with git-ignore '/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-8318084910510323868</id><published>2013-12-16T07:31:00.000+05:30</published><updated>2013-12-16T07:31:10.090+05:30</updated><title type='text'>gem mysql2 install failing ubuntu 64 bit</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
There is a bit problem with mysql installation with the ruby gem , we can solve this problem with these two commands&amp;nbsp;&lt;a href=&quot;http://stackoverflow.com/questions/4115126/ruby-gem-mysql2-install-failing&quot;&gt;ruby-gem-mysql2-install-failing&lt;/a&gt;&lt;div&gt;
&lt;br /&gt;&lt;div&gt;
&lt;pre class=&quot;default prettyprint prettyprinted&quot; style=&quot;background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; line-height: 18px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;&lt;code style=&quot;border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;color: #cc0000;&quot;&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;sudo apt&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;get&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; install libmysqlclient&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;dev  &lt;/span&gt;&lt;span class=&quot;com&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;#(mysql development headers)&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
sudo gem install mysql2 &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;kwd&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;with&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;mysql&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;-&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;dir&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;/etc/&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;mysql&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; border: 0px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;default prettyprint prettyprinted&quot; style=&quot;background-color: #eeeeee; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 14px; line-height: 18px; margin-bottom: 10px; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;&quot;&gt;you can find here more description &lt;span id=&quot;goog_1535810195&quot;&gt;&lt;/span&gt;&lt;span id=&quot;goog_1535810196&quot;&gt;&lt;/span&gt;&lt;a href=&quot;https://www.blogger.com/&quot;&gt;&lt;/a&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/8318084910510323868/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2013/12/gem-mysql2-install-failing-ubuntu-64-bit.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/8318084910510323868'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/8318084910510323868'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2013/12/gem-mysql2-install-failing-ubuntu-64-bit.html' title='gem mysql2 install failing ubuntu 64 bit'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-8118207828719146109</id><published>2013-08-17T16:53:00.001+05:30</published><updated>2013-08-17T16:53:26.237+05:30</updated><title type='text'>image with f.submit tag in rails</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;pre class=&quot;lang-rb prettyprint prettyprinted&quot; style=&quot;-webkit-text-stroke-width: 0px; background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 10px; max-height: 600px; orphans: auto; overflow: auto; padding: 5px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; widows: auto; width: auto; word-spacing: 0px;&quot;&gt;&lt;code style=&quot;background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;lang-rb prettyprint prettyprinted&quot; style=&quot;-webkit-text-stroke-width: 0px; background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 10px; max-height: 600px; orphans: auto; overflow: auto; padding: 5px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; widows: auto; width: auto; word-spacing: 0px;&quot;&gt;&lt;code style=&quot;background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;we can use this option &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;lang-rb prettyprint prettyprinted&quot; style=&quot;-webkit-text-stroke-width: 0px; background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 10px; max-height: 600px; orphans: auto; overflow: auto; padding: 5px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; widows: auto; width: auto; word-spacing: 0px;&quot;&gt;&lt;code style=&quot;background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;lt;%=&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; f&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;submit &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;Comment&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;type &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;image&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;src &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;/images/comment-button.png&quot;&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;%&amp;gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;lang-rb prettyprint prettyprinted&quot; style=&quot;-webkit-text-stroke-width: 0px; background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 10px; max-height: 600px; orphans: auto; overflow: auto; padding: 5px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; widows: auto; width: auto; word-spacing: 0px;&quot;&gt;&lt;code style=&quot;background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;lang-rb prettyprint prettyprinted&quot; style=&quot;-webkit-text-stroke-width: 0px; background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 10px; max-height: 600px; orphans: auto; overflow: auto; padding: 5px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; widows: auto; width: auto; word-spacing: 0px;&quot;&gt;&lt;code style=&quot;background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;And one more&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;lang-rb prettyprint prettyprinted&quot; style=&quot;-webkit-text-stroke-width: 0px; background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 10px; max-height: 600px; orphans: auto; overflow: auto; padding: 5px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; widows: auto; width: auto; word-spacing: 0px;&quot;&gt;&lt;code style=&quot;background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;nbsp;Erb tag&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;lang-rb prettyprint prettyprinted&quot; style=&quot;-webkit-text-stroke-width: 0px; background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 10px; max-height: 600px; orphans: auto; overflow: auto; padding: 5px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; widows: auto; width: auto; word-spacing: 0px;&quot;&gt;&lt;code style=&quot;background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&amp;lt;%= f.submit %&amp;gt; &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;lang-rb prettyprint prettyprinted&quot; style=&quot;-webkit-text-stroke-width: 0px; background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17.27272605895996px; margin: 0px 0px 10px; max-height: 600px; orphans: auto; overflow: auto; padding: 5px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; widows: auto; width: auto; word-spacing: 0px;&quot;&gt;&lt;code style=&quot;background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;code style=&quot;background-color: #eeeeee; background-position: initial initial; background-repeat: initial initial; border: 0px; font-family: Consolas, Menlo, Monaco, &#39;Lucida Console&#39;, &#39;Liberation Mono&#39;, &#39;DejaVu Sans Mono&#39;, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, monospace, serif; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;input&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;str&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: maroon; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;&quot;submit&quot;&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
  background&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;url&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;mybutton&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;png&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;);&lt;/span&gt;&lt;span class=&quot;pln&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;pun&quot; style=&quot;background-color: transparent; background-position: initial initial; background-repeat: initial initial; border: 0px; color: black; font-size: 13.63636302947998px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;}&lt;/span&gt;&lt;/code&gt; &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/8118207828719146109/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2013/08/image-with-fsubmit-tag-in-rails.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/8118207828719146109'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/8118207828719146109'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2013/08/image-with-fsubmit-tag-in-rails.html' title='image with f.submit tag in rails'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-3451091396780974561</id><published>2013-06-06T15:47:00.001+05:30</published><updated>2013-06-06T15:48:37.902+05:30</updated><title type='text'>while starting the sunspot server and when i run rake db:migrate  this error occuring undefined method `empty?&#39; for :needs:Symbol</title><content type='html'>Downgrade your rake version &lt;br /&gt;
&lt;pre style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; border: 0px; color: #333333; font-family: Consolas, &#39;Liberation Mono&#39;, Courier, monospace; font-size: 17px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; margin: 0px; orphans: auto; padding: 0px; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: auto; word-spacing: 0px;&quot;&gt;rake (0.9.2.2)&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/3451091396780974561/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2013/06/while-starting-sunspot-server-this.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/3451091396780974561'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/3451091396780974561'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2013/06/while-starting-sunspot-server-this.html' title='while starting the sunspot server and when i run rake db:migrate  this error occuring undefined method `empty?&#39; for :needs:Symbol'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-2830806638626646530</id><published>2013-06-05T13:06:00.001+05:30</published><updated>2013-06-05T13:06:20.500+05:30</updated><title type='text'>restart apache in ubuntu 12.04</title><content type='html'>&lt;pre style=&quot;-webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; background-color: #e0e0e0; border: 0px; color: #333333; font-family: &#39;Ubuntu Mono&#39;, &#39;Ubuntu Beta Mono A&#39;, Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 17px; margin: 0px 0px 10px; max-height: 600px; orphans: auto; overflow: auto; padding: 5px; text-align: left; text-indent: 0px; text-transform: none; vertical-align: baseline; widows: auto; width: auto; word-spacing: 0px;&quot;&gt;&lt;code style=&quot;background-color: #e0e0e0; border: 0px; color: #222222; font-family: &#39;Ubuntu Mono&#39;, &#39;Ubuntu Beta Mono A&#39;, Consolas, &#39;Bitstream Vera Sans Mono&#39;, &#39;Courier New&#39;, Courier, monospace; font-size: 14px; margin: 0px; padding: 0px; vertical-align: baseline;&quot;&gt;sudo /etc/init.d/apache2 restart&lt;/code&gt;&lt;/pre&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/2830806638626646530/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2013/06/restart-apache-in-ubuntu-1204.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/2830806638626646530'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/2830806638626646530'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2013/06/restart-apache-in-ubuntu-1204.html' title='restart apache in ubuntu 12.04'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-5718909514234361255</id><published>2012-11-06T13:24:00.001+05:30</published><updated>2012-11-06T13:24:18.222+05:30</updated><title type='text'>install mongodb ubuntu 12.10</title><content type='html'>commands&lt;br /&gt;
-------------------&lt;br /&gt;
1.sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10&lt;br /&gt;&lt;br /&gt;

2sudo echo &quot;deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen&quot; | tee -a /etc/apt/sources.list.d/10gen.list&lt;br /&gt;
sudo apt-get -y update&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3.
sudo apt-get -y update&lt;br /&gt;
&lt;br /&gt;
4.sudo apt-get -y install mongodb-10gen</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/5718909514234361255/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/11/install-mongodb-ubuntu-1210.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/5718909514234361255'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/5718909514234361255'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/11/install-mongodb-ubuntu-1210.html' title='install mongodb ubuntu 12.10'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-2905611565018774677</id><published>2012-10-23T10:55:00.001+05:30</published><updated>2012-10-23T10:55:51.139+05:30</updated><title type='text'>Start work with mongodb with rails</title><content type='html'>


 
 
 
 &lt;style type=&quot;text/css&quot;&gt;
 &lt;!--
  @page { margin: 0.79in }
  PRE.cjk { font-family: &quot;DejaVu Sans&quot;, monospace }
  P { margin-bottom: 0.08in }
  H4 { margin-bottom: 0.08in }
  H4.ctl { font-family: &quot;Lohit Hindi&quot; }
  TT.cjk { font-family: &quot;DejaVu Sans&quot;, monospace }
 --&gt;
 &lt;/style&gt;


&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
 How we can start work with mongodb&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
step:1 rails new my_app
–skip-active-record&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
        If you are working with mongodb
so we use to avoid the active record 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
       because it  does not work on
relational database .&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
Step2:Now  go to Config/application.rb
and instead of first line&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
         require “rails/all” 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
   wright this&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
         require
“action_controller/railtie”&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
         require
“action_mailer/railtie”&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
        require
“active-resource/railtie”&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
        require “
rails/test_unit/railtie”&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
step3: It&#39;s also important to make sure
that the reference to active_record in the generator block is
commented out&lt;/div&gt;
&lt;pre class=&quot;western&quot;&gt;# Configure generators values. Many other options are available, be sure to check the documentation.
# config.generators do |g|
#   g.orm             :active_record
#   g.template_engine :erb
#   g.test_framework  :test_unit, :fixture =&amp;gt; true
# end&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
step:4 Bundling&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
   Edit Gemfile 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
     gem rails ,”3.0.0”&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
   now you need to select the  OM
framework , these will require the &#39;mongo&#39;gem by default 
&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
 # Edit this Gemfile to bundle your
application&#39;s dependencies.&lt;/div&gt;
&lt;pre class=&quot;western&quot;&gt;  require &#39;rubygems&#39;
  require &#39;mongo&#39;
  source &#39;http://gemcutter.org&#39;

  gem &quot;rails&quot;, &quot;3.0.0&quot;
  gem &quot;mongo_mapper&quot;&lt;/pre&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
  Requiring &lt;tt class=&quot;western&quot;&gt;rubygems&lt;/tt&gt; and &lt;tt class=&quot;western&quot;&gt;mongo&lt;/tt&gt;
before running the &lt;tt class=&quot;western&quot;&gt;gem&lt;/tt&gt; command will ensure
that &lt;tt class=&quot;western&quot;&gt;bson_ext&lt;/tt&gt; is    loaded. If you&#39;d rather
not load &lt;tt class=&quot;western&quot;&gt;rubygems&lt;/tt&gt;, just make sure that both
&lt;tt class=&quot;western&quot;&gt;mongo&lt;/tt&gt; and &lt;tt class=&quot;western&quot;&gt;bson_ext&lt;/tt&gt;
are in   your load path when you require &lt;tt class=&quot;western&quot;&gt;mongo&lt;/tt&gt;.&lt;/div&gt;
Once you&#39;ve configured your &lt;tt class=&quot;western&quot;&gt;Gemfile&lt;/tt&gt;,
run the bundle installe&lt;br /&gt;

&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
 bundle install&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
&lt;h4 class=&quot;western&quot;&gt;
Initializing&lt;/h4&gt;
Create a Ruby file in &lt;tt class=&quot;western&quot;&gt;config/initializers&lt;/tt&gt;.
You can give it any name you want; here we&#39;ll call it
&lt;tt class=&quot;western&quot;&gt;config/initializers/mongo.rb&lt;/tt&gt;:&lt;br /&gt;

&lt;pre class=&quot;western&quot; style=&quot;border: none; padding: 0in;&quot;&gt;MongoMapper.connection = Mongo::Connection.new(&#39;localhost&#39;, 27017)
MongoMapper.database = &quot;#myapp-#{Rails.env}&quot;

if defined?(PhusionPassenger)
   PhusionPassenger.on_event(:starting_worker_process) do |forked|
     MongoMapper.connection.connect if forked
   end
end&lt;/pre&gt;
&lt;h4 class=&quot;western&quot;&gt;
Initializing&lt;/h4&gt;
Last item is to create an initializer to connect to MongoDB.
Create a Ruby file in &lt;tt class=&quot;western&quot;&gt;config/initializers&lt;/tt&gt;.
You can give it any name you want; here we&#39;ll call it
&lt;tt class=&quot;western&quot;&gt;config/initializers/mongo.rb&lt;/tt&gt;:&lt;br /&gt;

&lt;pre class=&quot;western&quot; style=&quot;border: none; padding: 0in;&quot;&gt;MongoMapper.connection = Mongo::Connection.new(&#39;localhost&#39;, 27017)
MongoMapper.database = &quot;#myapp-#{Rails.env}&quot;

if defined?(PhusionPassenger)
   PhusionPassenger.on_event(:starting_worker_process) do |forked|
     MongoMapper.connection.connect if forked
   end
end&lt;/pre&gt;
&lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=4112751891986525508&quot; name=&quot;Rails3-GettingStarted-RunningTests1&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;br /&gt;

&lt;a href=&quot;https://www.blogger.com/blogger.g?blogID=4112751891986525508&quot; name=&quot;Rails3-GettingStarted-RunningTests&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
&lt;br /&gt;

&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;br /&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/2905611565018774677/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/10/start-work-with-mongodb-with-rails.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/2905611565018774677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/2905611565018774677'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/10/start-work-with-mongodb-with-rails.html' title='Start work with mongodb with rails'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-4036664970500378093</id><published>2012-10-10T18:51:00.001+05:30</published><updated>2012-10-10T19:01:25.934+05:30</updated><title type='text'>Set Up Capistrano</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 style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;style type=&quot;text/css&quot;&gt;
 &lt;!--
  @page { margin: 0.79in }
  P { margin-bottom: 0.08in }
  CODE.cjk { font-family: &quot;DejaVu Sans&quot;, monospace }
  A:link { so-language: zxx }
 &lt;/style&gt;&lt;/div&gt;
Capistrano is a wonderful program for deploying Rails 3 apps. It work almost with any version controller system.Here we are working with git so we will develop right way fot that.&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0in;&quot;&gt;
&lt;span style=&quot;color: #444444;&quot;&gt;        &lt;/span&gt;&lt;span style=&quot;color: #444444;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, Times, serif;&quot;&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;span style=&quot;font-style: normal;&quot;&gt;&lt;span style=&quot;font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;#1 &lt;/span&gt;gem install capistrano &lt;br /&gt;
&lt;br /&gt;
then add this gem to the gem file &lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;&lt;br /&gt; #2 &lt;/span&gt;gem &#39;capistrano&#39; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For installing it into the application we need bundle instal &lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;#3&lt;/span&gt; capify . &lt;br /&gt;
&lt;br /&gt;
This command will genrate it will generate two file &lt;br /&gt;
&lt;br /&gt;
1.Capfile &lt;br /&gt;
2.config/deploy.rb &lt;br /&gt;
&lt;br /&gt;
Some information require for your application deploy , it will be inside the &lt;span style=&quot;background-color: magenta;&quot;&gt;deploy&lt;/span&gt;&lt;br /&gt;
require &#39;bundler/capistrano&#39; &lt;br /&gt;
&lt;br /&gt;
set :user, &#39;username&#39; &lt;br /&gt;
&lt;br /&gt;
set :domain, &#39;web.host.com&#39; &lt;br /&gt;
&lt;br /&gt;
set :applicationdir, &quot;appdir&quot; &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
set :scm, &#39;git&#39; &lt;br /&gt;
&lt;br /&gt;
set :repository,  &quot;&lt;a href=&quot;ssh://&quot;&gt;ssh://&lt;/a&gt;[user@]host/~/projectdir.git&quot; &lt;br /&gt;
&lt;br /&gt;
set :git_enable_submodules, 1 # if you have vendored rails &lt;br /&gt;
&lt;br /&gt;
set :branch, &#39;master&#39; &lt;br /&gt;
&lt;br /&gt;
set :git_shallow_clone, 1 &lt;br /&gt;
&lt;br /&gt;
set :scm_verbose, true &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# roles (servers) &lt;br /&gt;
&lt;br /&gt;
role :web, domain &lt;br /&gt;
&lt;br /&gt;
role :app, domain &lt;br /&gt;
&lt;br /&gt;
role :db,  domain, :primary =&amp;gt; true &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# deploy config &lt;br /&gt;
&lt;br /&gt;
set :deploy_to, applicationdir &lt;br /&gt;
&lt;br /&gt;
set :deploy_via, :export &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# additional settings &lt;br /&gt;
&lt;br /&gt;
default_run_options[:pty] = true  # Forgo errors when deploying from windows &lt;br /&gt;
&lt;br /&gt;
#ssh_options[:keys] = %w(/home/user/.ssh/id_rsa)            # If you are using ssh_keysset :chmod755, &quot;app config db lib public vendor script script/* public/disp*&quot;set :use_sudo, false &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# Passenger &lt;br /&gt;
&lt;br /&gt;
namespace :deploy do &lt;br /&gt;
&lt;br /&gt;
task :start do ; end &lt;br /&gt;
&lt;br /&gt;
task :stop do ; end &lt;br /&gt;
&lt;br /&gt;
task :restart, :roles =&amp;gt; :app, :except =&amp;gt; { :no_release =&amp;gt; true } do &lt;br /&gt;
&lt;br /&gt;
run &quot;#{try_sudo} touch #{File.join(current_path,&#39;tmp&#39;,&#39;restart.txt&#39;)}&quot; &lt;br /&gt;
&lt;br /&gt;
end &lt;br /&gt;
&lt;br /&gt;
end &lt;br /&gt;
for deploying it use the command &lt;br /&gt;
&lt;span style=&quot;color: magenta;&quot;&gt;&lt;br /&gt; #4&lt;/span&gt; cap deploy&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if you have multiple server just like one for testing or can say one is live one is development one is staging then follow this&lt;br /&gt;
&lt;a href=&quot;https://github.com/capistrano/capistrano/wiki/2.x-Multistage-Extension&quot;&gt;Multistage Extension&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;If this post help you then please comment or like it , if you can share your&amp;nbsp;&amp;nbsp; knowldge please comment.&lt;br /&gt;
Thanks&lt;br /&gt;
Arvind 
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/4036664970500378093/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/10/set-up-capistrano.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/4036664970500378093'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/4036664970500378093'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/10/set-up-capistrano.html' title='Set Up Capistrano'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-7522614327361062507</id><published>2012-10-06T11:43:00.002+05:30</published><updated>2012-10-06T11:43:48.669+05:30</updated><title type='text'>Talking about how we can edit image in rails 3</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Comment is must: &lt;br /&gt;
&lt;br /&gt;
I search the &lt;a href=&quot;http://ckeditor.com/&quot; rel=&quot;nofollow&quot;&gt;CKEditor&lt;/a&gt; which is usefull to edit the image &lt;a href=&quot;http://ckeditor.com/&quot;&gt;http://ckeditor.com/&lt;/a&gt; or&lt;br /&gt;
&lt;br /&gt;
install the &lt;a href=&quot;https://github.com/sferik/rails_admin/&quot; rel=&quot;nofollow&quot;&gt;rails_admin&lt;/a&gt; gem and follow the instructions in the README to set-up CKEditor&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/7522614327361062507/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/10/talking-about-how-we-can-edit-image-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/7522614327361062507'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/7522614327361062507'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/10/talking-about-how-we-can-edit-image-in.html' title='Talking about how we can edit image in rails 3'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-5288137474439959692</id><published>2012-10-06T11:42:00.002+05:30</published><updated>2012-10-06T11:42:30.823+05:30</updated><title type='text'>how to find the error in email setting in rails</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Hi please like the comment if you got the right answer and share your comment&lt;br /&gt;
&amp;nbsp;what the thing i got ,if you are working in email seting or SMTP seting in rails&lt;br /&gt;
&lt;br /&gt;
always ActionMailer::Base.raise_delivery_errors = true, use true it helps lots&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/5288137474439959692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/10/how-to-find-error-in-email-setting-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/5288137474439959692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/5288137474439959692'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/10/how-to-find-error-in-email-setting-in.html' title='how to find the error in email setting in rails'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-5549864651368630525</id><published>2012-09-10T18:58:00.000+05:30</published><updated>2012-09-10T19:52:33.906+05:30</updated><title type='text'>Postgres Sql</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Uninstall the Postgresql&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;&lt;code&gt;sudo apt-get --purge remove postgresql&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;Can &lt;a href=&quot;http://askubuntu.com/questions/32730/how-to-remove-postgres-from-my-installation&quot;&gt;http://askubuntu.com/questions/32730/how-to-remove-postgres-from-my-installation&lt;/a&gt; also refer  &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;Install the Postgresql&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;  for Ubuntu please refer this link&lt;a href=&quot;https://help.ubuntu.com/community/PostgreSQL&quot;&gt;https://help.ubuntu.com/community/PostgreSQL&lt;/a&gt; &lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/5549864651368630525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/09/postgres-sql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/5549864651368630525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/5549864651368630525'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/09/postgres-sql.html' title='Postgres Sql'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-5239312932523560131</id><published>2012-09-06T19:34:00.001+05:30</published><updated>2012-09-06T19:34:06.313+05:30</updated><title type='text'>For Rails beginner , For Good Codding some tips</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
When we use to code at that time we think that coding is nothing but only what we want that should complete and we don&#39;t see the other thing even don&#39;t remember the proper indentation , So with my experience i am writing some tips for good codding&lt;br /&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; if any body have more tips&amp;nbsp; than please command or share with me&lt;br /&gt;
&lt;br /&gt;
1. As i told proper indentation .&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; Ruby Style : 2 space&amp;nbsp; indent .&lt;br /&gt;
2. Space around arrow =&amp;gt;, and also &#39; , &#39;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if you will follow this it will increase the code readability.&lt;br /&gt;
&lt;br /&gt;
3.Do not use while loop.&lt;br /&gt;
4. Inside the view don&#39;t code &amp;nbsp; , if needed then use view helper.&lt;br /&gt;
5.&lt;span class=&quot;a&quot; style=&quot;left: 418px; letter-spacing: -1px; top: 4722px; word-spacing: 2px;&quot;&gt;Don&#39;t use ActiveRecord models in migration unless you re-define them within&lt;/span&gt;&lt;span class=&quot;a&quot; style=&quot;left: 418px; letter-spacing: -1px; top: 4809px; word-spacing: 4px;&quot;&gt;the migration&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;a&quot; style=&quot;left: 418px; letter-spacing: -1px; top: 4809px; word-spacing: 4px;&quot;&gt;6. Database related query always wright in Activerecord&amp;nbsp; &lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/5239312932523560131/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/09/for-rails-beginner-for-good-codding.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/5239312932523560131'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/5239312932523560131'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/09/for-rails-beginner-for-good-codding.html' title='For Rails beginner , For Good Codding some tips'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-7920452188710546021</id><published>2012-09-06T12:34:00.001+05:30</published><updated>2012-09-06T12:46:25.675+05:30</updated><title type='text'>Errorr with solution , mongrol , postgresql </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;pre&gt;I am using rails 2.2.2 with ruby 1.8.7.
When i start server, this is the error that i receive:

E:\xop\xopweb&amp;gt;ruby script/server
=&amp;gt; Booting Mongrel (use &#39;script/server webrick&#39; to force WEBrick)
=&amp;gt; Rails 2.2.2 application starting on &lt;a class=&quot;postedlink&quot; href=&quot;http://0.0.0.0:3000/&quot; rel=&quot;nofollow&quot;&gt;http://0.0.0.0:3000&lt;/a&gt;
=&amp;gt; Call with -d to detach
=&amp;gt; Ctrl-C to shutdown server
Exiting
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/depende
ncies.rb:142:in `load_without_new_constant_marking&#39;: no such file to
load -- mon
grel_rails (MissingSourceFile)
        from
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_su
pport/dependencies.rb:142:in `load&#39;
        from
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_su
pport/dependencies.rb:521:in `new_constants_in&#39;
        from
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_su
pport/dependencies.rb:142:in `load&#39;
        from
C:/Ruby187/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/servers/
mongrel.rb:64
        from
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`gem_original_require&#39;
        from
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`require&#39;
        from
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_su
pport/dependencies.rb:153:in `require&#39;
        from
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_su
pport/dependencies.rb:521:in `new_constants_in&#39;
        from
C:/Ruby187/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_su
pport/dependencies.rb:153:in `require&#39;
        from
C:/Ruby187/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/commands/server.r
b:49
        from
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`gem_original_require&#39;
        from
C:/Ruby187/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in
`require&#39;
        from script/server:3

&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;
                              When i was first time working with rails 2.2.2 and ruby 1.8.7&lt;/span&gt;&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4cccc;&quot;&gt;with PostgreSQL it was giving me this error  i search lot about this error why it is occurring&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4cccc;&quot;&gt;seeing it is showing thing it is showing that it is the error with gem or ruby vression ,&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4cccc;&quot;&gt;                 But if you want to solve this first run it with webrick then it will show the&lt;/pre&gt;
&lt;pre style=&quot;background-color: #f4cccc;&quot;&gt;correct error ,&amp;nbsp;&lt;/pre&gt;
&lt;pre&gt;&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;                When i did it was showing the error ./script/../config/../vendor/rails/railties/lib/rails/gem_dependency.rb:106:in `requirement&#39;: undefined method `version_requirements&#39; for #&amp;lt;Gem::Dependency:0xb72f4894&amp;gt; (NoMethodError)&lt;/span&gt;

&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;                  for solving it i did only change the gem versoin that was 1.8,.., so i change it to lower one 1.3.5 so it is working fine&lt;/span&gt;

&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;And also you can find the command &lt;/span&gt;
&lt;span style=&quot;background-color: #f4cccc;&quot;&gt;&lt;a href=&quot;http://vyasarvind.blogspot.in/2012/09/ruby-gem-update.html&quot; rel=&quot;nofollow&quot;&gt;http://vyasarvind.blogspot.in/2012/09/ruby-gem-update.html&lt;/a&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/7920452188710546021/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/09/errorr-with-solution-mongrol-postgresql.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/7920452188710546021'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/7920452188710546021'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/09/errorr-with-solution-mongrol-postgresql.html' title='Errorr with solution , mongrol , postgresql '/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-3242864409132384185</id><published>2012-09-05T20:19:00.004+05:30</published><updated>2012-09-05T20:19:41.391+05:30</updated><title type='text'>Ruby gem update</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
There is no need to install an uninstall the ruby gem for jsut changing the gem version , Installing the version manager to solve this problem&lt;br /&gt;
&lt;br /&gt;
&lt;h2 style=&quot;background-color: magenta; font-weight: normal; text-align: left;&quot;&gt;
1.&lt;code&gt;s&lt;strike&gt;&lt;/strike&gt;udo gem uninstall rubygems-update -v 1.3.5&lt;/code&gt;&lt;/h2&gt;
&lt;h3 style=&quot;background-color: magenta; font-weight: normal; text-align: left;&quot;&gt;
&lt;code&gt;2.&lt;/code&gt;Update to 1.3.0: &lt;code&gt;sudo gem install rubygems-update -v 1.3.0&lt;/code&gt;&lt;/h3&gt;
&lt;h3 style=&quot;background-color: magenta; font-weight: normal; text-align: left;&quot;&gt;
&lt;code&gt;3.&lt;/code&gt;&lt;code&gt;sudo update_rubygems&lt;/code&gt;&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;code style=&quot;background-color: magenta; font-weight: normal;&quot;&gt;4.&lt;/code&gt;&lt;span style=&quot;background-color: magenta; font-weight: normal;&quot;&gt;Then update to latest: &lt;/span&gt;&lt;code style=&quot;background-color: magenta; font-weight: normal;&quot;&gt;sudo gem update --system&lt;/code&gt;&lt;code style=&quot;background-color: magenta; font-weight: normal;&quot;&gt; &lt;/code&gt;&lt;code style=&quot;background-color: magenta; font-weight: normal;&quot;&gt;&amp;nbsp;&lt;/code&gt;&lt;code&gt; &lt;/code&gt;&lt;/h3&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/3242864409132384185/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/09/ruby-gem-update.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/3242864409132384185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/3242864409132384185'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/09/ruby-gem-update.html' title='Ruby gem update'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-2721254507514648054</id><published>2012-08-28T11:56:00.001+05:30</published><updated>2012-08-28T11:56:34.824+05:30</updated><title type='text'>Application security checking</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Breakman gem in rails use for checking the security of your application&lt;br /&gt;
&amp;nbsp;can follow in rails cast video link http://railscasts.com/episodes/358-brakeman?autoplay=true&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/2721254507514648054/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/08/application-security-checking.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/2721254507514648054'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/2721254507514648054'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/08/application-security-checking.html' title='Application security checking'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-3262548569314348177</id><published>2012-05-30T15:03:00.002+05:30</published><updated>2012-05-30T15:03:49.059+05:30</updated><title type='text'>Creating popup box in rails through jquery</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;text-align: left;&quot;&gt;
Always remember to get the popup box in rails you can use jquery which is fancy box .&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
some script which is needed &lt;/div&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&quot;&amp;gt;&amp;lt;/script&amp;gt;

&amp;lt;script type=&quot;text/javascript&quot; src=&quot;/fancybox/jquery.fancybox-1.3.4.pack.js&quot;&amp;gt;&amp;lt;/script&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;/fancybox/jquery.easing-1.4.pack.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;/fancybox/jquery.mousewheel-3.0.4.pack.js&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;lt;link rel=&quot;stylesheet&quot; href=&quot;/fancybox/jquery.fancybox-1.3.4.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&amp;gt;&lt;/code&gt;&lt;code&gt; &lt;/code&gt;&lt;/pre&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
if you want to change the content according to your link then in that &quot;iframe&quot;is there in that you can send the id and&amp;nbsp; can see the popup&lt;/div&gt;
&lt;/blockquote&gt;
Ex:-&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/AVvXsEh5N5mzblZIzga8rBT0Lbg9LzYcZH5Ms3d7GlCC4qFW3hZoPSVN-hf5dPWPM7o9nq236ajkg5dplePh3r3WfgWNSQgEHc7iFy3k8Lc8rNuacyeq5giAcbRPgRq_BVssuLxGNUyqopcHN5g/s1600/Screenshot-1.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;99&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh5N5mzblZIzga8rBT0Lbg9LzYcZH5Ms3d7GlCC4qFW3hZoPSVN-hf5dPWPM7o9nq236ajkg5dplePh3r3WfgWNSQgEHc7iFy3k8Lc8rNuacyeq5giAcbRPgRq_BVssuLxGNUyqopcHN5g/s320/Screenshot-1.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
if you want to show this in rails then you have to follow some steps&lt;br /&gt;
1. Add the css and js file in public folder which is written in the fancy box jquery&lt;br /&gt;
2.Then add this in your layout so that you can show it in your view&lt;br /&gt;
3.If you have one form where you want to show this then you can create one more html view in that view only of any name&lt;br /&gt;
4.Then you have to create one link tag &amp;lt;a class = &quot;get_popup&quot; href=&quot;controllername/methodname/id&quot;&amp;gt;&lt;br /&gt;
here you have to create one method in your controller which will call by you when you click this link&lt;br /&gt;
5&amp;lt;script&amp;gt;&lt;br /&gt;$(document).ready(function() {&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //it is using for showing popup &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $(&quot;a.get_popup&quot;).fancybox({&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;width&#39;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &#39;75%&#39;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;height&#39;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &#39;75%&#39;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;autoScale&#39;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : false,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;transitionIn&#39;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &#39;none&#39;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;transitionOut&#39;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &#39;none&#39;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#39;type&#39;&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; : &#39;iframe&#39;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;br /&gt;&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;this is jquery function which you have to wright on top of your&amp;nbsp; application&amp;nbsp; &lt;br /&gt;
&lt;br /&gt;
6.Here which popup i was showing it is made in html so and class name is get_popup .so you have to remember that when you will make your view at that time that name should be same.&lt;br /&gt;
7.you can also send id by &amp;lt;a &amp;gt; tag but at that time you have to catch id in jquery&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/3262548569314348177/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/05/creating-popup-box-in-rails-through.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/3262548569314348177'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/3262548569314348177'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/05/creating-popup-box-in-rails-through.html' title='Creating popup box in rails through jquery'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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/AVvXsEh5N5mzblZIzga8rBT0Lbg9LzYcZH5Ms3d7GlCC4qFW3hZoPSVN-hf5dPWPM7o9nq236ajkg5dplePh3r3WfgWNSQgEHc7iFy3k8Lc8rNuacyeq5giAcbRPgRq_BVssuLxGNUyqopcHN5g/s72-c/Screenshot-1.png" height="72" width="72"/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4112751891986525508.post-8633768935032265879</id><published>2012-05-25T19:07:00.000+05:30</published><updated>2012-05-25T19:07:26.818+05:30</updated><title type='text'>array inside the array probleam</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
In rails if you got array inside the array and some empty array inside that then it will give probleam to show that data&lt;br /&gt;
&lt;br /&gt;
ex a = [1,3,4,[],3,[]]&lt;br /&gt;
for making one single array removing inner empty arrray then use &quot;flatten&quot;&lt;br /&gt;
&lt;br /&gt;
and for compleat changes you have to use &quot;flatten! &quot;&lt;br /&gt;
a.flatten!&lt;br /&gt;
puts a&lt;br /&gt;
o/p :[1,2,3]&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/8633768935032265879/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/05/array-inside-array-probleam.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/8633768935032265879'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/8633768935032265879'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/05/array-inside-array-probleam.html' title='array inside the array probleam'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-6713579006323205827</id><published>2012-05-24T19:33:00.001+05:30</published><updated>2012-05-24T19:33:24.719+05:30</updated><title type='text'></title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
today i was working on project and i got one error but my project was working properly....the error on &quot;Where&quot; method which is use to find something which would full fill the condition which is in side the Where .&lt;br /&gt;
Ex:&lt;br /&gt;
my code was&lt;br /&gt;
&amp;nbsp; @restaurant = Restaurant.where(getresid(session[:admin_id]))&lt;br /&gt;
&amp;nbsp;it was working here getresid is the private method which changes the admin id into restaurant id.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;But right code was @restaurant = Restaurant.where(:restaurant_id=&amp;gt;getresid(session[:admin_id]))&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/6713579006323205827/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/05/twoday-i-was-working-on-project-and-i.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/6713579006323205827'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/6713579006323205827'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/05/twoday-i-was-working-on-project-and-i.html' title=''/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-8713218831977818429</id><published>2012-05-23T19:50:00.000+05:30</published><updated>2012-05-23T19:50:18.950+05:30</updated><title type='text'></title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
today i was just working and i saw in rails it is very easy to maintain relation between two database and also the power of association&lt;br /&gt;
&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; but still due to call back twoday i could not understand why when i am using the javascript for making my page dynamic session is destroying&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/8713218831977818429/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/05/today-i-was-just-working-and-i-saw-in.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/8713218831977818429'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/8713218831977818429'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/05/today-i-was-just-working-and-i-saw-in.html' title=''/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-6923349929684468537</id><published>2012-04-13T19:13:00.002+05:30</published><updated>2012-04-13T19:13:45.720+05:30</updated><title type='text'>How you can youse git in ruby</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;pre&gt;== Git Library for Ruby

Library for using Git in Ruby. Test.

= Homepage

Git public hosting of the project source code is at:

&lt;a href=&quot;http://github.com/schacon/ruby-git&quot;&gt;http://github.com/schacon/ruby-git&lt;/a&gt;

= Install

You can install Ruby/Git like this:

$ sudo gem install git

= Major Objects

Git::Base - this is the object returned from a Git.open or Git.clone.  
Most major actions are called from this object.

Git::Object - this is the base object for your tree, blob and commit objects,
returned from @git.gtree or @git.object calls.  the Git::AbstractObject will
have most of the calls in common for all those objects.

Git::Diff - returns from a @git.diff command.  It is an Enumerable that returns
Git::Diff:DiffFile objects from which you can get per file patches and insertion/deletion
statistics.  You can also get total statistics from the Git::Diff object directly.

Git::Status - returns from a @git.status command.  It is an Enumerable that returns
Git:Status::StatusFile objects for each object in git, which includes files in the working
directory, in the index and in the repository.  Similar to running &#39;git status&#39; on the command
line to determine untracked and changed files.

Git::Branches - Enumerable object that holds Git::Branch objects.  You can call .local or .remote
on it to filter to just your local or remote branches.

Git::Remote - A reference to a remote repository that is tracked by this repository.

Git::Log - An Enumerable object that references all the Git::Object::Commit objects that encompass
your log query, which can be constructed through methods on the Git::Log object, like:

 @git.log(20).object(&quot;some_file&quot;).since(&quot;2 weeks ago&quot;).between(&#39;v2.6&#39;, &#39;v2.7&#39;).each { |commit| [block] } 

= Examples

Here are a bunch of examples of how to use the Ruby/Git package. 

First you have to remember to require rubygems if it&#39;s not.  Then include the &#39;git&#39; gem.

   require &#39;rubygems&#39;
   require &#39;git&#39;

Here are the operations that need read permission only.
      
   g = Git.open (working_dir, :log =&amp;gt; Logger.new(STDOUT))
   
   g.index
   g.index.readable?
   g.index.writable?
   g.repo
   g.dir
   
   g.log   # returns array of Git::Commit objects
   g.log.since(&#39;2 weeks ago&#39;)
   g.log.between(&#39;v2.5&#39;, &#39;v2.6&#39;)
   g.log.each {|l| puts l.sha }
   g.gblob(&#39;v2.5:Makefile&#39;).log.since(&#39;2 weeks ago&#39;)
   
   g.object(&#39;HEAD^&#39;).to_s  # git show / git rev-parse
   g.object(&#39;HEAD^&#39;).contents
   g.object(&#39;v2.5:Makefile&#39;).size
   g.object(&#39;v2.5:Makefile&#39;).sha
   
   g.gtree(treeish)
   g.gblob(treeish)
   g.gcommit(treeish)
   
   
   commit = g.gcommit(&#39;1cc8667014381&#39;)
    commit.gtree
    commit.parent.sha
    commit.parents.size
    commit.author.name
    commit.author.email
    commit.author.date.strftime(&quot;%m-%d-%y&quot;)
    commit.committer.name
    commit.date.strftime(&quot;%m-%d-%y&quot;)
    commit.message
   
  tree = g.gtree(&quot;HEAD^{tree}&quot;)
    tree.blobs
    tree.subtrees
    tree.children # blobs and subtrees
   
   g.revparse(&#39;v2.5:Makefile&#39;)
   
   g.branches # returns Git::Branch objects
   g.branches.local
   g.branches.remote
   g.branches[:master].gcommit
   g.branches[&#39;origin/master&#39;].gcommit
   
   g.grep(&#39;hello&#39;)  # implies HEAD
   g.blob(&#39;v2.5:Makefile&#39;).grep(&#39;hello&#39;)
   g.tag(&#39;v2.5&#39;).grep(&#39;hello&#39;, &#39;docs/&#39;)
   
   g.diff(commit1, commit2).size
   g.diff(commit1, commit2).stats
   g.gtree(&#39;v2.5&#39;).diff(&#39;v2.6&#39;).insertions
   g.diff(&#39;gitsearch1&#39;, &#39;v2.5&#39;).path(&#39;lib/&#39;)
   g.diff(&#39;gitsearch1&#39;, @git.gtree(&#39;v2.5&#39;))
   g.diff(&#39;gitsearch1&#39;, &#39;v2.5&#39;).path(&#39;docs/&#39;).patch
   g.gtree(&#39;v2.5&#39;).diff(&#39;v2.6&#39;).patch
   
   g.gtree(&#39;v2.5&#39;).diff(&#39;v2.6&#39;).each do |file_diff|
     puts file_diff.path
     puts file_diff.patch
     puts file_diff.blob(:src).contents
   end
   
   g.config(&#39;user.name&#39;)  # returns &#39;Scott Chacon&#39;
   g.config # returns whole config hash
   
   g.tag # returns array of Git::Tag objects
   
   
   
And here are the operations that will need to write to your git repository.
   
   
   g = Git.init
     Git.init(&#39;project&#39;)
     Git.init(&#39;/home/schacon/proj&#39;, 
     { :git_dir =&amp;gt; &#39;/opt/git/proj.git&#39;, 
       :index_file =&amp;gt; &#39;/tmp/index&#39;} )
    
   g = Git.clone(URI, :name =&amp;gt; &#39;name&#39;, :path =&amp;gt; &#39;/tmp/checkout&#39;)   
   g.config(&#39;user.name&#39;, &#39;Scott Chacon&#39;)
   g.config(&#39;user.email&#39;, &#39;&lt;a href=&quot;mailto:email@email.com&quot;&gt;email@email.com&lt;/a&gt;&#39;)      
   
   g.add(&#39;.&#39;)
   g.add([file1, file2])
   
   g.remove(&#39;file.txt&#39;)
   g.remove([&#39;file.txt&#39;, &#39;file2.txt&#39;])
       
   g.commit(&#39;message&#39;)
   g.commit_all(&#39;message&#39;)
   
   g = Git.clone(repo, &#39;myrepo&#39;)
   g.chdir do
    new_file(&#39;test-file&#39;, &#39;blahblahblah&#39;)
    g.status.changed.each do |file|
     puts file.blob(:index).contents
    end
   end
   
   g.reset # defaults to HEAD
   g.reset_hard(Git::Commit)
   
   g.branch(&#39;new_branch&#39;) # creates new or fetches existing
   g.branch(&#39;new_branch&#39;).checkout
   g.branch(&#39;new_branch&#39;).delete
   g.branch(&#39;existing_branch&#39;).checkout
   
   g.checkout(&#39;new_branch&#39;)
   g.checkout(g.branch(&#39;new_branch&#39;))
   
   g.branch(name).merge(branch2)
   g.branch(branch2).merge  # merges HEAD with branch2
   
   g.branch(name).in_branch(message) { # add files }  # auto-commits
   g.merge(&#39;new_branch&#39;)
   g.merge(&#39;origin/remote_branch&#39;)
   g.merge(g.branch(&#39;master&#39;))
   g.merge([branch1, branch2])
   
   r = g.add_remote(name, uri)  # Git::Remote
   r = g.add_remote(name, Git::Base)  # Git::Remote
   
   g.remotes  # array of Git::Remotes
   g.remote(name).fetch
   g.remote(name).remove
   g.remote(name).merge
   g.remote(name).merge(branch)
   
   g.fetch
   g.fetch(g.remotes.first)
   
   g.pull
   g.pull(Git::Repo, Git::Branch) # fetch and a merge
   
   g.add_tag(&#39;tag_name&#39;) # returns Git::Tag
   
   g.repack

   g.push
   g.push(g.remote(&#39;name&#39;))


Some examples of more low-level index and tree operations

   g.with_temp_index do 

     g.read_tree(tree3) # calls self.index.read_tree
     g.read_tree(tree1, :prefix =&amp;gt; &#39;hi/&#39;)

     c = g.commit_tree(&#39;message&#39;)
     # or #
     t = g.write_tree
     c = g.commit_tree(t, :message =&amp;gt; &#39;message&#39;, :parents =&amp;gt; [sha1, sha2])

     g.branch(&#39;branch_name&#39;).update_ref(c)
     g.update_ref(branch, c)

     g.with_temp_working do # new blank working directory
       g.checkout
       g.checkout(another_index)
       g.commit # commits to temp_index
     end    
   end

   g.set_index(&#39;/path/to/index&#39;)
   
   
   g.with_index(path) do 
     # calls set_index, then switches back after
   end
   
   g.with_working(dir) do
   # calls set_working, then switches back after
   end
   
   g.with_temp_working(dir) do
     g.checkout_index(:prefix =&amp;gt; dir, :path_limiter =&amp;gt; path)
     # do file work
     g.commit # commits to index
   end
   &lt;/pre&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/6923349929684468537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/04/how-you-can-youse-git-in-ruby.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/6923349929684468537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/6923349929684468537'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/04/how-you-can-youse-git-in-ruby.html' title='How you can youse git in ruby'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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-4112751891986525508.post-8466243010809480247</id><published>2012-03-02T10:26:00.000+05:30</published><updated>2012-03-02T10:26:25.404+05:30</updated><title type='text'>Data Structure Interview question1</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;&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Data structure interview question&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;: What is data structure&lt;b&gt;?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Answer&lt;/b&gt;:A data structure is a way of organizing data that 
considers not only the items stored, but also their relationship to each
 other. Advance knowledge about the relationship between data items 
allows designing of efficient algorithms for the manipulation of data.&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Data structure interview question&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;:&lt;b&gt; &lt;/b&gt;List out the areas in which data structures are applied extensively?&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Answer&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;: Ø Compiler Design,&lt;br /&gt;
Ø Operating System,&lt;br /&gt;
Ø Database Management System,&lt;br /&gt;
Ø Statistical analysis package,&lt;br /&gt;
Ø Numerical Analysis,&lt;br /&gt;
Ø Graphics,&lt;br /&gt;
Ø Artificial Intelligence,&lt;br /&gt;
Ø Simulation&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Data structure interview question&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;:What are the major data structures used in the following areas of RDBMS, Network data model &amp;amp; Hierarchical data model.&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Answer&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;: Ø RDBMS – Array (i.e. Array of structures)&lt;br /&gt;
Ø Network data model – Graph&lt;br /&gt;
Ø Hierarchical data model – Trees&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Data structure interview question&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;: &lt;b&gt;If you are using C language to implement the heterogeneous linked list, what pointer type will you use?&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;Answer&lt;/b&gt;: The heterogeneous linked list contains different data 
types in its nodes and we need a link, pointer to connect them. It is 
not possible to use ordinary pointers for this. So we go for void 
pointer. Void pointer is capable of storing pointer to any type as it is
 a generic pointer type.&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Data structure interview question&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;: Minimum number of queues needed to implement the priority queue?&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Answer&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;: Two. One queue is used for actual storing of data and another for storing priorities.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Data structure interview question&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;: What is the data structures used to perform recursion?&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Answer&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;: &lt;/b&gt;Stack.
 Because of its LIFO (Last In First Out) property it remembers its 
‘caller’ so knows whom to return when the function has to return. 
Recursion makes use of system stack for storing the return addresses of 
the function calls. Every recursive function has its equivalent 
iterative (non-recursive) function. Even when such equivalent iterative 
procedures are written, explicit stack is to be used.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot;&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Data structure interview question:&lt;/b&gt;What are the notations used in Evaluation of Arithmetic Expressions using prefix and postfix forms?&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Arial,Helvetica,sans-serif; text-align: justify;&quot;&gt;
&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Answer&lt;/b&gt;:Polish and Reverse Polish notations. &lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Data structure interview question&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;:&lt;/b&gt; Convert the expression ((A + B) * C – (D – E) ^ (F + G)) to equivalent Prefix and Postfix notations. &lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Answer&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;:&lt;/b&gt;&lt;b&gt;Prefix Notation&lt;/b&gt;: ^ - * +ABC - DE + FG &lt;br /&gt;
&lt;b&gt;Postfix Notation&lt;/b&gt;: AB + C * DE - - FG + ^ &lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Data structure interview question&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;:Sorting is not possible by using which of the following methods? &lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Answer&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;:&lt;/b&gt;(a) Insertion &lt;br /&gt;
(b) Selection &lt;br /&gt;
(c) Exchange (bubble sort) &lt;br /&gt;
(d) Deletion &lt;br /&gt;
(d) Deletion. &lt;br /&gt;
Using insertion we can perform insertion sort, using selection we can 
perform selection sort, using exchange we can perform the bubble sort 
(and other similar sorting methods). But no sorting method can be done 
just using deletion. &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Q&lt;/b&gt;:&lt;b&gt;Draw a binary tree with 20 nodes has 21 null branches&lt;/b&gt;? &lt;br /&gt;
&lt;b&gt;Answer&lt;/b&gt;:Let us take a tree with 5 nodes (n=5) &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigMEibXuy8JqS0Z2_Q-PGK1q7FEz_5W6TJ4m0RznvUYx1YVf2XT9HuyFQznWMWpiVfT5leIMJT9nAq6r6pnuHTdC3t1YAZLZGvlqL06xcCr2tP4AnD0RtNT-Txv1-ZGy94hr2lQ2LAfSF4/s1600-h/data+struc.bmp&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEigMEibXuy8JqS0Z2_Q-PGK1q7FEz_5W6TJ4m0RznvUYx1YVf2XT9HuyFQznWMWpiVfT5leIMJT9nAq6r6pnuHTdC3t1YAZLZGvlqL06xcCr2tP4AnD0RtNT-Txv1-ZGy94hr2lQ2LAfSF4/s320/data+struc.bmp&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
It will have only 6 (ie,5+1) null branches. In general, a binary tree with n nodes has exactly n+1 null nodes. &lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;Data structure interview question&lt;/b&gt;&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;b&gt;:&lt;/b&gt; What are the methods available in storing sequential files ? &lt;br /&gt;
&lt;b&gt;Answer&lt;/b&gt;:Ø Straight merging, &lt;br /&gt;
Ø Natural merging, &lt;br /&gt;
Ø Polyphase sort, &lt;br /&gt;
Ø Distribution of Initial runs.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&amp;nbsp;






&lt;span class=&quot;post-author&quot;&gt;
&lt;/span&gt;&lt;span style=&quot;font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/8466243010809480247/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/03/data-structure-interview-question1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/8466243010809480247'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/8466243010809480247'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/03/data-structure-interview-question1.html' title='Data Structure Interview question1'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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/AVvXsEigMEibXuy8JqS0Z2_Q-PGK1q7FEz_5W6TJ4m0RznvUYx1YVf2XT9HuyFQznWMWpiVfT5leIMJT9nAq6r6pnuHTdC3t1YAZLZGvlqL06xcCr2tP4AnD0RtNT-Txv1-ZGy94hr2lQ2LAfSF4/s72-c/data+struc.bmp" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4112751891986525508.post-1130323228309371412</id><published>2012-03-01T21:30:00.000+05:30</published><updated>2012-03-01T21:30:22.668+05:30</updated><title type='text'>c basic question</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div class=&quot;tech-div&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; color: #444444; font-family: Verdana, Arial; font-size: 12px; padding-bottom: 5px; padding-top: 5px;&quot;&gt;
&lt;div class=&quot;tech-question ib-green&quot; style=&quot;color: #606060; font-weight: bold; line-height: 17px; padding-bottom: 10px;&quot;&gt;
1. What is a local block?&lt;/div&gt;
&lt;div class=&quot;tech-answer&quot; style=&quot;line-height: 17px; padding-left: 30px;&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
A local block is any portion of a C program that is enclosed by the left brace (&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;{&lt;/i&gt;) and the right brace (&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;}&lt;/i&gt;). A C function contains left and right braces, and therefore anything between the two braces is contained in a local block. An&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;if&lt;/i&gt;&amp;nbsp;statement or a&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;switch&lt;/i&gt;&amp;nbsp;statement can also contain braces, so the portion of code between these two braces would be considered a local block.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Additionally, you might want to create your own local block without the aid of a C function or keyword construct. This is perfectly legal. Variables can be declared within local blocks, but they must be declared only at the beginning of a local block. Variables declared in this manner are visible only within the local block. Duplicate variable names declared within a local block take precedence over variables with the same name declared outside the local block. Here is an example of a program that uses local blocks:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;
&lt;span class=&quot;preprocessor&quot; style=&quot;color: #949494; font-weight: bold;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; main(&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;);
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; main()
{
     &lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* Begin local block for function main() */&lt;/span&gt;
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; test_var = &lt;span class=&quot;number&quot;&gt;10&lt;/span&gt;;
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Test variable before the if statement: %d\n&quot;&lt;/span&gt;, test_var);
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (test_var &amp;gt; &lt;span class=&quot;number&quot;&gt;5&lt;/span&gt;)
     {
          &lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* Begin local block for &quot;if&quot; statement */&lt;/span&gt;
          &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; test_var = &lt;span class=&quot;number&quot;&gt;5&lt;/span&gt;;
          printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Test variable within the if statement: %d\n&quot;&lt;/span&gt;,
                 test_var);
          {
               &lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* Begin independent local block (not tied to
                  any function or keyword) */&lt;/span&gt;
               &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; test_var = &lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;;
               printf(
               &lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Test variable within the independent local block:%d\n&quot;&lt;/span&gt;,
               test_var);
          }
          &lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* End independent local block */&lt;/span&gt;
     }
     &lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* End local block for &quot;if&quot; statement */&lt;/span&gt;
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Test variable after the if statement: %d\n&quot;&lt;/span&gt;, test_var);
}
&lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* End local block for function main() */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
This example program produces the following output:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Test variable before the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;if&lt;/i&gt;&amp;nbsp;statement: 10&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Test variable within the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;if&lt;/i&gt;&amp;nbsp;statement: 5&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Test variable within the independent local block: 0&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Test variable after the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;if&lt;/i&gt;&amp;nbsp;statement: 10&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Notice that as each test_var was defined, it took precedence over the previously defined&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;test_var&lt;/i&gt;. Also notice that when the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;if&lt;/i&gt;&amp;nbsp;statement local block had ended, the program had reentered the scope of the original&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;test_var&lt;/i&gt;, and its value was 10.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;tech-div&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; color: #444444; font-family: Verdana, Arial; font-size: 12px; padding-bottom: 5px; padding-top: 5px;&quot;&gt;
&lt;div class=&quot;tech-question ib-green&quot; style=&quot;color: #606060; font-weight: bold; line-height: 17px; padding-bottom: 10px;&quot;&gt;
2. Should variables be stored in local blocks?&lt;/div&gt;
&lt;div class=&quot;tech-answer&quot; style=&quot;line-height: 17px; padding-left: 30px;&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
The use of local blocks for storing variables is unusual and therefore should be avoided, with only rare exceptions. One of these exceptions would be for debugging purposes, when you might want to declare a local instance of a global variable to test within your function. You also might want to use a local block when you want to make your program more readable in the current context.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Sometimes having the variable declared closer to where it is used makes your program more readable. However, well-written programs usually do not have to resort to declaring variables in this manner, and you should avoid using local blocks.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;tech-div&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; color: #444444; font-family: Verdana, Arial; font-size: 12px; padding-bottom: 5px; padding-top: 5px;&quot;&gt;
&lt;div class=&quot;tech-question ib-green&quot; style=&quot;color: #606060; font-weight: bold; line-height: 17px; padding-bottom: 10px;&quot;&gt;
3. When is a&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;switch&lt;/i&gt;&amp;nbsp;statement better than multiple&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;if&lt;/i&gt;&amp;nbsp;statements?&lt;/div&gt;
&lt;div class=&quot;tech-answer&quot; style=&quot;line-height: 17px; padding-left: 30px;&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
A&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;switch&lt;/i&gt;&amp;nbsp;statement is generally best to use when you have more than two conditional expressions based on a single variable of numeric type. For instance, rather than the code&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (x == &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;)
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;x is equal to one.\n&quot;&lt;/span&gt;);
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (x == &lt;span class=&quot;number&quot;&gt;2&lt;/span&gt;)
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;x is equal to two.\n&quot;&lt;/span&gt;);
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (x == &lt;span class=&quot;number&quot;&gt;3&lt;/span&gt;)
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;x is equal to three.\n&quot;&lt;/span&gt;);
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;x is not equal to one, two, or three.\n&quot;&lt;/span&gt;);
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
the following code is easier to read and maintain:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;switch&lt;/span&gt; (x)
{
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;:   printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;x is equal to one.\n&quot;&lt;/span&gt;);
                    &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;number&quot;&gt;2&lt;/span&gt;:   printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;x is equal to two.\n&quot;&lt;/span&gt;);
                    &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;number&quot;&gt;3&lt;/span&gt;:   printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;x is equal to three.\n&quot;&lt;/span&gt;);
                    &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;default&lt;/span&gt;:  printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;x is not equal to one, two, or three.\n&quot;&lt;/span&gt;);
                    &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Notice that for this method to work, the conditional expression must be based on a variable of numeric type in order to use the switch statement. Also, the conditional expression must be based on a single variable. For instance, even though the following&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;if&lt;/i&gt;&amp;nbsp;statement contains more than two conditions, it is not a candidate for using a&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;switch&lt;/i&gt;&amp;nbsp;statement because it is based on string comparisons and not numeric comparisons:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;* name = &lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Lupto&quot;&lt;/span&gt;;
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (!stricmp(name, &lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Isaac&quot;&lt;/span&gt;))
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Your name means &#39;Laughter&#39;.\n&quot;&lt;/span&gt;);
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (!stricmp(name, &lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Amy&quot;&lt;/span&gt;))
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Your name means &#39;Beloved&#39;.\n &quot;&lt;/span&gt;);
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (!stricmp(name, &lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Lloyd&quot;&lt;/span&gt;))
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Your name means &#39;Mysterious&#39;.\n &quot;&lt;/span&gt;);
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;I haven&#39;t a clue as to what your name means.\n&quot;&lt;/span&gt;);
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;tech-div&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; color: #444444; font-family: Verdana, Arial; font-size: 12px; padding-bottom: 5px; padding-top: 5px;&quot;&gt;
&lt;div class=&quot;tech-question ib-green&quot; style=&quot;color: #606060; font-weight: bold; line-height: 17px; padding-bottom: 10px;&quot;&gt;
4. Is a default case necessary in a&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;switch&lt;/i&gt;&amp;nbsp;statement?&lt;/div&gt;
&lt;div class=&quot;tech-answer&quot; style=&quot;line-height: 17px; padding-left: 30px;&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
No, but it is not a bad idea to put&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;default&lt;/i&gt;&amp;nbsp;statements in&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;switch&lt;/i&gt;&amp;nbsp;statements for error- or logic-checking purposes. For instance, the following switch statement is perfectly normal:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;switch&lt;/span&gt; (char_code)
{
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&#39;Y&#39;&lt;/span&gt;:
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&#39;y&#39;&lt;/span&gt;: printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;You answered YES!\n&quot;&lt;/span&gt;);
               &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&#39;N&#39;&lt;/span&gt;:
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;case&lt;/span&gt; &lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&#39;n&#39;&lt;/span&gt;: printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;You answered NO!\n&quot;&lt;/span&gt;);
               &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Consider, however, what would happen if an unknown character code were passed to this&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;switch&lt;/i&gt;&amp;nbsp;statement. The program would not print anything. It would be a good idea, therefore, to insert a&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;default&lt;/i&gt;&amp;nbsp;case where this condition would be taken care of:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;...
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;default&lt;/span&gt;:  printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Unknown response: %d\n&quot;&lt;/span&gt;, char_code);
               &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
...
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Additionally,&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;default&lt;/i&gt;&amp;nbsp;cases come in handy for logic checking. For instance, if your&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;switch&lt;/i&gt;&amp;nbsp;statement handled a fixed number of conditions and you considered any value outside those conditions to be a logic error, you could insert a&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;default&lt;/i&gt;&amp;nbsp;case which would flag that condition. Consider the following example:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; move_cursor(&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; direction)
{
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;switch&lt;/span&gt; (direction)
     {
          &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;case&lt;/span&gt; UP:     cursor_up();
                       &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
          &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;case&lt;/span&gt; DOWN:   cursor_down();
                       &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
          &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;case&lt;/span&gt; LEFT:   cursor_left();
                       &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
          &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;case&lt;/span&gt; RIGHT:  cursor_right();
                       &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
          &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;default&lt;/span&gt;:     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Logic error on line number %ld!!!\n&quot;&lt;/span&gt;,
                               __LINE__);
                       &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
     }
}&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;
&lt;div class=&quot;tech-div&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; color: #444444; font-family: Verdana, Arial; font-size: 12px; line-height: normal; padding-bottom: 5px; padding-top: 5px; white-space: normal;&quot;&gt;
&lt;div class=&quot;tech-question ib-green&quot; style=&quot;color: #606060; font-weight: bold; line-height: 17px; padding-bottom: 10px;&quot;&gt;
5. Can the last case of a&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;switch&lt;/i&gt;&amp;nbsp;statement skip including the break?&lt;/div&gt;
&lt;div class=&quot;tech-answer&quot; style=&quot;line-height: 17px; padding-left: 30px;&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Even though the last case of a switch statement does not require a break statement at the end, you should add&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;break&lt;/i&gt;&amp;nbsp;statements to all cases of the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;switch&lt;/i&gt;&amp;nbsp;statement, including the last case. You should do so primarily because your program has a strong chance of being maintained by someone other than you who might add cases but neglect to notice that the last case has no&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;break&lt;/i&gt;&amp;nbsp;statement.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
This oversight would cause what would formerly be the last case statement to &quot;fall through&quot; to the new statements added to the bottom of the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;switch&lt;/i&gt;&amp;nbsp;statement. Putting a&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;break&lt;/i&gt;&amp;nbsp;after each case statement would prevent this possible mishap and make your program more &quot;bulletproof.&quot; Besides, most of today&#39;s optimizing compilers will optimize out the last break, so there will be no performance degradation if you add it.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;tech-div&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; color: #444444; font-family: Verdana, Arial; font-size: 12px; line-height: normal; padding-bottom: 5px; padding-top: 5px; white-space: normal;&quot;&gt;
&lt;div class=&quot;tech-question ib-green&quot; style=&quot;color: #606060; font-weight: bold; line-height: 17px; padding-bottom: 10px;&quot;&gt;
6. Other than in a&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;for&lt;/i&gt;&amp;nbsp;statement, when is the comma operator used?&lt;/div&gt;
&lt;div class=&quot;tech-answer&quot; style=&quot;line-height: 17px; padding-left: 30px;&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
The comma operator is commonly used to separate variable declarations, function arguments, and expressions, as well as the elements of a for statement. Look closely at the following program, which shows some of the many ways a comma can be used:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;preprocessor&quot; style=&quot;color: #949494; font-weight: bold;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;preprocessor&quot; style=&quot;color: #949494; font-weight: bold;&quot;&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; main(&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;);
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; main()
{
     &lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* Here, the comma operator is used to separate
        three variable declarations. */&lt;/span&gt;
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i, j, k;
     &lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* Notice how you can use the comma operator to perform
        multiple initializations on the same line. */&lt;/span&gt;
     i = &lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;, j = &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;, k = &lt;span class=&quot;number&quot;&gt;2&lt;/span&gt;;
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;i = %d, j = %d, k = %d\n&quot;&lt;/span&gt;, i, j, k);
     &lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* Here, the comma operator is used to execute three expressions
        in one line: assign k to i, increment j, and increment k.
        The value that i receives is always the rightmost expression. */&lt;/span&gt;
     i = (j++, k++);
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;i = %d, j = %d, k = %d\n&quot;&lt;/span&gt;, i, j, k);
     &lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* Here, the while statement uses the comma operator to
        assign the value of i as well as test it. */&lt;/span&gt;
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;while&lt;/span&gt; (i = (rand() % &lt;span class=&quot;number&quot;&gt;100&lt;/span&gt;), i != &lt;span class=&quot;number&quot;&gt;50&lt;/span&gt;)
          printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;i is %d, trying again...\n&quot;&lt;/span&gt;, i);
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;\nGuess what? i is 50!\n&quot;&lt;/span&gt;);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Notice the line that reads&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;i = (j++, k++);&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
This line actually performs three actions at once. These are the three actions, in order:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
1. Assigns the value of&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;k&lt;/i&gt;&amp;nbsp;to&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;i&lt;/i&gt;. This happens because the left value (&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;lvalue&lt;/i&gt;) always evaluates to the rightmost argument. In this case, it evaluates to&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;k&lt;/i&gt;. Notice that it does not evaluate to&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;k++&lt;/i&gt;, because&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;k++&lt;/i&gt;&amp;nbsp;is a postfix incremental expression, and&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;k&lt;/i&gt;&amp;nbsp;is not incremented until the assignment of&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;k&lt;/i&gt;&amp;nbsp;to&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;i&lt;/i&gt;&amp;nbsp;is made. If the expression had read&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;++k&lt;/i&gt;, the value of&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;++k&lt;/i&gt;&amp;nbsp;would be assigned to&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;i&lt;/i&gt;&amp;nbsp;because it is a prefix incremental expression, and it is incremented before the assignment is made.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
2. Increments&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;j&lt;/i&gt;.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
3. Increments&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;k&lt;/i&gt;.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Also, notice the strange-looking while statement:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;while&lt;/span&gt; (i = (rand() % &lt;span class=&quot;number&quot;&gt;100&lt;/span&gt;), i != &lt;span class=&quot;number&quot;&gt;50&lt;/span&gt;)
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;i is %d, trying again...\n&quot;&lt;/span&gt;);
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Here, the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;comma&lt;/i&gt;&amp;nbsp;operator separates two expressions, each of which is evaluated for each iteration of the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;while&lt;/i&gt;statement. The first expression, to the left of the comma, assigns&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;i&lt;/i&gt;&amp;nbsp;to a random number from 0 to 99.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
The second expression, which is more commonly found in a&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;while&lt;/i&gt;&amp;nbsp;statement, is a conditional expression that tests to see whether&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;i&lt;/i&gt;&amp;nbsp;is not equal to 50. For each iteration of the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;while&lt;/i&gt;&amp;nbsp;statement,&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;i&lt;/i&gt;&amp;nbsp;is assigned a new random number, and the value of&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;i&lt;/i&gt;&amp;nbsp;is checked to see that it is not 50. Eventually,&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;i&lt;/i&gt;&amp;nbsp;is randomly assigned the value 50, and the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;while&lt;/i&gt;&amp;nbsp;statement terminates.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;tech-div&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; color: #444444; font-family: Verdana, Arial; font-size: 12px; line-height: normal; padding-bottom: 5px; padding-top: 5px; white-space: normal;&quot;&gt;
&lt;div class=&quot;tech-question ib-green&quot; style=&quot;color: #606060; font-weight: bold; line-height: 17px; padding-bottom: 10px;&quot;&gt;
7. How can you tell whether a loop ended prematurely?&lt;/div&gt;
&lt;div class=&quot;tech-answer&quot; style=&quot;line-height: 17px; padding-left: 30px;&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Generally, loops are dependent on one or more variables. Your program can check those variables outside the loop to ensure that the loop executed properly. For instance, consider the following example:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;preprocessor&quot; style=&quot;color: #949494; font-weight: bold;&quot;&gt;#define REQUESTED_BLOCKS 512&lt;/span&gt;
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x;
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;* cp[REQUESTED_BLOCKS];
&lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* Attempt (in vain, I must add...) to
   allocate 512 10KB blocks in memory. */&lt;/span&gt;
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; (x=&lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;; x&amp;lt; REQUESTED_BLOCKS; x++)
{
     cp[x] = (&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;*) malloc(&lt;span class=&quot;number&quot;&gt;10000&lt;/span&gt;, &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;);
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (cp[x] == (&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;char&lt;/span&gt;*) NULL)
          &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;break&lt;/span&gt;;
}
&lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* If x is less than REQUESTED_BLOCKS,
   the loop has ended prematurely. */&lt;/span&gt;
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (x &amp;lt; REQUESTED_BLOCKS)
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Bummer! My loop ended prematurely!\n&quot;&lt;/span&gt;);
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Notice that for the loop to execute successfully, it would have had to iterate through 512 times. Immediately following the loop, this condition is tested to see whether the loop ended prematurely. If the variable&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;x&lt;/i&gt;&amp;nbsp;is anything less than 512, some error has occurred.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;tech-div&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; color: #444444; font-family: Verdana, Arial; font-size: 12px; line-height: normal; padding-bottom: 5px; padding-top: 5px; white-space: normal;&quot;&gt;
&lt;div class=&quot;tech-question ib-green&quot; style=&quot;color: #606060; font-weight: bold; line-height: 17px; padding-bottom: 10px;&quot;&gt;
8. What is the difference between&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;goto&lt;/i&gt;&amp;nbsp;and long&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;jmp( )&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;setjmp()&lt;/i&gt;?&lt;/div&gt;
&lt;div class=&quot;tech-answer&quot; style=&quot;line-height: 17px; padding-left: 30px;&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
A&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;goto&lt;/i&gt;&amp;nbsp;statement implements a local jump of program execution, and the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;longjmp()&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;setjmp()&lt;/i&gt;&amp;nbsp;functions implement a nonlocal, or far, jump of program execution. Generally, a jump in execution of any kind should be avoided because it is not considered good programming practice to use such statements as&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;goto&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;longjmp&lt;/i&gt;in your program.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
A&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;goto&lt;/i&gt;&amp;nbsp;statement simply bypasses code in your program and jumps to a predefined position. To use the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;goto&lt;/i&gt;statement, you give it a labeled position to jump to. This predefined position must be within the same function. You cannot implement gotos between functions. Here is an example of a goto statement:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; bad_programmers_function(&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;)
{
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x;
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Excuse me while I count to 5000...\n&quot;&lt;/span&gt;);
     x = &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;;
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;while&lt;/span&gt; (&lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;)
     {
          printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;, x);
          &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (x == &lt;span class=&quot;number&quot;&gt;5000&lt;/span&gt;)
               &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;goto&lt;/span&gt; all_done;
          &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;
               x = x + &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;;
     }
all_done:
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Whew! That wasn&#39;t so bad, was it?\n&quot;&lt;/span&gt;);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
This example could have been written much better, avoiding the use of a&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;goto&lt;/i&gt;&amp;nbsp;statement. Here is an example of an improved implementation:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; better_function(&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;)
{
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x;
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Excuse me while I count to 5000...\n&quot;&lt;/span&gt;);
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; (x=&lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;; x&amp;lt;=&lt;span class=&quot;number&quot;&gt;5000&lt;/span&gt;; x++)
          printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;%d\n&quot;&lt;/span&gt;, x);
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;Whew! That wasn&#39;t so bad, was it?\n&quot;&lt;/span&gt;);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
As previously mentioned, the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;longjmp()&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;setjmp()&lt;/i&gt;&amp;nbsp;functions implement a nonlocal&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;goto&lt;/i&gt;. When your program calls&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;setjmp()&lt;/i&gt;, the current state of your program is saved in a structure of type&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;jmp_buf&lt;/i&gt;. Later, your program can call the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;longjmp()&lt;/i&gt;&amp;nbsp;function to restore the program&#39;s state as it was when you called&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;setjmp()&lt;/i&gt;. Unlike the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;goto&lt;/i&gt;&amp;nbsp;statement, the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;longjmp()&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;setjmp()&lt;/i&gt;&amp;nbsp;functions do not need to be implemented in the same function.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
However, there is a major drawback to using these functions: your program, when restored to its previously saved state, will lose its references to any dynamically allocated memory between the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;longjmp()&lt;/i&gt;&amp;nbsp;and the&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;setjmp()&lt;/i&gt;. This means you will waste memory for every&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;malloc()&lt;/i&gt;&amp;nbsp;or&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;calloc()&lt;/i&gt;&amp;nbsp;you have implemented between your&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;longjmp()&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;setjmp()&lt;/i&gt;, and your program will be horribly inefficient. It is highly recommended that you avoid using functions such as&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;longjmp()&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;setjmp()&lt;/i&gt;&amp;nbsp;because they, like the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;goto&lt;/i&gt;&amp;nbsp;statement, are quite often an indication of poor programming practice.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Here is an example of the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;longjmp()&lt;/i&gt;&amp;nbsp;and&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;setjmp()&lt;/i&gt;&amp;nbsp;functions:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;preprocessor&quot; style=&quot;color: #949494; font-weight: bold;&quot;&gt;#include &amp;lt;stdio.h&amp;gt;&lt;/span&gt;
&lt;span class=&quot;preprocessor&quot; style=&quot;color: #949494; font-weight: bold;&quot;&gt;#include &amp;lt;setjmp.h&amp;gt;&lt;/span&gt;
jmp_buf saved_state;
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; main(&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;);
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; call_longjmp(&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;);
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; main(&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;)
{
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; ret_code;
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;The current state of the program is being saved...\n&quot;&lt;/span&gt;);
     ret_code = setjmp(saved_state);
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; (ret_code == &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;)
     {
          printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;The longjmp function has been called.\n&quot;&lt;/span&gt;);
          printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;The program&#39;s previous state has been restored.\n&quot;&lt;/span&gt;);
          exit(&lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;);
     }
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;I am about to call longjmp and\n&quot;&lt;/span&gt;);
     printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;return to the previous program state...\n&quot;&lt;/span&gt;);
     call_longjmp();
}
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt; call_longjmp(&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;void&lt;/span&gt;)
{
     longjmp(saved_state, &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;);
&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/code&gt;
&lt;div class=&quot;tech-div&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; font-family: Verdana, Arial; line-height: normal; padding-bottom: 5px; padding-top: 5px; white-space: normal;&quot;&gt;
&lt;div class=&quot;tech-question ib-green&quot; style=&quot;color: #606060; font-weight: bold; line-height: 17px; padding-bottom: 10px;&quot;&gt;
9. What is an&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;lvalue&lt;/i&gt;?&lt;/div&gt;
&lt;div class=&quot;tech-answer&quot; style=&quot;line-height: 17px; padding-left: 30px;&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
An&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;lvalue&lt;/i&gt;&amp;nbsp;is an expression to which a value can be assigned. The&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;lvalue&lt;/i&gt;&amp;nbsp;expression is located on the left side of an assignment statement, whereas an&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;rvalue&lt;/i&gt;&amp;nbsp;is located on the right side of an assignment statement. Each assignment statement must have an&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;lvalue&lt;/i&gt;&amp;nbsp;and an&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;rvalue&lt;/i&gt;. The&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;lvalue&lt;/i&gt;&amp;nbsp;expression must reference a storable variable in memory. It cannot be a constant. For instance, the following lines show a few examples of lvalues:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x;
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt;* p_int;
x = &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;;
*p_int = &lt;span class=&quot;number&quot;&gt;5&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
The variable&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;x&lt;/i&gt;&amp;nbsp;is an integer, which is a storable location in memory. Therefore, the statement&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;x = 1&lt;/i&gt;&amp;nbsp;qualifies&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;x&lt;/i&gt;to be an&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;lvalue&lt;/i&gt;. Notice the second assignment statement,&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;*p_int = 5&lt;/i&gt;. By using the * modifier to reference the area of memory that&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;p_int&lt;/i&gt;&amp;nbsp;points to,&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;*p_int&lt;/i&gt;&amp;nbsp;is qualified as an&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;lvalue&lt;/i&gt;. In contrast, here are a few examples of what would not be considered lvalues:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;preprocessor&quot; style=&quot;color: #949494; font-weight: bold;&quot;&gt;#define CONST_VAL 10&lt;/span&gt;
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x;
&lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* example 1 */&lt;/span&gt;
&lt;span class=&quot;number&quot;&gt;1&lt;/span&gt; = x;
&lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* example 2 */&lt;/span&gt;
CONST_VAL = &lt;span class=&quot;number&quot;&gt;5&lt;/span&gt;;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
In both statements, the left side of the statement evaluates to a constant value that cannot be changed because constants do not represent storable locations in memory. Therefore, these two assignment statements do not contain lvalues and will be flagged by your compiler as errors.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;tech-div&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; font-family: Verdana, Arial; line-height: normal; padding-bottom: 5px; padding-top: 5px; white-space: normal;&quot;&gt;
&lt;div class=&quot;tech-question ib-green&quot; style=&quot;color: #606060; font-weight: bold; line-height: 17px; padding-bottom: 10px;&quot;&gt;
10. Can an array be an&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;lvalue&lt;/i&gt;?&lt;/div&gt;
&lt;div class=&quot;tech-answer&quot; style=&quot;line-height: 17px; padding-left: 30px;&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Is an array an expression to which we can assign a value? The answer to this question is no, because an array is composed of several separate array elements that cannot be treated as a whole for assignment purposes. The following statement is therefore illegal:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;int x[5], y[5];&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;x = y;&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
You could, however, use a&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;for&lt;/i&gt;&amp;nbsp;loop to iterate through each element of the array and assign values individually, such as in this example:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; i;
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x[&lt;span class=&quot;number&quot;&gt;5&lt;/span&gt;];
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; y[&lt;span class=&quot;number&quot;&gt;5&lt;/span&gt;];
...
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; (i=&lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;; i&amp;lt;&lt;span class=&quot;number&quot;&gt;5&lt;/span&gt;; i++)
     x[i] = y[i]
...
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Additionally, you might want to copy the whole array all at once. You can do so using a library function such as the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;memcpy()&lt;/i&gt;&amp;nbsp;function, which is shown here:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;memcpy(x, y, sizeof(y));&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
It should be noted here that unlike arrays, structures can be treated as lvalues. Thus, you can assign one structure variable to another structure variable of the same type, such as this:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;typedef&lt;/span&gt; &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;struct&lt;/span&gt; t_name
{
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;char&lt;/span&gt; last_name[&lt;span class=&quot;number&quot;&gt;25&lt;/span&gt;];
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;char&lt;/span&gt; first_name[&lt;span class=&quot;number&quot;&gt;15&lt;/span&gt;];
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;char&lt;/span&gt; middle_init[&lt;span class=&quot;number&quot;&gt;2&lt;/span&gt;];
} NAME;
...
NAME my_name, your_name;
...
your_name = my_name;
...
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
In the preceding example, the entire contents of the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;my_name&lt;/i&gt;&amp;nbsp;structure were copied into the&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;your_name&lt;/i&gt;structure. This is essentially the same as the following line:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;memcpy(your_name, my_name, sizeof(your_name));&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;tech-div&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; font-family: Verdana, Arial; line-height: normal; padding-bottom: 5px; padding-top: 5px; white-space: normal;&quot;&gt;
&lt;div class=&quot;tech-question ib-green&quot; style=&quot;color: #606060; font-weight: bold; line-height: 17px; padding-bottom: 10px;&quot;&gt;
11. What is an&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;rvalue&lt;/i&gt;?&lt;/div&gt;
&lt;div class=&quot;tech-answer&quot; style=&quot;line-height: 17px; padding-left: 30px;&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;rvalue&lt;/i&gt;&amp;nbsp;can be defined as an expression that can be assigned to an&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;lvalue&lt;/i&gt;. The&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;rvalue&lt;/i&gt;&amp;nbsp;appears on the right side of an assignment statement.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Unlike an&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;lvalue&lt;/i&gt;, an&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;rvalue&lt;/i&gt;&amp;nbsp;can be a constant or an expression, as shown here:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x, y;
x = &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;;               &lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* 1 is an rvalue; x is an lvalue */&lt;/span&gt;
y = (x + &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;);         &lt;span class=&quot;comment&quot; style=&quot;color: #009900;&quot;&gt;/* (x + 1) is an rvalue; y is an lvalue */&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
An assignment statement must have both an lvalue and an rvalue. Therefore, the following statement would not compile because it is missing an&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;rvalue&lt;/i&gt;:&lt;/div&gt;
&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;int x; x = void_function_call() /* the function void_function_call() returns nothing */&lt;/i&gt;&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
If the function had returned an integer, it would be considered an rvalue because it evaluates into something that the lvalue, x, can store.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;tech-div&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; font-family: Verdana, Arial; line-height: normal; padding-bottom: 5px; padding-top: 5px; white-space: normal;&quot;&gt;
&lt;div class=&quot;tech-question ib-green&quot; style=&quot;color: #606060; font-weight: bold; line-height: 17px; padding-bottom: 10px;&quot;&gt;
12. Is left-to-right or right-to-left order guaranteed for operator precedence?&lt;/div&gt;
&lt;div class=&quot;tech-answer&quot; style=&quot;line-height: 17px; padding-left: 30px;&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
The simple answer to this question is neither. The C language does not always evaluate left-to-right or right-to-left. Generally, function calls are evaluated first, followed by complex expressions and then simple expressions.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Additionally, most of today&#39;s popular C compilers often rearrange the order in which the expression is evaluated in order to get better optimized code. You therefore should always implicitly define your operator precedence by using parentheses.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
For example, consider the following expression:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;a = b + c/d / function_call() * 5&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
The way this expression is to be evaluated is totally ambiguous, and you probably will not get the results you want. Instead, try writing it by using implicit operator precedence:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;a = b + (((c/d) / function_call()) * 5)&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Using this method, you can be assured that your expression will be evaluated properly and that the compiler will not rearrange operators for optimization purposes.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;tech-div&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; font-family: Verdana, Arial; line-height: normal; padding-bottom: 5px; padding-top: 5px; white-space: normal;&quot;&gt;
&lt;div class=&quot;tech-question ib-green&quot; style=&quot;color: #606060; font-weight: bold; line-height: 17px; padding-bottom: 10px;&quot;&gt;
13. What is the difference between&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;++var&lt;/i&gt;&amp;nbsp;and&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;&amp;nbsp;var++&lt;/i&gt;?&lt;/div&gt;
&lt;div class=&quot;tech-answer&quot; style=&quot;line-height: 17px; padding-left: 30px;&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
The&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;++&lt;/i&gt;&amp;nbsp;operator is called the increment operator. When the operator is placed before the variable (&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;++var&lt;/i&gt;), the variable is incremented by 1 before it is used in the expression. When the operator is placed after the variable (&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;var++&lt;/i&gt;), the expression is evaluated, and then the variable is incremented by 1.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
The same holds true for the decrement operator (&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;--&lt;/i&gt;). When the operator is placed before the variable, you are said to have a prefix operation. When the operator is placed after the variable, you are said to have a postfix operation.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
For instance, consider the following example of postfix incrementation:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x, y;
x = &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;;
y = (x++ * &lt;span class=&quot;number&quot;&gt;5&lt;/span&gt;);
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
In this example, postfix incrementation is used, and&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;x&lt;/i&gt;&amp;nbsp;is not incremented until after the evaluation of the expression is done. Therefore,&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;y&lt;/i&gt;&amp;nbsp;evaluates to 1 times 5, or 5. After the evaluation,&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;x&lt;/i&gt;&amp;nbsp;is incremented to 2.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
Now look at an example using prefix incrementation:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x, y;
x = &lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;;
y = (++x * &lt;span class=&quot;number&quot;&gt;5&lt;/span&gt;);
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
This example is the same as the first one, except that this example uses prefix incrementation rather than postfix. Therefore,&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;x&lt;/i&gt;&amp;nbsp;is incremented before the expression is evaluated, making it 2. Hence,&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;y&lt;/i&gt;&amp;nbsp;evaluates to 2 times 5, or 10.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;tech-div&quot; style=&quot;background-color: white; border-bottom-color: rgb(204, 204, 204); border-bottom-style: dashed; border-bottom-width: 1px; font-family: Verdana, Arial; line-height: normal; padding-bottom: 5px; padding-top: 5px; white-space: normal;&quot;&gt;
&lt;div class=&quot;tech-question ib-green&quot; style=&quot;color: #606060; font-weight: bold; line-height: 17px; padding-bottom: 10px;&quot;&gt;
14. What does the modulus operator do?&lt;/div&gt;
&lt;div class=&quot;tech-answer&quot; style=&quot;line-height: 17px; padding-left: 30px;&quot;&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
The modulus operator (&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;%&lt;/i&gt;) gives the remainder of two divided numbers. For instance, consider the following portion of code:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;x = 15/7&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
If&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;x&lt;/i&gt;&amp;nbsp;were an integer, the resulting value of&amp;nbsp;&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;x&lt;/i&gt;&amp;nbsp;would be 2. However, consider what would happen if you were to apply the modulus operator to the same equation:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;i class=&quot;c-code&quot; style=&quot;color: #dd0000; font-family: &#39;Courier New&#39;; font-size: 13px; font-style: normal;&quot;&gt;x = 15%7&lt;/i&gt;&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
The result of this expression would be the remainder of 15 divided by 7, or 1. This is to say that 15 divided by 7 is 2 with a remainder of 1.&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
The modulus operator is commonly used to determine whether one number is evenly divisible into another. For instance, if you wanted to print every third letter of the alphabet, you would use the following code:&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;pre class=&quot;code-pre&quot; style=&quot;background-color: #f8f8f8; border-bottom-color: rgb(147, 183, 213); border-bottom-style: dashed; border-bottom-width: 1px; border-image: initial; border-left-color: rgb(147, 183, 213); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(147, 183, 213); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(147, 183, 213); border-top-style: dashed; border-top-width: 1px; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px;&quot;&gt;&lt;code class=&quot;cpp&quot; style=&quot;color: #222222; font-family: courier, &#39;courier new&#39;; font-size: 14px;&quot;&gt;&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;int&lt;/span&gt; x;
&lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;for&lt;/span&gt; (x=&lt;span class=&quot;number&quot;&gt;1&lt;/span&gt;; x&amp;lt;=&lt;span class=&quot;number&quot;&gt;26&lt;/span&gt;; x++)
     &lt;span class=&quot;keyword&quot; style=&quot;color: blue;&quot;&gt;if&lt;/span&gt; ((x%&lt;span class=&quot;number&quot;&gt;3&lt;/span&gt;) == &lt;span class=&quot;number&quot;&gt;0&lt;/span&gt;)
          printf(&lt;span class=&quot;string&quot; style=&quot;color: #ee3b3b;&quot;&gt;&quot;%c&quot;&lt;/span&gt;, x+&lt;span class=&quot;number&quot;&gt;64&lt;/span&gt;);
&lt;/code&gt;&lt;/pre&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
&lt;/div&gt;
&lt;div style=&quot;font-family: Verdana, Tahoma, Arial, sans-serif;&quot;&gt;
The preceding example would output the string &quot;cfilorux&quot;, which represents every third letter in the alphabet.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://vyasarvind.blogspot.com/feeds/1130323228309371412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://vyasarvind.blogspot.com/2012/03/c-basic-question.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/1130323228309371412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4112751891986525508/posts/default/1130323228309371412'/><link rel='alternate' type='text/html' href='http://vyasarvind.blogspot.com/2012/03/c-basic-question.html' title='c basic question'/><author><name>Arvind Vyas</name><uri>http://www.blogger.com/profile/10405979139604989428</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></feed>