<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>tail -f findings.out &#187; Ruby</title>
	<atom:link href="http://dancingpenguinsoflight.com/category/programming/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://dancingpenguinsoflight.com</link>
	<description></description>
	<lastBuildDate>Sun, 21 Aug 2011 14:33:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Reminder for mysql rubygem install on Ubuntu</title>
		<link>http://dancingpenguinsoflight.com/2011/01/reminder-for-mysql-rubygem-install-on-ubuntu/</link>
		<comments>http://dancingpenguinsoflight.com/2011/01/reminder-for-mysql-rubygem-install-on-ubuntu/#comments</comments>
		<pubDate>Tue, 04 Jan 2011 03:09:10 +0000</pubDate>
		<dc:creator>Samuel Huckins</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://dancingpenguinsoflight.com/?p=1841</guid>
		<description><![CDATA[Quick easy steps to get up and running with ruby, mysql, sqlite, rails, and most especially the mysql gem on a fresh Ubuntu 10.10 64-bit system: 123456789# mysql and dev packages needed for mysql rubygem: sudo apt-get install mysql-server mysql-client &#8230; <a href="http://dancingpenguinsoflight.com/2011/01/reminder-for-mysql-rubygem-install-on-ubuntu/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Quick easy steps to get up and running with ruby, mysql, sqlite, rails, and most especially the mysql gem on a fresh Ubuntu 10.10 64-bit system:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># mysql and dev packages needed for mysql rubygem:</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> mysql-server mysql-client libmysqlclient-dev \<br />
libmysqld-dev<br />
<span style="color: #666666; font-style: italic;"># Needed for ruby-debug:</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> ruby1.8-dev <br />
<span style="color: #666666; font-style: italic;"># Rails package includes lots of goodies you'll likely want:</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails sqlite3 ruby-debug<br />
<span style="color: #666666; font-style: italic;"># And finally the gem:</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> mysql</div></td></tr></tbody></table></div>
    ]]></content:encoded>
			<wfw:commentRss>http://dancingpenguinsoflight.com/2011/01/reminder-for-mysql-rubygem-install-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Review of Hacking Vim 7.2</title>
		<link>http://dancingpenguinsoflight.com/2010/06/review-of-hacking-vim-7-2/</link>
		<comments>http://dancingpenguinsoflight.com/2010/06/review-of-hacking-vim-7-2/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 01:24:43 +0000</pubDate>
		<dc:creator>Samuel Huckins</dc:creator>
				<category><![CDATA[Book Review]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://dancingpenguinsoflight.com/?p=1480</guid>
		<description><![CDATA[Hacking Vim 7.2 by Kim Schulz is filled with a variety of useful explanations and helpful tips for Vim users wanting to improve their efficiency and learn more about their editor. While I&#8217;ve enjoyed finding new and better ways to &#8230; <a href="http://dancingpenguinsoflight.com/2010/06/review-of-hacking-vim-7-2/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><img style="float: left; margin-right: 10px;" title="vim_logo" src="http://dancingpenguinsoflight.com/wp-content/uploads/2009/07/vim_logo.png" alt="vim_logo" width="125" height="125" /><a title="Hacking Vim on Packt" href="https://www.packtpub.com/hacking-vim-7-2/book" target="_blank"><em>Hacking Vim 7.2</em></a> by Kim Schulz is filled with a variety of useful explanations and helpful tips for <a title="vim homepage" href="http://www.vim.org/" target="_blank">Vim</a> users wanting to improve their efficiency and learn more about their editor. While I&#8217;ve enjoyed finding <a title="DPOL posts on Vim" href="http://dancingpenguinsoflight.com/?s=vim" target="_blank">new and better ways to use Vim</a> for some time, I still learned quite a lot from this book.</p>
<p>If you use Vim only to edit text files when you happen to be  logged  into a CLI: mosey on along, this isn&#8217;t the book for you. If you   currently use Vim regularly and want to improve your knowledge and effectiveness with it: your time reading this book will be well-spent. If you&#8217;ve somehow never heard of   Vim but are enraptured by the idea of a text editor that can be an effective IDE in   addition to allowing you to play Tetris and Rubik&#8217;s Cube: you might like this book too.<br />
<span id="more-1480"></span><br />
At first this book seemed rather short for such a  potentially expansive topic. In the  end I found this to be mostly a virtue  rather than a problem, as the amount  of information presented is, in fact,  voluminous. A more comprehensive  approach likely would have been too  hefty and less  effective. It doesn&#8217;t pretend to be a  manual for Vim. Instead it  illustrates the best approaches for various issues and situations, suggests improvements  on more common operations, and provides lots of  references to external  resources (primarily Vim internal help and vim.org) to  learn more. Examples and illustrations provide insight into some of Vim&#8217;s lesser known abilities, while commonly used ones are explained and presented in new and useful ways. Groups of features resolve into <em>solutions</em>.</p>
<h2>Chapter by Chapter</h2>
<h3><strong>Chapter 1, Getting Started with Vim</strong></h3>
<p>Primarily a history of the Vim editor. Useful to expand the knowledge of Vim fans, but not really pertinent to <em>hacking</em> your beloved editor. Would probably have been better as an appendix or excised entirely.</p>
<h3><strong>Chapter 2</strong>, <strong>Personalizing Vim</strong></h3>
<p>Editing your Vim config, customizing fonts, colors, menu buttons and other UI elements. Lots of great material for tuning the visual appearance. More about vim.org and other resources for colorschemes (such as <a title="Vim colorscheme test site" href="http://vimcolorschemetest.googlecode.com/svn/html/index-c.html" target="_blank">this gem</a>) would have been helpful. The ability to add tooltip balloons was new to me and quite exciting. Schulz provides a number of great examples for their use. The discussion of abbreviations was a bit confusing, especially considering the recommendation of the more intuitive snippets approach in Chapter 4.</p>
<h3><strong>Chapter 3, Better Navigation</strong></h3>
<p>By now you might already be feeling overwhelmed by the number of key commands to remember. I recommend starting a cheat sheet of those you find especially interesting. Speaking of that, perhaps it&#8217;s just my predilections and lack of a perfect memory, but the vast number of code navigation keys was just a bit too much. Sure, &#8220;extra keys pressed equals extra time wasted&#8221;, but what about extra time sorting through key commands in your thoughts? Still, plenty of tips should be mind-blowing if new to you. Jumping to files named in the text of the current file, for example, is really handy. The information about search improvements, both in user files and in the help system, was quite good. I&#8217;ve yet to really use signs or marks, but found their explanation here illuminating.</p>
<h3><strong>Chapter 4, Production (Productivity?) Boosters</strong></h3>
<p>Templates! Templates are awesome, and this was a welcome introduction to a topic <a title="DPOL post on Bash scripting, template" href="http://dancingpenguinsoflight.com/2009/03/vim-for-bash-scripting-a-happier-union/" target="_blank">I&#8217;ve barely scratched</a> in my Vim journey. I&#8217;ve also not used placeholders in templates before, which look to be quite useful. Tag lists and essential plugins for their use are explained, providing an effective presentation of this feature. I was getting a little worried around pg. 86, as the number of Ctrl + x, Ctrl + SOME_KEY commands started to get cumbersome. Then came the explanation of triggering all completion types using a single key, which was quite refreshing. Complete using dictionaries, words in the current document, language files, and more, all using a single key. The SuperCleverTab function will be a very welcome addition to my configuration. Until seeing the example about macros, I never really felt how useful they might be. This definitely convinced me.</p>
<p>But this meaty chapter isn&#8217;t over yet! Sessions felt rather opaque to me before reading this section, and I think they will now definitely serve a role for me. No more ritual of opening the right files, folding them just how I want, etc every morning. Undo branching&#8230; I still find this rather too complicated and marginal of a feature to care about. But the examples were at least explanatory. Folding is a great eye-saver, and the coverage was adequate. I&#8217;m still not really a fan of vimdiff, as there are other diff utilities out there that make the process faster and more intuitive to me. One exception is finding the diff between the current buffer and the saved file, which is very handy and not something available in most editors for sure! I hadn&#8217;t opened remote files in Vim directly before, so the section on this at the end of this chapter was quite useful.</p>
<h3><strong>Chapter 5, Advanced Formatting</strong></h3>
<p>I felt mostly ambivalent about the beginning of this chapter. To me, if you want text aligned a certain way, or want to create proper lists and use other more advanced document formatting features, you should use a word processor. Adding whitespace to my text files for alignment&#8217;s sake doesn&#8217;t strike me as a good idea.</p>
<p>The second part covering formatting pertinent to coding was much more useful. I&#8217;ve used things like autoindent and formatting of pasted code for a while now, and they are quite essential to sanity. Great coverage for those new to these features. Integration of external formatting tools such as Tidy is also described. <strong></strong></p>
<h3><strong>Chapter 6, Basic Vim Scripting</strong></h3>
<p>&#8220;<em>Now</em> we get to it&#8221; was my feeling starting this chapter. There&#8217;s some very helpful stuff in here, but it&#8217;s strangely organized and should have been moved or at least mentioned earlier in the book to provide the most benefit. Some critically handy items: explanation of Vim configuration file directories, how to properly override layers of configuration, Vimball installation, syntax highlighting and colorscheme creation. Then&#8230; comes an introductory language tutorial. Honestly, it&#8217;s pretty dull and mostly elementary. I would have rather this been moved to an appendix mentioned early in the book. It does provide broad coverage of the basics one would need to start writing Vim scripts.</p>
<h3><strong>Chapter 7, Extended Vim Scripting</strong></h3>
<p><strong></strong>Everything you need to know about actually writing Vim scripts: suggested code format, function structure, adding key mappings, detecting OS and Vim version, debugging and distributing scripts, documentation, even integrating programming languages like Python and Ruby! This is certainly a great reference to get started with Vim scripting. Schulz also gives an example script wrapping up a number of these points, providing something like a Vim scripter&#8217;s &#8220;Hello World&#8221;.</p>
<h3><strong>Appendix A, Vim Can Do Everything</strong></h3>
<p>Examples of the many and varied things you can do with Vim, such as Tweet and play Tetris. Provides amusement, but not a lot of value. The section on Vim as an IDE should really have been expanded to an entire chapter or appendix considering the likely audience for this book.</p>
<h3><strong>Appendix B, Vim Configuration Alternatives</strong></h3>
<p>A number of tips on how to keep your Vim configuration organized. Spends time explaining a system of scripts created by Jos van RisWick that allows the user to make changes to their configuration from GUI menus and make them permanent, instead of editing config files. I had never heard of this and found it quite interesting.</p>
<p>The last few pages deal with storing your Vim configuration online. While I whole-heartedly agree with the intent, the particular manifestation presented is rather terrible. Using this setup, the user&#8217;s .vimrc would be downloaded <em>every time</em> Vim is opened. Then it still has to be parsed, which for heavily customized setups can already take a moment. Not the best when you&#8217;re looking for a lean editor. And what about the legion of scripts and other supporting files outside .vimrc? I think not. My approach to the problem is to keep all of my Vim configuration files inside an SCM system, checking it out on each system the first time I want to use Vim.</p>
<h2>Issues</h2>
<ul>
<li><strong>Confused structure</strong>: Chapters 6 and 7 felt rather strangely divided  in  themselves, and I felt most of the content should have been provided   earlier. Having a better knowledge of the syntax and nature of ex   commands/Vim scripting would have made the content throughout the book   more understandable. I felt I was mostly taking the syntax in the code provided for   granted, without feeling comfortable enough about all the components that I could have written something of my own design.</li>
<li><strong>Typos</strong>: The text would have greatly benefited from another round of   copy-editing. Most of the errors weren&#8217;t very distracting. There were, however, a number of typos in the code provided that   were more problematic, especially for a work on an editor that can be   rather picky about commands. For a first edition, these aren&#8217;t overly   numerous.</li>
<li><strong>Lack of color diagrams</strong>: I&#8217;m all for using black and  white images  when they will suffice, but when providing illustrations of  *color*  highlighting files, images without color are downright useless!  I was  rather surprised at this oversight, first appearing in chapter 2,  then  in multiple places in chapter 6. They could have at least linked  to  color images online.</li>
</ul>
<h2>Conclusion</h2>
<p>All in all this was a very useful  treasure trove of tips. Some I&#8217;ve  already added to my repertoire, and  more I&#8217;m trying to understand  better. In fact, I learned so much from it  that I decided I will likely  need to drop most of my current Vim config  and remake it cleanly. I  know I&#8217;m not alone in collecting bits and  pieces of configuration for  this wonderful editor, in a fashion  occasionally reminiscent of a  deranged hermit crab. Now that I have a  more solid understanding I can  rebuild it quickly and effectively.</p>
<p>In summary, I agree with <a title="Brian Carper's Hacking Vim 7.2 review" href="http://briancarper.net/blog/review-hacking-vim-72" target="_blank">Brian Carper</a>:</p>
<blockquote><p>The best you can hope for in a book is a broad outline to point the way  toward features that you didn&#8217;t know much about. Hacking Vim 7.2  achieves this goal.</p></blockquote>
    ]]></content:encoded>
			<wfw:commentRss>http://dancingpenguinsoflight.com/2010/06/review-of-hacking-vim-7-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>An improved ruby debugger invocation</title>
		<link>http://dancingpenguinsoflight.com/2009/09/an-improved-ruby-debugger-invocation/</link>
		<comments>http://dancingpenguinsoflight.com/2009/09/an-improved-ruby-debugger-invocation/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 01:17:41 +0000</pubDate>
		<dc:creator>Samuel Huckins</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://dancingpenguinsoflight.com/?p=1195</guid>
		<description><![CDATA[I&#8217;d been wanting to write a post for some time on improvements I&#8217;ve found useful in using Ruby&#8217;s debugger. Friend Trevor Rosen beat me to the proverbial punch, however. Give his post a read first, I&#8217;ll wait. Now on top &#8230; <a href="http://dancingpenguinsoflight.com/2009/09/an-improved-ruby-debugger-invocation/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d been wanting to write a post for some time on improvements I&#8217;ve found useful in using Ruby&#8217;s debugger. Friend Trevor Rosen <a target="_blank" title="Trevor Rosen's post on improving Ruby debugger" href="http://www.catapult-creative.com/2009/08/12/make-ruby-debug-work-better/">beat me to the proverbial punch</a>, however. Give his post a read first, I&#8217;ll wait.</p>
<p>Now on top of his suggestions I have one more refinement to add. I&#8217;ve defined a snippet in vim for whenever I need to use the debugger. You should be able to define the same in whatever editor you use (and if your editor can&#8217;t do snippets, get <a target="_blank" title="vim home" href="http://www.vim.org/">a real one</a>). When in an .rb file, &#8220;debug&#8221; + Tab becomes:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'ruby-debug'</span>; Debugger.<span style="color:#9900CC;">settings</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:autoeval</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">true</span>; debugger; rubys_debugger = <span style="color:#996600;">&quot;annoying&quot;</span></div></td></tr></tbody></table></div>
<p>In addition to the format Trevor suggested (which calls the necessary module, turns on auto evaluation, and calls the debugger itself) this adds a simple assignment after the debugger is called. I often find this necessary because I want to debug right at the very end of a given suite, a conditional, a method, etc. But if you invoke the debugger as the last statement in such a situation, it won&#8217;t actually be called. Here&#8217;s an example file:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span><br />
<br />
<span style="color:#9966CC; font-weight:bold;">def</span> troubled_func<span style="color:#006600; font-weight:bold;">&#40;</span>var1<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;Entering troubled function...&quot;</span><br />
&nbsp; secret_num = <span style="color:#CC0066; font-weight:bold;">rand</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">*</span> var1<br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'ruby-debug'</span>; Debugger.<span style="color:#9900CC;">settings</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:autoeval</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">true</span>; debugger<br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
troubled_func<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">5</span><span style="color:#006600; font-weight:bold;">&#41;</span></div></td></tr></tbody></table></div>
<p>When you run this, you won&#8217;t get a debugger console. All the output you get is &#8220;Entering troubled function&#8230;&#8221; and the script exits. If instead you add the assignment I list above after debugger is called, you will get to the debugger console. Sad, but true. (You can select a less offensive assignment if you wish. I settled on it in disgust.)</p>
<p>Aside from this, the Ruby debugger is a useful and beautiful thing. So add the snippet and forget about it.</p>
    ]]></content:encoded>
			<wfw:commentRss>http://dancingpenguinsoflight.com/2009/09/an-improved-ruby-debugger-invocation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Improved irb configuration</title>
		<link>http://dancingpenguinsoflight.com/2009/07/improved-irb-configuration/</link>
		<comments>http://dancingpenguinsoflight.com/2009/07/improved-irb-configuration/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 02:18:49 +0000</pubDate>
		<dc:creator>Samuel Huckins</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[efficiency]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://dancingpenguinsoflight.com/?p=1068</guid>
		<description><![CDATA[As applies to most new tools I start to use, the time in which I&#8217;ve started to learn Ruby has included a fair amount of time improving my general working environment, to make it more suited to the use of &#8230; <a href="http://dancingpenguinsoflight.com/2009/07/improved-irb-configuration/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As applies to most new tools I start to use, the time in which I&#8217;ve started to learn Ruby has included a fair amount of time improving my general working environment, to make it more suited to the use of a welcome new tool. Aside from seeking out informative and reliable sources of documentation, new useful modules, and additions to my editor to make it more Ruby-friendly, I&#8217;ve also sought a more efficient configuration for irb. I discussed irb and how to setup some basic improved config in <a target="_blank" title="Post on irb config" href="http://dancingpenguinsoflight.com/2009/06/a-better-ruby-prompt/">this recent post</a>. </p>
<p>Commenter Vorian helpfully mentioned that the same effect can be achieved through an .irbrc file. This file can then be placed in a VCS, and in addition having the configuration in one spot is preferable. While seeking information on the configuration options available, I came across a number of additional customizations that have proved quite useful. I took <a href="http://ruby.tie-rack.org/3/my-irbrc/">this page&#8217;s</a> suggestions mostly verbatim in formulating mine. <a href="http://drnicwilliams.com/2006/10/12/my-irbrc-for-consoleirb/">This page</a> was also helpful. Here&#8217;s my current .irbrc, highlights to follow:</p>
<div class="codecolorer-container ruby blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br />56<br />57<br />58<br />59<br />60<br />61<br />62<br />63<br />64<br /></div></td><td><div class="ruby codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color:#008000; font-style:italic;"># Interactive Ruby console configuration</span><br />
IRB_START_TIME = <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Print to yaml format with &quot;y&quot;</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'yaml'</span><br />
<span style="color:#008000; font-style:italic;"># Pretty printing</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'pp'</span><br />
<span style="color:#008000; font-style:italic;"># Ability to load rubygem modules</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rubygems'</span><br />
<span style="color:#008000; font-style:italic;"># Tab completion</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'irb/completion'</span><br />
<span style="color:#008000; font-style:italic;"># Save irb sessions to history file</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'irb/ext/save-history'</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Not stdlib</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'map_by_method'</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'what_methods'</span><br />
<span style="color:#008000; font-style:italic;"># For printing time in session</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'duration'</span><br />
<span style="color:#008000; font-style:italic;"># For coloration</span><br />
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'wirble'</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Include line numbers and indent levels:</span><br />
IRB.<span style="color:#9900CC;">conf</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:PROMPT</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:SHORT</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; <span style="color:#ff3333; font-weight:bold;">:PROMPT_C</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#996600;">&quot;%03n:%i* &quot;</span>,<br />
&nbsp; :<span style="color:#0000FF; font-weight:bold;">RETURN</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#996600;">&quot;%s<span style="color:#000099;">\n</span>&quot;</span>,<br />
&nbsp; <span style="color:#ff3333; font-weight:bold;">:PROMPT_I</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#996600;">&quot;%03n:%i&gt; &quot;</span>,<br />
&nbsp; <span style="color:#ff3333; font-weight:bold;">:PROMPT_N</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#996600;">&quot;%03n:%i&gt; &quot;</span>,<br />
&nbsp; <span style="color:#ff3333; font-weight:bold;">:PROMPT_S</span><span style="color:#006600; font-weight:bold;">=&gt;</span><span style="color:#996600;">&quot;%03n:%i%l &quot;</span><br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
<br />
IRB.<span style="color:#9900CC;">conf</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:PROMPT_MODE</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#ff3333; font-weight:bold;">:SHORT</span><br />
<span style="color:#008000; font-style:italic;"># Adds readline functionality</span><br />
IRB.<span style="color:#9900CC;">conf</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:USE_READLINE</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">true</span><br />
<span style="color:#008000; font-style:italic;"># Auto indents suites</span><br />
IRB.<span style="color:#9900CC;">conf</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:AUTO_INDENT</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">true</span><br />
<span style="color:#008000; font-style:italic;"># Where history is saved</span><br />
IRB.<span style="color:#9900CC;">conf</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:HISTORY_FILE</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">&quot;#{ENV['HOME']}/.irb-save-history&quot;</span><br />
<span style="color:#008000; font-style:italic;"># How many lines to save</span><br />
IRB.<span style="color:#9900CC;">conf</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:SAVE_HISTORY</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006666;">1000</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Turn turn on colorization, off other wirble wierdness</span><br />
Wirble.<span style="color:#9900CC;">init</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:skip_prompt</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span>, <span style="color:#ff3333; font-weight:bold;">:skip_history</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span><br />
Wirble.<span style="color:#9900CC;">colorize</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Quick benchmarking facility</span><br />
<span style="color:#008000; font-style:italic;"># Based on rue's irbrc =&gt; http://pastie.org/179534</span><br />
<span style="color:#9966CC; font-weight:bold;">def</span> quick<span style="color:#006600; font-weight:bold;">&#40;</span>repetitions=<span style="color:#006666;">100</span>, <span style="color:#006600; font-weight:bold;">&amp;</span>block<span style="color:#006600; font-weight:bold;">&#41;</span><br />
&nbsp; <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'benchmark'</span><br />
&nbsp; <span style="color:#CC00FF; font-weight:bold;">Benchmark</span>.<span style="color:#9900CC;">bmbm</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>b<span style="color:#006600; font-weight:bold;">|</span><br />
&nbsp; &nbsp; b.<span style="color:#9900CC;">report</span> <span style="color:#006600; font-weight:bold;">&#123;</span>repetitions.<span style="color:#9900CC;">times</span> <span style="color:#006600; font-weight:bold;">&amp;</span>block<span style="color:#006600; font-weight:bold;">&#125;</span> <br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
&nbsp; <span style="color:#0000FF; font-weight:bold;">nil</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Return only the methods not present on basic objects</span><br />
<span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#CC00FF; font-weight:bold;">Object</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> interesting_methods<br />
&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">methods</span> <span style="color:#006600; font-weight:bold;">-</span> <span style="color:#CC00FF; font-weight:bold;">Object</span>.<span style="color:#9900CC;">new</span>.<span style="color:#9900CC;">methods</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">sort</span><br />
&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span><br />
<span style="color:#9966CC; font-weight:bold;">end</span><br />
<br />
<span style="color:#008000; font-style:italic;"># Prints how long the session has been open upon exit</span><br />
<span style="color:#CC0066; font-weight:bold;">at_exit</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#CC0066; font-weight:bold;">puts</span> Duration.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span> <span style="color:#006600; font-weight:bold;">-</span> IRB_START_TIME<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div></td></tr></tbody></table></div>
<p>You&#8217;ll need to install the following gems (&#8220;sudo gem install FOO&#8221;): <a target="_blank" title="New magical version of Symbol.to_proc by Dr. Nic" href="http://drnicwilliams.com/2006/09/28/new-magical-version-of-symbolto_proc/">map_by_method</a>, <a target="_blank" title="Stick it in Your ~/.irbrc: MethodFinder" href="http://redhanded.hobix.com/inspect/stickItInYourIrbrcMethodfinder.html">what_methods</a>, <a target="_blank" title="Information on duration gem" href="http://www.ahabman.com/blog/2009/06/ruby-duration/">duration</a>, and <a target="_blank" title="Wirble home" href="http://pablotron.org/software/wirble/">wirble</a>. Most options should be self-explanatory and there&#8217;s plenty of commentary.</p>
<p>With this in place, you&#8217;ll get tab completion to assist in remembering method names and automatic indentation to make visualizing your code&#8217;s structure simpler. Output will be colorized for quicker understanding. Your activity will be recorded for later review, and when you exit you&#8217;ll find out how long you were in the session.</p>
<p><img src="http://dancingpenguinsoflight.com/wp-content/uploads/2009/07/irb.png" alt="irb" title="irb" width="255" height="266" class="aligncenter size-full wp-image-1078" /></p>
<p>The two methods defined are helpers for benchmarking and viewing the methods on an object that are more interesting:</p>
<p><img src="http://dancingpenguinsoflight.com/wp-content/uploads/2009/07/methods.png" alt="methods" title="methods" width="596" height="609" class="aligncenter size-full wp-image-1079" /></p>
<p>For more information on irb use, check out <a target="_blank" title="irb in Programming Ruby" href="http://www.rubycentral.com/book/irb.html">this section in Programming Ruby</a>.</p>
    ]]></content:encoded>
			<wfw:commentRss>http://dancingpenguinsoflight.com/2009/07/improved-irb-configuration/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A better Ruby prompt</title>
		<link>http://dancingpenguinsoflight.com/2009/06/a-better-ruby-prompt/</link>
		<comments>http://dancingpenguinsoflight.com/2009/06/a-better-ruby-prompt/#comments</comments>
		<pubDate>Sun, 21 Jun 2009 14:36:20 +0000</pubDate>
		<dc:creator>Samuel Huckins</dc:creator>
				<category><![CDATA[Ruby]]></category>
		<category><![CDATA[efficiency]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://dancingpenguinsoflight.com/?p=1039</guid>
		<description><![CDATA[The Interactive Ruby Shell, or irb, is indispensable for trying out Ruby code rapidly, seeing what works and what&#8217;s elegant. But the defaults aren&#8217;t quite optimal. Tab completion It lacks tab completion by default. Having this available can save you &#8230; <a href="http://dancingpenguinsoflight.com/2009/06/a-better-ruby-prompt/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>The <a target="_blank" title="Wikipedia on irb" href="http://en.wikipedia.org/wiki/Interactive_Ruby_Shell">Interactive Ruby Shell</a>, or irb, is indispensable for trying out Ruby code rapidly, seeing what works and what&#8217;s elegant. But the defaults aren&#8217;t quite optimal. </p>
<h2>Tab completion</h2>
<p>It lacks tab completion by default. Having this available can save you a lot of time, especially as you are learning the language. To turn it on, simply add the option &#8220;-r irb/completion&#8221; to require that functionality. You can also add it to a running session by entering &#8220;require &#8216;irb/completion&#8217;&#8221;. After setting this you can press Tab after a dot following an object to see what methods are available for it (not all methods shown in image):</p>
<p><img src="http://dancingpenguinsoflight.com/wp-content/uploads/2009/06/tab-complete.png" alt="tab-complete" title="tab-complete" width="479" height="321" class="aligncenter size-full wp-image-1040" /></p>
<p>Now you can type the method you want to use from the list. You can also type part of a method name and press Tab to view matches on what you have so far.</p>
<h2>Appearance</h2>
<p>The default prompt can also be a little too wordy:</p>
<p><img src="http://dancingpenguinsoflight.com/wp-content/uploads/2009/06/default-irb.png" alt="default-irb" title="default-irb" width="272" height="41" class="aligncenter size-full wp-image-1041" /></p>
<p>This shows the program name (always &#8220;irb(main)&#8221; for the irb command), the line number within said program, and the indentation level. This last value is incremented as you move into loops and other multi-line structures. If you don&#8217;t want this meta information, however, just call irb with the &#8220;&#8211;simple prompt&#8221; option:</p>
<p><img src="http://dancingpenguinsoflight.com/wp-content/uploads/2009/06/simple-irb.png" alt="simple-irb" title="simple-irb" width="419" height="45" class="aligncenter size-full wp-image-1042" /></p>
<h2>Aliases</h2>
<p>I combine the above customizations into two Bash aliases for simpler access. Just add the following to your ~/.bashrc:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">r</span>=<span style="color: #ff0000;">&quot;irb --simple-prompt -r irb/completion&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">irb</span>=<span style="color: #ff0000;">&quot;irb -r irb/completion&quot;</span></div></td></tr></tbody></table></div>
<p>Now you can get to a simpler prompt for quick checks, or the full prompt for more complete documentation, making a tutorial, etc. And both have the lovely tab completion.</p>
<p><em><strong>[EDIT, 2009-07-17]:</strong> As helpfully pointed out by commenter Vorian, the improvements above can also be attained using configuration options placed into ~/.irbrc. After hearing about this, I looked around for example .irbrc files and put together a decent one. <a title="Post on additional irb config" href="http://dancingpenguinsoflight.com/2009/07/improved-irb-configuration/">Check out this post</a> for more details.</em></p>
    ]]></content:encoded>
			<wfw:commentRss>http://dancingpenguinsoflight.com/2009/06/a-better-ruby-prompt/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Ruby, Rails, and Gems: Getting Started</title>
		<link>http://dancingpenguinsoflight.com/2009/05/ruby-rails-and-gems-getting-started/</link>
		<comments>http://dancingpenguinsoflight.com/2009/05/ruby-rails-and-gems-getting-started/#comments</comments>
		<pubDate>Sun, 10 May 2009 20:28:38 +0000</pubDate>
		<dc:creator>Samuel Huckins</dc:creator>
				<category><![CDATA[CLI]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://dancingpenguinsoflight.com/?p=896</guid>
		<description><![CDATA[I recently started learning Ruby (mostly to flesh out my programming knowledge) and since one of the main self-detected shortcomings in my programming knowledge and skillset is web frameworks and web programming, I decided to give Ruby on Rails a &#8230; <a href="http://dancingpenguinsoflight.com/2009/05/ruby-rails-and-gems-getting-started/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.ruby-lang.org/en/" target="_blank"><img class="alignleft size-full wp-image-915" style="margin-right: 15px; margin-bottom: 15px; border: none !important; float: left;" title="Ruby" src="http://dancingpenguinsoflight.com/wp-content/uploads/2009/05/ruby_logo1.gif" border="0" alt="" width="104" height="105" /></a> I recently started learning <a title="Ruby home" href="http://www.ruby-lang.org/en/" target="_blank">Ruby</a> (mostly to flesh out my programming knowledge) and since one of the main self-detected shortcomings in my programming knowledge and skillset is web frameworks and web programming, I decided to give <a title="Ruby on Rails home" href="http://rubyonrails.org/" target="_blank">Ruby on Rails</a> a shot. This post will describe the first steps needed to begin using Ruby, Ruby on Rails, and their entourage. I&#8217;m running Ubuntu 9.04 Jaunty Jackelope, but there are <a title="Let me Google that for you..." href="http://lmgtfy.com/?q=install+ruby" target="_blank">many guides out there</a> to get you up and running. It will also cover some basic tips for using RubyGems and other related topics to get you going faster. Thanks to friend and co-worker <a title="Catault Creative home" href="http://www.catapult-creative.com/" target="_blank">Trevor Rosen</a> for ample (cough, <em>truculent</em>, cough) encouragement, information, and assistance in this bauble-strewn journey.</p>
<p>First install Ruby and a few related items:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get install</span> ruby rdoc irb</div></td></tr></tbody></table></div>
<p><a title="RDoc manual" href="http://rdoc.sourceforge.net/" target="_blank">RDoc</a> allows you to generate HTML API presentations from Ruby code. irb is the <a target="_blank" title="irb man page" href="http://linux.die.net/man/1/irb">interactive Ruby prompt</a>, great for trying out quick ideas.</p>
<p>Next you need to install RubyGems. <a title="RubyGems manual" href="http://rubygems.org/read/book/1" target="_blank">RubyGems</a> is the Ruby packaging system, as easy_install is to Python and apt-get is to Ubuntu. It&#8217;s a lovely package handling system. While I use and love setup_tools, it does have its shortcomings. RubyGems actually allows you to uninstall packages! Sounds simple enough, but easy_install users know this is a continual pain. RubyGems also allows much better searching and provides more information about potential packages. </p>
<p>I don&#8217;t recommend installing this from the Ubuntu repos. I ran into some odd problems, while the latest from RubyForge worked fine. If you do get it from the repo, be sure to install &#8220;rubygems&#8221;, not &#8220;gem&#8221; (Graphics Environment for Multimedia &#8211; PureData library)! To install from source, get the latest stable version from <a target="_blank" title="RubyGems download page" href="http://rubyforge.org/frs/?group_id=126">here on RubyForge</a>, then:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">tar</span> xzvf rubygems-VERSION.tgz<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> rubygems-VERSION<span style="color: #000000; font-weight: bold;">/</span><br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> ruby setup.rb<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gem1.8 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gem</div></td></tr></tbody></table></div>
<p>That last step is needed since the setup script doesn&#8217;t make its own symlink. This can make for wretched confusion&#8230;  Here are some basic RubyGems commands and example output:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># View available commands</span><br />
<span style="color: #000000; font-weight: bold;">&gt;</span> gem <span style="color: #7a0874; font-weight: bold;">help</span> commands<br />
GEM commands are:<br />
...All the commands and descriptions thereof.<br />
<span style="color: #666666; font-style: italic;"># Search for a gem by name:</span><br />
<span style="color: #000000; font-weight: bold;">&gt;</span> gem query <span style="color: #660033;">--remote</span> <span style="color: #660033;">--name-matches</span> flickr<br />
<span style="color: #000000; font-weight: bold;">***</span> REMOTE GEMS <span style="color: #000000; font-weight: bold;">***</span><br />
flickr <span style="color: #7a0874; font-weight: bold;">&#40;</span>1.0.2<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
...Many more...<br />
<span style="color: #666666; font-style: italic;"># Install a gem:</span><br />
<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #660033;">--remote</span> flickr<br />
Successfully installed flickr-1.0.2<br />
<span style="color: #000000;">1</span> gem installed<br />
<span style="color: #666666; font-style: italic;"># Get information on an installed gem:</span><br />
<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem specification flickr<br />
<span style="color: #660033;">---</span> <span style="color: #000000; font-weight: bold;">!</span>ruby<span style="color: #000000; font-weight: bold;">/</span>object:Gem::Specification<br />
name: flickr<br />
version: <span style="color: #000000; font-weight: bold;">!</span>ruby<span style="color: #000000; font-weight: bold;">/</span>object:Gem::Version<br />
version: 1.0.2<br />
...Lots more...<br />
<span style="color: #666666; font-style: italic;"># Remove a gem:</span><br />
<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> gem uninstall flickr<br />
Successfully uninstalled flickr-1.0.2</div></td></tr></tbody></table></div>
<p>Consider adding a few Bash aliases for faster access to the basic commands:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># Look for gems with &quot;gquery name&quot;:</span><br />
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">gquery</span>=<span style="color: #ff0000;">&quot;gem query --remote --name-matches&quot;</span><br />
<span style="color: #666666; font-style: italic;"># Install new gems with &quot;ginst name&quot;:</span><br />
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ginst</span>=<span style="color: #ff0000;">&quot;sudo gem install&quot;</span><br />
<span style="color: #666666; font-style: italic;"># Get information on gems with &quot;ginfo name&quot;:</span><br />
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">ginfo</span>=<span style="color: #ff0000;">&quot;sudo gem specification&quot;</span><br />
<span style="color: #666666; font-style: italic;"># Remove gems with &quot;gdel name&quot;:</span><br />
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">gdel</span>=<span style="color: #ff0000;">&quot;sudo gem uninstall&quot;</span><br />
<span style="color: #666666; font-style: italic;"># Update gems:</span><br />
<span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">gupdate</span>=<span style="color: #ff0000;">&quot;sudo gem update&quot;</span></div></td></tr></tbody></table></div>
<p>Next install Rails and its merry band:</p>
<div class="codecolorer-container bash blackboard" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> gem <span style="color: #c20cb9; font-weight: bold;">install</span> rails</div></td></tr></tbody></table></div>
<p><a href="http://rubyonrails.org/" target="_blank"><img class="aligncenter size-full wp-image-912" style="margin-left: 15px; margin-bottom: 15px; border: none !important; float: right;" title="Ruby on Rails" src="http://dancingpenguinsoflight.com/wp-content/uploads/2009/05/rails_logo_128x128.png" border="0" alt="The Rails Logo was created by Kevin Milden and is distrubuted under the BY-ND Creative Commons Licence." width="128" height="128" /></a></p>
<p>This will install Rails, its library dependencies, rake, etc. I first installed Rails via apt-get, but ran into a small issue. </p>
<p>Next, to get the general sense of creating a Rails app, I recommend starting off with <a title="The Original Ruby on Rails Screencasts" href="http://showmedo.com/videotutorials/video?name=ruby5MinuteFlickrInterface&amp;fromSeriesID=29" target="_blank">The Original Ruby on Rails Screencasts</a> by Sam Stephenson and David Hansson on <a title="ShowMeDo home" href="http://showmedo.com/" target="_blank">ShowMeDo</a>. These are by no means comprehensive guides, but they illustrate doing some basic things with Rails, and end up with some pretty nice apps in a few minutes. You&#8217;ll be hard pressed to follow along yourself, depending on how many hours of Doom you played as a child.</p>
<p>To really start to grasp things, check out the <a title="RailsGuides Getting Started" href="http://guides.rubyonrails.org/getting_started.html" target="_blank">Getting Started guide</a> on the <a title="RailsGuides home" href="http://guides.rubyonrails.org" target="_blank">RailsGuides</a> site. This goes through each step from nothing to a working Rails app. As you proceed, you might want additional information on various technical details. Look no further than the <a title="Rails Searchable API" href="http://railsapi.com/" target="_blank">Rails Searchable API</a> site. You can browse this online or download it locally. It provides a decent looking (finally for an HTML API: readable) and useable API reference for Rails. The search is amazing, and they&#8217;ve done a great job compressing a lot of information into a relatively small amount of space.</p>
<p>Once you begin looking for information on how to accomplish various discrete tasks, check out <a title="Railscasts podcasts" href="http://railscasts.com/episodes/archive" target="_blank">Railscasts</a>. These assume some Rails knowledge, but are decent simple guides to how to add features like reliable authentication, avoiding SQL injection, generating PDFs, and a lot more (160 so far!).</p>
<p>I hope to post more on Ruby and Ruby on Rails as I learn and play around with them. If you are new to Ruby, <a title="About Ruby" href="http://www.ruby-lang.org/en/about/" target="_blank">check out this page</a>. I came across it after I started going through a few tutorials, and find it amply summarizes most of the features I started to love at first blush.</p>
    ]]></content:encoded>
			<wfw:commentRss>http://dancingpenguinsoflight.com/2009/05/ruby-rails-and-gems-getting-started/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

