<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/atom10full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US">
  <title>spatten design - All Comments</title>
  <id>tag:spattendesign.com,2008:mephisto/comments</id>
  <generator uri="http://mephistoblog.com" version="0.7.2">Mephisto Noh-Varr</generator>
  
  <link href="http://spattendesign.com/" rel="alternate" type="text/html" />
  <updated>2008-02-03T13:13:39Z</updated>
  <link rel="self" href="http://feeds.feedburner.com/spattendesign-AllComments" type="application/atom+xml" /><entry xml:base="http://spattendesign.com/">
    <author>
      <name>SONU</name>
    </author>
    <id>tag:spattendesign.com,2007-12-05:82:140</id>
    <published>2008-02-03T13:13:39Z</published>
    <updated>2008-02-03T13:13:39Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2007/12/5/amazon-s3-ruby-and-rails-slides" rel="alternate" type="text/html" />
    <title>Comment on 'Amazon S3, Ruby and Rails slides' by SONU</title>
<content type="html">s3demo $&gt;s3syncer
flowers.jpg ===&gt; spatten_syncdemo:flowers.jpg</content>  </entry>
  <entry xml:base="http://spattendesign.com/">
    <author>
      <name>Sam Livingston-Gray</name>
    </author>
    <id>tag:spattendesign.com,2008-01-27:124:133</id>
    <published>2008-01-27T05:41:17Z</published>
    <updated>2008-01-27T05:41:17Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2008/1/27/rubyize-this-live-in-vancouver-refactoring-3" rel="alternate" type="text/html" />
    <title>Comment on 'Rubyize This: Live in Vancouver.  Refactoring #3' by Sam Livingston-Gray</title>
<content type="html">I use the splat operator regularly (perhaps not daily, but certainly once every week or two).  Among other things, it's a handy way to peel off the first N elements of an arglist and pass the rest along to some other function -- sort of a reverse currying, if you will.  (=

&lt;pre&gt;&lt;code&gt;
def do_something_complicated(*gaggle_of_args)
  foo, bar, *others = *gaggle_of_args
  do_step_one(foo, bar)
  do_step_two(*gaggle_of_args)
end
&lt;/code&gt;&lt;/pre&gt;

Hmm... that example looks a bit crap, actually.  But the splat is still my friend.  And it's clearly time for me to go to sleep.  (=</content>  </entry>
  <entry xml:base="http://spattendesign.com/">
    <author>
      <name>Sam Livingston-Gray</name>
    </author>
    <id>tag:spattendesign.com,2008-01-27:122:132</id>
    <published>2008-01-27T05:29:53Z</published>
    <updated>2008-01-27T05:29:53Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2008/1/27/rubyize-this-live-in-vancouver-refactoring-2" rel="alternate" type="text/html" />
    <title>Comment on 'Rubyize This: Live in Vancouver.  Refactoring #2' by Sam Livingston-Gray</title>
