{ |one, step, back| } http://www.pairprogrammingbot.com/index.cgi Jim Weirich's Blog en-us { |one, step, back| } http://onestepback.org http://onestepback.org/images/jwface.gif New Blog Name http://www.pairprogrammingbot.com/index.cgi/Humor/RenameTitle.red <p style="padding-left:3em;"><em>Ryan Tomayko has pointed out, my blog title does not conform to standard Ruby coding conventions. We need to fix this.</em></p> <p><a href="http://tomayko.com/">Ryan Tomayko</a> has done a <a href="http://tomayko.com/writings/your-clever-weblog-title">review of blogs using code snippets</a> as there title and has pointed out that mine does not conform to generally accepted Ruby coding standards. You see, in &#8220;{&nbsp;|&nbsp;one,&nbsp;step,&nbsp;back&nbsp;|&nbsp;}&#8221; I use spaces between the vertical bars and the argument names. Proper Ruby code would never be written that way.</p> <p>He&#8217;s right. So in order to promote better Ruby coding practices, I&#8217;m renaming the blog to &#8220;{&nbsp;|one,&nbsp;step,&nbsp;back|&nbsp;}&#8221;.</p> <p>Let it never be said that I ignore standards.</p> <p style="padding-left:3em;">An aside: The use of {||} in the title was inspired by a Smalltalk logo that used [|]. See the powered by banner at the bottom of the sidebar in <a href="http://www.cincomsmalltalk.com/blog/blogView">James Robertson&#8217;s blog</a> for an example.</p> Innovative Identification http://www.pairprogrammingbot.com/index.cgi/Humor/InnovativeIdentification.red <p style="padding-left:3em;"><em>Dick Hardt&#8217;s <span class="caps">OSCON 2005</span> keynote talked about how to identify yourself online. Here&#8217;s an <span class="caps">IRC</span> conversation the ensued after I accidently issued a sudo command on a friend&#8217;s system, one that is monitored very closely by the sysadmin. </em></p> <pre> [22:35] &lt;paulv&gt; matthew immediately declared that we were already cracked. :) [22:35] &lt;matthew&gt; yeah, it's all good. Although, can you prove you're Jim? [22:35] &lt;jweirich&gt; yes [22:35] &lt;jweirich&gt; ask me a Ruby question [22:35] &lt;paulv&gt; implement the Y-combinator! [22:35] &lt;matthew&gt; heh [22:35] &lt;paulv&gt; then I'll believe. [22:36] &lt;jweirich&gt; p proc { |le| [22:36] &lt;jweirich&gt; proc { |f| f.call(f) } \ [22:36] &lt;jweirich&gt; .call ( proc { |f| [22:36] &lt;jweirich&gt; le.call (proc { |x| f.call(f).call(x) }) }) [22:36] &lt;jweirich&gt; }.call(proc { |recurse| [22:36] &lt;jweirich&gt; proc { |n| [22:36] &lt;jweirich&gt; if n == 0 then [22:36] &lt;jweirich&gt; 1 [22:36] &lt;jweirich&gt; else [22:36] &lt;jweirich&gt; n * recurse.call (n-1) [22:36] &lt;jweirich&gt; end [22:36] &lt;jweirich&gt; } [22:36] &lt;jweirich&gt; }).call(5) [22:37] &lt;matthew&gt; wow. This is better than gpg keys. [22:37] &lt;matthew&gt; I hope you had that laying around [22:37] &lt;jweirich&gt; nah, did it from memory ;) [22:37] &lt;paulv&gt; this *is* better than GPG keys. </pre> <p>(and for those that missed the winking smiley, no, I did <em>not</em> do this from memory)</p> <h2>Update</h2> <p>I see that Dick Hardt&#8217;s <span class="caps">OSCON 2005</span> presentation on Identity 2.0 is available at <a href="http://www.identity20.com/media/OSCON2005">http://www.identity20.com/media/OSCON2005</a>. This is worth seeing.</p> Cheating at Computer Games http://www.pairprogrammingbot.com/index.cgi/Humor/CheatingAtComputerGames.rdoc <em>One of the most enjoyable programming exercises is writing a computer program that plays a game.</em> <h2>Paper Rock Scissors &#8230;</h2> <p> The weeks Ruby quiz involves writing a simple program to play the game &quot;Paper, Rock, Scissors&quot;. Soon after the comments started on the quiz, someone submitted this 12 line &quot;cheating&quot; program: </p> <pre> class Cheater &lt; Player def initialize opponent Object.const_get(opponent).send :define_method, :choose do :paper end end def choose :scissors end end </pre> <p> It cheats in that it dynamically modifies its opponent object so that it always returns :paper, making it trivial to beat. While it does cheat, it does show some clever &quot;thinking outside the box&quot; approach to playing Paper, Rock, Scissors. </p> <p> This reminds me of a story &#8230; </p> <h2>Greed</h2> <p> A number of years ago, I used to teach C++ in GE&#8217;s after hours education program. One of the projects assigned to the class was writing a player for the game of Greed. Greed is a simple dice game where you score points by rolling a set of 5 dice. You can continue to roll as long as you continue to make points on each roll. However, a row that has no point value causes you to lose <em>all</em> the points for a turn, so there is some value in stopping while you are ahead (hence the name <em>Greed</em>). </p> <p> The game framework handles the dice rolling. All the student&#8217;s prgram had to do was decide whether or not to roll again given the the current state of the dice. </p> <p> As part of the course, I pointed out that the encapsulation and data hiding features of C++ made it difficult to &quot;cheat&quot; by effecting the framework or other player objects. One particular student took this as a challenge and announced that he had a &quot;cheating&quot; player program that stayed within the &quot;rules&quot; setup by the C++ langauge, but yet would always win. </p> <p> How did he do it? This cheating player would record the state of the seed of the standard library&#8217;s random number generator. It would then do trial rolls of the dice until it got a high scoring roll. Then it would reset the random number seed to the value that produced the high scoring roll, and indicate to the game framework that it wanted to roll again. The framework would comply and give the player the high scoring roll that it was setup to do. The cheating player would win the game in a single turn. </p> <p> The cheat was easily defeated (once the cheat was understood) by using a private random number generator that wasn&#8217;t accessible to the player programs. But I learned two things from this exercise: </p> <ol> <li>Programmers love challenges, especially the kind that say &quot;You can&#8217;t do this &#8230;&quot; </li> <li>Secure software is hard to create, particularly because of point 1. </li> </ol> <hr size="2"></hr><ul> <li><a href="http://onestepback.org/cgi-bin/osbwiki.pl?FeedBack/CheatingAtComputerGames">Feedback</a> </li> </ul> Geek Birthday Humor http://www.pairprogrammingbot.com/index.cgi/Humor/GeekBirthdayHumor.rdoc I&#8217;ve had a lot of fun with my birthday this year. I tell people that &#8230; <dl> <dt> </dt><dd><em>I&#8217;m going to turn 30 this year.</em> </dd> </dl> <p> Then I pause and let them do a double take at the graying color of my hair, and then finish with &#8230; </p> <dl> <dt> </dt><dd><em>&#8230; hexadecimal.</em> </dd> </dl> <p> The joke goes over pretty well amongst my geek and programmer friends. However, when used in non-geek company, they just look at me as if I lost my mind. </p> <p> Perhaps I have. </p> Saw this ... http://www.pairprogrammingbot.com/index.cgi/Humor/TopPosting.rdoc in a UseNet signature: <pre> A: No. Q: Is top-posting okay? </pre>