<?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>fleshyorgans &#187; ruby</title> <atom:link href="http://fleshy.org.nz/tag/ruby/feed/" rel="self" type="application/rss+xml" /><link>http://fleshy.org.nz</link> <description>Essays from a guy with too much pontification on his hands</description> <lastBuildDate>Tue, 10 Jan 2012 06:16:41 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Coding: Rails Issues with :include</title><link>http://fleshy.org.nz/2008/02/23/coding-rails-issues-with-include/</link> <comments>http://fleshy.org.nz/2008/02/23/coding-rails-issues-with-include/#comments</comments> <pubDate>Sat, 23 Feb 2008 17:10:26 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[code]]></category> <category><![CDATA[rails]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/2008/02/23/coding-rails-issues-with-include/</guid> <description><![CDATA[This is a sort of code analysis and something I discovered with :include usage in Rails. (This is in rails 1.1.6, so YMMV. I believe the latest Rails opts to use inner SELECTs rather than JOIN statements. Also, this is kind of long.) I have the following association set that represents a document repository. User [...]]]></description> <content:encoded><![CDATA[<p>This is a sort of code analysis and something I discovered with :include usage in Rails. (This is in rails 1.1.6, so YMMV. I believe the latest Rails opts to use inner SELECTs rather than JOIN statements.</p><p> Also, this is kind of long.)<br
/> <span
id="more-805"></span></p><p> I have the following association set that represents a document repository.<br
/> <br/><br
/> User 1-n Folders<br
/> User 1-n Roles<br
/> Folder 1-n Documents<br
/> Documents n-n Brands<br
/> <br/><br
/> Folders n-n Viewer Roles<br
/> Folders n-n Manager Roles<br
/> <br/><br
/> Lastly, Users n -(polymorphic through)- n Brands</p><p> In order to display a tree of Folders a given user can view, that User must<br
/> be a manager or viewer of a Folder, and his Brands contain Brand of at<br
/> least one Document under that Folder (a Document associated with a Brand under a folder lets the user view that Folder iff that user has the Brand.)</p><p> So the way this was originally implemented was a recursive loop<br
/> something like this:</p><blockquote><p> def show_subfolders(folder)<br
/> User.folders.each do |folder|<br
/> show_subfolders(folder)<br
/> end<br
/> end</p><p>Class User<br
/> def folders<br
/> Folder.find(:all,:conditions => &#8216;parent = folder&#8217;,<br
/> :include => [:manager_roles, :viewer_roles, {:documents => :brands]]<br
/> ).each do<br
/> |folder|<br
/> if method_to_check_brands(folder) &#038;&#038; method_to_check_view_perms(folder)<br
/> yield(folder)<br
/> end<br
/> end<br
/> end</p></blockquote><p> The eventual problems that developed with this logic were the following:</p><ol><li>second-level includes are problematic in Rails, this generated<br
/> outer joins against seven tables</li><li>massive join, recursively called. I believe the Big O* is (c!)^n,<br
/> glancing quickly</li><li>Indexes don&#8217;t help, because the outer joins sort of blow the<br
/> performance gains away</li><li>All data is being selected, so just sheer amount of data transfer<br
/> slowed things down</li><li>The yield adds a lot of crap to the callstack</li><li>Brand and View/Manage permissioning was already happening in the code</li></ol><p> With 245 documents under 30 folders, mysql logged slow queries that<br
/> had to examine 320,000 rows &#8212; and that was multiple times.</p><p> The solution? Remove the :includes. Since permissioning and<br
/> restriction was already happening in code, I let Rails do its own<br
/> thing and select when necessary. This lowered the response time from<br
/> 10+ seconds for page view to 0.5 seconds. (And for what it&#8217;s worth,<br
/> doing the join statements manually, or removing the second-level :includes only brings it down to 2 or 3 seconds.)</p><p>By reducing the stuff that needs to join, indices are are used more<br
/> efficiently, and letting Rails do a find for Folder.documents on each<br
/> iteration ends up being a lot faster than trying to join with the<br
/> view/manage/brands permissions.</p><p> The More You Know!</p><p>* It&#8217;s been over a decade since I actually figured out the order of an algorithm. I&#8217;m sort of guessing, here.</p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2008/02/23/coding-rails-issues-with-include/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Operator Precedence (ruby et al.)</title><link>http://fleshy.org.nz/2008/02/01/operator-precedence-ruby-et-al/</link> <comments>http://fleshy.org.nz/2008/02/01/operator-precedence-ruby-et-al/#comments</comments> <pubDate>Fri, 01 Feb 2008 15:20:32 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/2008/02/01/operator-precedence-ruby-et-al/</guid> <description><![CDATA[Thought this was a little silly, but it generated a lot of discussion about precedence, short-circuiting of conditionals, and the value of syntactic sugar. http://pastie.caboo.se/146194]]></description> <content:encoded><![CDATA[<p>Thought this was a little silly, but it generated a lot of discussion about precedence, short-circuiting of conditionals, and the value of syntactic sugar.<br
/> <script src='http://pastie.org/146194.js'></script><br
/> <a
href="http://pastie.caboo.se/146194">http://pastie.caboo.se/146194</a></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2008/02/01/operator-precedence-ruby-et-al/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Quick and dirty hack for acts_as_attachment file movement</title><link>http://fleshy.org.nz/2007/12/10/quick-and-dirty-hack-for-acts_as_attachment-file-movement/</link> <comments>http://fleshy.org.nz/2007/12/10/quick-and-dirty-hack-for-acts_as_attachment-file-movement/#comments</comments> <pubDate>Mon, 10 Dec 2007 20:59:17 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/786</guid> <description><![CDATA[Say you&#8217;re working on something that uses acts_as_attachment. Also say that the person who wrote it decided that all the different models&#8217; attachments would save in the same place. Also suppose that you want to change the file location of all those uploads. Well, here&#8217;s a quick and dirty migration that&#8217;ll save you from moving [...]]]></description> <content:encoded><![CDATA[<p>Say you&#8217;re working on something that uses acts_as_attachment. Also say that the person who wrote it decided that all the different models&#8217; attachments would save in the same place. Also suppose that you want to change the file location of all those uploads.</p><p><em>Well</em>, here&#8217;s a quick and dirty migration that&#8217;ll save you from moving files manually.</p><p><a
href="http://pastie.caboo.se/126613">Automove Files for Storage Changes, with acts_as_attachment</a></p><p>Originally I wanted to do something like  Attachment.new( OldAttachment.find(?).attributes ), but there were issues with that because acts_as_attachment wants uploaded data to be a tmp file or some crap. This ended up being the easier way, all in all.</p><p>Use with care.<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/12/10/quick-and-dirty-hack-for-acts_as_attachment-file-movement/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>PHP and Payflow Pro FOR THE LOSE</title><link>http://fleshy.org.nz/2007/10/29/php-and-payflow-pro-for-the-lose/</link> <comments>http://fleshy.org.nz/2007/10/29/php-and-payflow-pro-for-the-lose/#comments</comments> <pubDate>Mon, 29 Oct 2007 20:51:55 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[php]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/774</guid> <description><![CDATA[Posting this cause I wan&#8217;t aware and the only other post I found was dated January. Since Paypal purchased Verisign they are discontinuing the pfpro extension to PHP. And in fact, what I&#8217;m reading is that Sept 2009 is the end of life for that functionality, meaning requests will not work beyond that point. For [...]]]></description> <content:encoded><![CDATA[<p>Posting this cause I wan&#8217;t aware and the only other post I found was dated January.</p><p>Since Paypal purchased Verisign they are discontinuing the pfpro extension to PHP. And in fact, what I&#8217;m reading is that Sept 2009 is the end of life for that functionality, meaning requests will not work beyond that point.</p><p>For sites using pfpro that ned to transition, the solution is<br
/> 1) use the java sdk<br
/> 2) use the .net sdk<br
/> 3) write your own api to utilize curl and https<br
/> 4) use a public api for curl and https a la <a
href="http://www.paypaldeveloper.com/pdn/board/message?message.uid=28775#U28775">This post from the paypal developer forum</a></p><p>ALSO&#8230;<br
/> this means if you&#8217;re installing a 64 bit system, you&#8217;re pretty much screwed because there are no new libraries/binaries released for pfpro under that platform&#8230; unless you&#8217;re running a .net or java solution.</p><p>Sucks.</p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/10/29/php-and-payflow-pro-for-the-lose/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>My tools for development under Ubuntu</title><link>http://fleshy.org.nz/2007/08/29/my-tools-for-development-under-ubuntu/</link> <comments>http://fleshy.org.nz/2007/08/29/my-tools-for-development-under-ubuntu/#comments</comments> <pubDate>Thu, 30 Aug 2007 02:03:29 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[gnome]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[ruby]]></category> <category><![CDATA[ubuntu]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/758</guid> <description><![CDATA[My work machine recently developed the click of death, so I had to get a new hard drive and reinstall everything. Just in case this happens again, and in case anyone else is interested, below is the list of things I install in addition to the standard Ubuntu installation: Development build-essential ruby1.8, librubymysql, ruby-devel,gems mysql [...]]]></description> <content:encoded><![CDATA[<p>My work machine recently developed the click of death, so I had to get a new hard drive and reinstall everything. Just in case this happens again, and in case anyone else is interested, below is the list of things I install in addition to the standard Ubuntu installation:<br
/> <span
id="more-758"></span><br
/> <strong>Development</strong></p><ul><li>build-essential</li><li>ruby1.8, librubymysql, ruby-devel,gems</li><li>mysql</li><li>vim-full (ruby, perl, etc)</li><li>subversion</li><li>kernel-headers</li><li>exuberant ctags</li></ul><p><strong>Config</strong></p><ul><li>nvidia-glx</li><li>envy</li><li>gnome-color-chooser</li></ul><p><strong>Graphics</strong></p><ul><li>inkscape</li><li>gimpshop</li></ul><p><strong>Connectivity</strong></p><ul><li>synergy</li><li>ssh-server</li><li>citrix client</li><li>sshfs</li><li>nfs</li><li>smbfs</li></ul><p><strong>Misc</strong></p><ul><li>firefox extensions</li><li>compiz-fusion</li><li>amarok</li><li>restricted codecs (w32codecs, mp3, flash, etc)</li><li>msttcorefonts</li><li>gmail-notifier</li><li>tilda</li><li>vmware-server</li><li>opera</li><li>ies4linux</li></ul><p>There are a bunch of other things I have to set up as well, such as NFS mounting the dev server, installing Vim plugins, and reinstalling my Firefox extensions, but for the most part it took about an hour and a half from the start of install to finish for me to get my box up and running nicely again. I really like Ubuntu&#8217;s package management <img
src='http://fleshy.org.nz/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p><p><strong>Protip:</strong> Put your dot files (such as .gaim or .vimrc) into subversion. Makes migrating and recovering from HDD failure very easy.<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/08/29/my-tools-for-development-under-ubuntu/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>How I got ruby 1.8.5 on a Red Hat 7.3 box</title><link>http://fleshy.org.nz/2007/07/24/how-i-got-ruby-185-on-a-red-hat-73-box/</link> <comments>http://fleshy.org.nz/2007/07/24/how-i-got-ruby-185-on-a-red-hat-73-box/#comments</comments> <pubDate>Tue, 24 Jul 2007 19:26:19 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[administration]]></category> <category><![CDATA[api]]></category> <category><![CDATA[config]]></category> <category><![CDATA[hacks]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/749</guid> <description><![CDATA[For anyone else who needs to do this: Compiling Ruby 1.8.5 on an ancient redhat box is difficult. It&#8217;s not as simple as just make/make install&#8230; it doesn&#8217;t work right out of the box. My solution was to statically link ruby during compilation. Grab the source Extract Do &#8220;./configure&#8221; Edit ext/Setup (a text file), and [...]]]></description> <content:encoded><![CDATA[<p>For anyone else who needs to do this:</p><p>Compiling Ruby 1.8.5 on an ancient redhat box is difficult. It&#8217;s not as simple as just make/make install&#8230; it doesn&#8217;t work right out of the box. My solution was to statically link ruby during compilation.</p><ol><li>Grab the source</li><li>Extract</li><li>Do &#8220;./configure&#8221;</li><li>Edit ext/Setup (a text file), and uncomment everything except for<ol><li>openssl (unless you have openssl 0.9.7 or higher)</li><li>pty</li><li>Wil32API</li><li>win32ole</li></ol></li><li>Move ext/openssl out of the install directory</li><li>&#8216;make&#8217;</li><li>su, then &#8216;make install&#8217;</li></ol><p>This got me a working ruby installation, minus openssl and pty. The problems I was running into were library related, mainly glibc, libssl, and crypt libraries. It&#8217;s certainly possible to get a working installation without all the monkeying around with statically linked executables, but I was running a risk of destabilizing the rest of the system by doing that.</p><p>Note: Your Mileage May Vary</p><p>Good luck!<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/07/24/how-i-got-ruby-185-on-a-red-hat-73-box/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Ruby Braces vs. Do/End blocks</title><link>http://fleshy.org.nz/2007/07/23/ruby-braces-vs-doend-blocks/</link> <comments>http://fleshy.org.nz/2007/07/23/ruby-braces-vs-doend-blocks/#comments</comments> <pubDate>Mon, 23 Jul 2007 15:57:41 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/748</guid> <description><![CDATA[When parentheses are important: So, braces have higher precedence over do/end blocks. According to Pickaxe, when calling a method with no parentheses, the braces will be applied to the last method parameter, do will be applied to the invocation. A Very Contrived Example: def string_to_integer &#160;&#160;if block_given? &#160;&#160;&#160;&#160;yield.to_i &#160;&#160;else &#160;&#160;&#160;&#160;0 &#160;&#160;end end a = [1,2,3] [...]]]></description> <content:encoded><![CDATA[<p><strong>When parentheses are important:</strong><br
/> So, braces have higher precedence over do/end blocks. According to Pickaxe, when calling a method with no parentheses, the braces will be applied to the last method parameter, do will be applied to the invocation.</p><p>A Very Contrived Example:<br
/> <code><br
/> def string_to_integer<br
/> &nbsp;&nbsp;if block_given?<br
/> &nbsp;&nbsp;&nbsp;&nbsp;yield.to_i<br
/> &nbsp;&nbsp;else<br
/> &nbsp;&nbsp;&nbsp;&nbsp;0<br
/> &nbsp;&nbsp;end<br
/> end<br
/> a = [1,2,3]<br
/> </code><br
/> A) a.inject string_to_integer { &#8217;5&#8242; } do |i,sum| i + sum end => 11<br
/> B) a.inject string_to_integer { |i,sum| i + sum }   => undefined method error<br
/> C) a.inject string_to_integer do  |i,sum| i + sum end   => 6</p><p>in A, the first brace is sent to the string_to_integer method<br
/> in B, the same happens, but the block was actually meant for inject<br
/> in C it works as intended.</p><p>Just food for thought.</p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/07/23/ruby-braces-vs-doend-blocks/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Ruby and processing character sets</title><link>http://fleshy.org.nz/2007/07/19/ruby-and-processing-character-sets/</link> <comments>http://fleshy.org.nz/2007/07/19/ruby-and-processing-character-sets/#comments</comments> <pubDate>Thu, 19 Jul 2007 19:52:18 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/745</guid> <description><![CDATA[Posting this because it&#8217;s been difficult for me to find resources on how to convert between different character encodings, such as Windows-1252 (cp1252) to UTF-8 or ISO-8859-1. It took me about a day to discover some of these libraries. Maybe I wasn&#8217;t searching for the correct keywords &#8212; dunno. require 'iconv' require 'charguess' # Reads [...]]]></description> <content:encoded><![CDATA[<p>Posting this because it&#8217;s been difficult for me to find resources on how to convert between different character encodings, such as Windows-1252 (cp1252) to UTF-8 or ISO-8859-1. It took me about a day to discover some of these libraries. Maybe I wasn&#8217;t searching for the correct keywords &#8212; dunno.</p><p><code><br
/> require 'iconv'<br
/> require 'charguess'<br
/> # Reads an arbitrary file and attempts to convert to a new file in UTF-8<br
/> # Sort of quick and dirty<br
/> # You should note that Iconv.conv will barf if you specify<br
/> # a source encoding that doesn't match the actual source encoding<br
/> def poop_out_utf8(infile, outfile)<br
/> &nbsp;&nbsp;if infile == outfile<br
/> &nbsp;&nbsp;&nbsp;&nbsp;puts 'Source and destination are the same, silly!"<br
/> &nbsp;&nbsp;&nbsp;&nbsp;return<br
/> &nbsp;&nbsp;end<br
/> &nbsp;&nbsp;out_file = File.new outfile, 'w'<br
/> &nbsp;&nbsp;begin<br
/> &nbsp;&nbsp;&nbsp;&nbsp;File.open(infile, 'r') do |file|<br
/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;file.each_line{|line|<br
/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;out_file.puts Iconv.conv('UTF-8', CharGuess::guess(line),line) unless line.nil?<br
/> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br
/> &nbsp;&nbsp;end<br
/> &nbsp;&nbsp;rescue Exception => e<br
/> &nbsp;&nbsp;&nbsp;&nbsp;puts e<br
/> &nbsp;&nbsp;ensure<br
/> &nbsp;&nbsp;&nbsp;&nbsp;out_file.close<br
/> &nbsp;&nbsp;end<br
/> end<br
/> </code></p><p>You should have iconv already. CharGuess you&#8217;ll need to install yourself, most likely. Grab the <a
href="http://libcharguess.sourceforge.net/">clib here</a>, and the <a
href="http://raa.ruby-lang.org/project/charguess">ruby binding here</a>.</p><p>Assuming you&#8217;ve extracted the clib to /home/user/libcharguess/ (and done the ./configure/make/sudo make install bit), install the ruby charguess bindings with<br
/> <code><br
/> ruby extconf.rb --with-charguess-include=/home/user/libcharguess/cpp/<br
/> make<br
/> make install<br
/> </code><br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/07/19/ruby-and-processing-character-sets/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Observation: Code cleverness == Bad</title><link>http://fleshy.org.nz/2007/05/02/observation-code-cleverness-bad/</link> <comments>http://fleshy.org.nz/2007/05/02/observation-code-cleverness-bad/#comments</comments> <pubDate>Wed, 02 May 2007 19:06:01 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/705</guid> <description><![CDATA[This is inspired by Ruby, but could apply to Perl as well. Situation: class with dynamic, on the fly class method definitions of the form What this does is defines some class methods role1_email_addresses, role2_email_addresses, etc on the fly. Works perfectly, until the first element returned in users is actually an empty email. This is [...]]]></description> <content:encoded><![CDATA[<p>This is inspired by Ruby, but could apply to Perl as well.</p><p>Situation: class with dynamic, on the fly class method definitions of the form<br
/> <script src='http://pastie.org/955714.js'></script></p><p>What this does is defines some class methods role1_email_addresses, role2_email_addresses, etc on the fly.</p><p>Works perfectly, until the first element returned in users is actually an empty email.</p><p>This is an example of writing clever code for succinctness (which is rampant in ruby circles). The problem is this code has bugs, and in order to fix it you have to rewrite it or add extra checks and workarounds. Which means the code is no longer succinct nor clever.</p><p>In my recent experience, that&#8217;s all that overly-clever code gets you. You just end up making extra work for yourself (or the maintainer) down the line.</code><br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2007/05/02/observation-code-cleverness-bad/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>InstantRails Bad!</title><link>http://fleshy.org.nz/2006/06/27/instantrails-bad/</link> <comments>http://fleshy.org.nz/2006/06/27/instantrails-bad/#comments</comments> <pubDate>Tue, 27 Jun 2006 15:27:18 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[rails]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/archives/483</guid> <description><![CDATA[According to Avira antivirus: C:\Documents and Settings\jonw\My Documents\Installs\InstantRails-1.3a-win.zip [0] Archive type: ZIP &#8211;> InstantRails/ruby/bin/ruby.exe [DETECTION] Is the Trojan horse TR/Spy.Ruby.Ka.2.C &#8211;> InstantRails/ruby/bin/rubyw.exe [DETECTION] Is the Trojan horse TR/Spy.Ruby.Ka.2.A [INFO] The file was moved to &#8217;451431cd.qua&#8217;! I don&#8217;t know what&#8217;s up with that.]]></description> <content:encoded><![CDATA[<p>According to <a
href="http://www.avira.com/">Avira</a> antivirus:</p><blockquote><p> C:\Documents and Settings\jonw\My Documents\Installs\InstantRails-1.3a-win.zip<br
/> [0] Archive type: ZIP<br
/> &#8211;> InstantRails/ruby/bin/ruby.exe<br
/> [DETECTION] Is the Trojan horse TR/Spy.Ruby.Ka.2.C<br
/> &#8211;> InstantRails/ruby/bin/rubyw.exe<br
/> [DETECTION] Is the Trojan horse TR/Spy.Ruby.Ka.2.A<br
/> [INFO]      The file was moved to &#8217;451431cd.qua&#8217;!</p></blockquote><p>I don&#8217;t know what&#8217;s up with that.<br
/></p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2006/06/27/instantrails-bad/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Snakes and Rubies</title><link>http://fleshy.org.nz/2005/12/04/snakes-and-rubies/</link> <comments>http://fleshy.org.nz/2005/12/04/snakes-and-rubies/#comments</comments> <pubDate>Sun, 04 Dec 2005 14:36:17 +0000</pubDate> <dc:creator>Jonathan Warner</dc:creator> <category><![CDATA[general]]></category> <category><![CDATA[code]]></category> <category><![CDATA[coding]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[picture]]></category> <category><![CDATA[rails]]></category> <category><![CDATA[ruby]]></category> <guid
isPermaLink="false">http://fleshy.org.nz/yum/?p=344</guid> <description><![CDATA[Adrian (left) and David (right) Yesterday, all the developers from work went to Snakes and Rubies, in Chicago. It was rather fun. This was a seminar/conference for Ruby on Rails and the Django framework for python. Adrian Holovaty is one of the three developers who created the Django framework for Python; initially for use on [...]]]></description> <content:encoded><![CDATA[<div
style="float: right; margin-left: 10px; margin-bottom: 10px;"> <a
href="/pics/index.php?picture=IMG_6404.jpg&#038;directory=snakesandrubies/&#038;maxx=1024&#038;maxy=768&#038;nav=1" title="Adrian Holovaty and David Heinemeier Hansson"><img
src="http://src.sencha.io///pics/index.php?picture=IMG_6404.jpg&#038;directory=snakesandrubies/&#038;maxx=240&#038;maxy=320&#038;nav=0" alt="Adrian Holovaty and David Heinemeier Hansson" style="border: solid 2px #000000;" /></a><br
/> Adrian (left) and David (right)<br
/></div><p>Yesterday, all the developers from <a
href="http://www.lightsky.com/">work</a> went to <a
href="http://snakesandrubies.com/event/">Snakes and Rubies</a>, in Chicago. It was rather fun. This was a <a
href="/pics/index.php?picture=IMG_6401.jpg&#038;directory=snakesandrubies/&#038;maxx=1024&#038;maxy=768&#038;nav=1" title="picture link">seminar/conference</a> for <a
href="http://www.rubyonrails.com/">Ruby on Rails</a> and the <a
href="http://www.djangoproject.com/">Django framework</a> for python.</p><p>Adrian Holovaty is one of the three developers who created the Django framework for Python; initially for use on the <a
href="http://www.lawrence.com/">Lawrence, KS</a> local events and information site.</p><p>David Heinemeier Hansson is the developer who initially began development on the Rails framework for Ruby two years ago, though at this point there are other collaborators, I believe. Rails is used in projects linked off <a
href="http://www.37signals.com/">37 Signals</a>.<br
/> <br
clear="both"/><br
/> <span
id="more-344"></span><br
/> Both presentations were neat, though I will say that I was initially disheartened when <a
href="http://www.loudthinking.com/">David&#8217;s</a> Rails presentation consisted <em>almost entirely of code screenshots</em>. That, at least at first, steered me away and gave me a far better feeling for <em><a
href="http://www.holovaty.com/">Adrian</a></em> and his Django presentation.  It took a little while to get over that and listen without rancor.</p><p>Both technologies are really sweet. For those unaware, they both provide a method to use their respective languages, Ruby and Python, to quickly rock out websites and web applications. What I took away from the event is that they&#8217;re both well-thought and extendable technologies, but Django is aimed to be more of a general purpose site builder for sites with dynamic content and interrelations between that content, whereas Rails is aimed more specifically at the web application construction aspect of things.</p><p>I don&#8217;t know if this is a fair characterization or not, but it&#8217;s what I took away.</p><p>The difference in presentational style makes things difficult when trying to choose one over the other &#8212; Adrian&#8217;s Django presentation was very engaging and entertaining. It was very much a <a
href="http://www.m-w.com/cgi-bin/dictionary?va=proselytizing">proselytizing</a> thrust. David&#8217;s Rails presentation was just&#8230; code. His assumption of the format was that people already were familiar and knew about the framework, and the presentation aspect of the seminar was just fluff or feature displays as a prelude to the QA portion.  It was harder to learn what I, as a developer, could really do with the framework.</p><p>The entire trip home was essentially spent discussing the pros and cons of both as far as we could determine. We&#8217;ll have to just try them both it seems. Very few of our developers know Python and none know Ruby at work &#8212; it will be interesting.</p><p>One other thing to mention, there was a lot of <a
href="http://www.php.net/">PHP</a> bashing going on. Very much in the same religious wars vein as Mac v. PC or Linux v. BSD.  Some of it was valid, but most of it was cheap shots. I just want to mention that what a lot of the PHP bashers fail to realize is it&#8217;s the <em>programmers</em> who write bad PHP code. If you treat PHP as if it were C++ or some other functional language, the coding requirements to write <em>good</em> code are the same. For reference, I have never heard C bashing (aside from bemoaning the use of pointers) from anyone, even though it has a <em>lot</em> of the same issues as PHP. So I say the put-downs were a little off the mark &#8212; it is equally possible to write bad code in Ruby and Python as it is in any other language.</p><p><em>Having said that</em>&#8230; I had an epiphany prompted by one of David&#8217;s comments &#8212; he characterized PHP as the Devil, always prompting you to do bad things. My ephiphany was: This is true, because PHP is basically lazy man&#8217;s C++.</p><p>Examples:</p><ul><li>There is no strong typing, you can do all the nasty C++ stuff you got D&#8217;s for in college, and furthermore, there&#8217;s no compilation. So there&#8217;s no incentive to actually test your code or think about validation or error checking. At least with C you get errors or odd behavior when you try to use an <code>int</code> as a <code>char</code>, and if you have an eventual parse error, you know right off the bat.</li><li>In PHP the language construction is half-assed about being half-assed. You kind of have C-style objects, but they&#8217;re not strict so if you really want you can refer to private data (which only became truly private in PHP5.)</li></ul><p>You&#8217;re set up in a situation where you <em>want</em> to write bad code in the form of shortcuts, inlining what should be functions, and straight declaring what should be objects. It just sets you up, as a developer, to be a poor coder.</p><p>The thing I think people really miss is that you <strong>can</strong> ignore those promptings and write the good code anyway.</p><p>In any event, two of the <em>valid</em> criticisms brought up, namely verbosity and length of applications, are issues I&#8217;d like to get rid of. PHP, like C++ and C, almost requires that your code be extensive and long. For that reason alone, I&#8217;m willing to look at another language solution.</p> ]]></content:encoded> <wfw:commentRss>http://fleshy.org.nz/2005/12/04/snakes-and-rubies/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> </channel> </rss>