<content type="html">Here's one of the hash-based solutions.  I've never liked the redundancy of doing "foo = Foo.new; foo.do_something; return foo" -- this would look even prettier with ActiveSupport's Object#returning.  But I couldn't get it to include properly, so this will do.  (=

&lt;pre&gt;&lt;code&gt;
#!/usr/bin/env ruby

require 'pp'

# Get data from a file, turn it in to a float, and find the max

module Enumerable
  def value_counts
    h = Hash.new(0)
    each { |e| h[e] += 1 } 
    h
  end
end

lines = File.readlines('random.txt')
histogram = lines.map { |line| line.chomp.to_i }.value_counts

# Print the histogram
pp histogram
puts
histogram.keys.sort.each { |n| puts '*' * histogram[n] }
&lt;/code&gt;&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://spattendesign.com/">
    <author>
      <name>Sam Livingston-Gray</name>
    </author>
    <id>tag:spattendesign.com,2008-01-27:121:131</id>
    <published>2008-01-27T05:17:36Z</published>
    <updated>2008-01-27T05:17:36Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2008/1/27/rubyize-this-live-in-vancouver" rel="alternate" type="text/html" />
    <title>Comment on 'Rubyize this: Live in Vancouver.  Refactoring #1.' by Sam Livingston-Gray</title>
<content type="html">Incorporating some of the feedback I got after showing it, here's my take:

&lt;pre&gt;
&lt;code&gt;
#!/usr/bin/env ruby

# create num random numbers between min and max 
# and print them to a file called file_name, one per line

class Range
  def random_member
    offset = rand(max - min)
    min + offset
  end
end

def create_random_numbers(file_name, range, num)
  File.open(file_name, 'w') do |file|
    num.times { file.puts(range.random_member) }
  end
end

create_random_numbers('random.txt', (0..10), 1000)
&lt;/code&gt;
&lt;/pre&gt;</content>  </entry>
  <entry xml:base="http://spattendesign.com/">
    <author>
      <name>Scott</name>
    </author>
    <id>tag:spattendesign.com,2008-01-27:122:130</id>
    <published>2008-01-27T04:44:32Z</published>
    <updated>2008-01-27T04:44:32Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2008/1/27/rubyize-this-live-in-vancouver-refactoring-2" rel="alternate" type="text/html" />
    <title>Comment on 'Rubyize This: Live in Vancouver.  Refactoring #2' by Scott</title>
<content type="html">I've fixed the bug Owen pointed out in the posted code.</content>  </entry>
  <entry xml:base="http://spattendesign.com/">
    <author>
      <name>Scott</name>
    </author>
    <id>tag:spattendesign.com,2008-01-27:122:129</id>
    <published>2008-01-27T04:42:00Z</published>
    <updated>2008-01-27T04:42:00Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2008/1/27/rubyize-this-live-in-vancouver-refactoring-2" rel="alternate" type="text/html" />
    <title>Comment on 'Rubyize This: Live in Vancouver.  Refactoring #2' by Scott</title>
<content type="html">Hmm.  You're right, Owen.  I guess nobody else had generated random data with numbers in the max bucket.  Sorry about that! -- Scott</content>  </entry>
  <entry xml:base="http://spattendesign.com/">
    <author>
      <name>Owen Rogers</name>
    </author>
    <id>tag:spattendesign.com,2008-01-27:122:128</id>
    <published>2008-01-27T04:19:48Z</published>
    <updated>2008-01-27T04:19:48Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2008/1/27/rubyize-this-live-in-vancouver-refactoring-2" rel="alternate" type="text/html" />
    <title>Comment on 'Rubyize This: Live in Vancouver.  Refactoring #2' by Owen Rogers</title>
<content type="html">similarly, the exclusive range operator should not used on line 31 either.

this is my solution. it could probably be compressed further, but at the expense of readability:

require 'pp'

histogram = []
File.readlines('random.txt').each do |value| 
	i = value.chomp.to_i
	histogram[i] ||= 0
	histogram[i] += 1
end

# Print the histogram
pp histogram
puts
histogram.each { | v | puts "*" * v }</content>  </entry>
  <entry xml:base="http://spattendesign.com/">
    <author>
      <name>Owen Rogers</name>
    </author>
    <id>tag:spattendesign.com,2008-01-27:122:127</id>
    <published>2008-01-27T03:53:29Z</published>
    <updated>2008-01-27T03:53:29Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2008/1/27/rubyize-this-live-in-vancouver-refactoring-2" rel="alternate" type="text/html" />
    <title>Comment on 'Rubyize This: Live in Vancouver.  Refactoring #2' by Owen Rogers</title>
<content type="html">there's a bug in this code -- which is why i wasn't able to get it working today. line 19 should read:
for n in (0 .. max)

if you use the exclusive range operator, it will fail because the histogram array will not initialise all of the necessary values to 0.</content>  </entry>
  <entry xml:base="http://spattendesign.com/">
    <author>
      <name>anonymous</name>
    </author>
    <id>tag:spattendesign.com,2008-01-27:122:126</id>
    <published>2008-01-27T00:55:45Z</published>
    <updated>2008-01-27T00:55:45Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2008/1/27/rubyize-this-live-in-vancouver-refactoring-2" rel="alternate" type="text/html" />
    <title>Comment on 'Rubyize This: Live in Vancouver.  Refactoring #2' by anonymous</title>
<content type="html">oops, should read:  0.upto((data=File.readlines('random.txt').collect {|e| e.chomp!.to_f}).max.to_i) {|i| puts "*" *  data.select{|a| a==i}.size}</content>  </entry>
  <entry xml:base="http://spattendesign.com/">
    <author>
      <name>anonymous</name>
    </author>
    <id>tag:spattendesign.com,2008-01-27:122:125</id>
    <published>2008-01-27T00:54:19Z</published>
    <updated>2008-01-27T00:54:19Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2008/1/27/rubyize-this-live-in-vancouver-refactoring-2" rel="alternate" type="text/html" />
    <title>Comment on 'Rubyize This: Live in Vancouver.  Refactoring #2' by anonymous</title>
<content type="html">oneliner trial:  0.upto((data=File.readlines('random.txt').collect {|e| e.chomp!.to_f}).max.to_i) {|i| puts i.to_s + " " + data.select{|a| a==i}.size.to_s}</content>  </entry>
  <entry xml:base="http://spattendesign.com/">
    <author>
      <name>anonymous</name>
    </author>
    <id>tag:spattendesign.com,2008-01-27:121:123</id>
    <published>2008-01-27T00:25:16Z</published>
    <updated>2008-01-27T00:25:16Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2008/1/27/rubyize-this-live-in-vancouver" rel="alternate" type="text/html" />
    <title>Comment on 'Rubyize this: Live in Vancouver.  Refactoring #1.' by anonymous</title>
<content type="html">shall we start with the following?

def create_random_numbers(file_name, min, max, num)
  File.open(file_name, 'w'){|f| 1.upto(num) {|i| f.puts rand(max-min)+min }}
end</content>  </entry>
  <entry xml:base="http://spattendesign.com/">
    <author>
      <name>Scott</name>
    </author>
    <id>tag:spattendesign.com,2007-11-06:21:111</id>
    <published>2007-12-24T17:54:50Z</published>
    <updated>2007-12-24T17:54:50Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2007/11/6/synching-your-amazon-s3-asset-host-using-capistrano" rel="alternate" type="text/html" />
    <title>Comment on 'Synching Your Amazon S3 Asset Host using Capistrano' by Scott</title>
<content type="html">Oops.  Matt, thanks for pointing that out.  I made the same change to the plugin in the svn repository.  Stuff like this makes me wish I had found a better way to unit test this plugin.  -- Scott</content>  </entry>
  <entry xml:base="http://spattendesign.com/">
    <author>
      <name>Matt Harvey</name>
    </author>
    <id>tag:spattendesign.com,2007-11-06:21:110</id>
    <published>2007-12-24T04:37:28Z</published>
    <updated>2007-12-24T04:37:28Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2007/11/6/synching-your-amazon-s3-asset-host-using-capistrano" rel="alternate" type="text/html" />
    <title>Comment on 'Synching Your Amazon S3 Asset Host using Capistrano' by Matt Harvey</title>
<content type="html">Fixed my problem about the ACL not set to public access by setting the --public-read flag to the options to s3sync.rb on line 183 of recipies/synch_s3_asset_host.rb. The plugin still saved me lots of time. Thanks.</content>  </entry>
  <entry xml:base="http://spattendesign.com/">
    <author>
      <name>Matt Harvey</name>
    </author>
    <id>tag:spattendesign.com,2007-11-06:21:109</id>
    <published>2007-12-24T02:50:35Z</published>
    <updated>2007-12-24T02:50:35Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2007/11/6/synching-your-amazon-s3-asset-host-using-capistrano" rel="alternate" type="text/html" />
    <title>Comment on 'Synching Your Amazon S3 Asset Host using Capistrano' by Matt Harvey</title>
<content type="html">This did everything perfect until I tried to load my site. The ACLs on all the files did not allow them to be world-readable. I don't know why. I just went in with irb and AWS::S3 to fix the ACLs after the fact, but I get the feeling that I must have done something wrong.</content>  </entry>
  <entry xml:base="http://spattendesign.com/">
    <author>
      <name>Scott</name>
    </author>
    <id>tag:spattendesign.com,2007-10-10:8:101</id>
    <published>2007-12-15T05:32:12Z</published>
    <updated>2007-12-15T05:32:12Z</updated>
    <category term="blog" />
    <link href="http://spattendesign.com/2007/10/10/updating-dynamic-dns-on-amazon-ec2" rel="alternate" type="text/html" />
    <title>Comment on 'Updating dynamic DNS on Amazon EC2' by Scott</title>
<content type="html">I know, I really do need to do that.  Before I do that, though I want to update the script to take advantage of instance data. I want to be able to start up a test instance without it clobbering the DNS of my real instance.  -- Scott</content>  </entry>
</feed>
