class Array
  def count_by
    inject( Hash.new(0) ) do |result, val|
...

Ruby On Array.group_by that counts

by arvanasse, June 30, 2010 13:55 Star_fullStar_fullStar_fullStar_full

Pretty similar to spaghetti...

7855792dbc5f3b4c365344314e2b1ad6 Talk
def twitter_message
  ls = LineStream.new(true)

...

Ruby On Checking validity of messag...

by arvanasse, June 30, 2010 13:41 Star_fullStar_fullStar_fullStar_full

Really like the way spaghet...

7855792dbc5f3b4c365344314e2b1ad6 Talk
class Rule < ActiveRecord::Base
  RULE_TYPES = [:allowed_senders, :blocked_senders, :blocked_character_set, :custom]  
end
...

Ruby On Rails helper method needs r...

by arvanasse, June 30, 2010 13:19

#inject is the best way to ...

7855792dbc5f3b4c365344314e2b1ad6 Talk
class Rule < ActiveRecord::Base
  RULE_TYPES = [:allowed_senders, :blocked_senders, :blocked_character_set, :custom]  
end
...

Ruby On Rails helper method needs r...

by arvanasse, June 30, 2010 13:18

#inject is the best way to ...

7855792dbc5f3b4c365344314e2b1ad6 Talk
Challenger < ActiveRecord::Base
  has_many :challenges, :class_name => 'Fight', :foreign_key => :challenger_id
  has_many :defenses, :class_name => 'Fight', :foreign_key => :challengee_id
...

Ruby On Refactor sanitize_sql_array

by arvanasse, June 21, 2010 16:17 Star_fullStar_fullStar_fullStar_fullStar_full

Why not replace #challenger...

7855792dbc5f3b4c365344314e2b1ad6 Talk
class Store < ActiveRecord::Base
  has_many :promos
...

Ruby On Rails Store has more than m...

by arvanasse, June 08, 2010 14:51 Star_fullStar_fullStar_fullStar_fullStar_full

Your code does not seem to ...

7855792dbc5f3b4c365344314e2b1ad6 Talk
# Assuming something like this
class Badge
  BRONZE_BADGE 10
...

Ruby On how to refactor tricky logi...

by arvanasse, June 07, 2010 14:20 Star_fullStar_fullStar_fullStar_full

Assuming that you call #che...

7855792dbc5f3b4c365344314e2b1ad6 Talk
#!/usr/bin/ruby

class MagicSquare
...

Ruby On Multidimension array and math

by arvanasse, June 04, 2010 13:11
7855792dbc5f3b4c365344314e2b1ad6 Talk
def array_to_params(param_name, params)
  # normalize to an array first
  params = [params] unless params.is_a?(Array)
...

Ruby On Generate post query for array

by arvanasse, June 01, 2010 15:03 Star_fullStar_fullStar_fullStar_fullStar_full

This refactoring does not p...

7855792dbc5f3b4c365344314e2b1ad6 Talk
require 'date'

# Creating this array in the correct order allows you to use the index as the suggested value.
...

Ruby On Simple Ruby Program for cre...

by arvanasse, June 01, 2010 14:42 Star_fullStar_fullStar_fullStar_fullStar_full

Not a bad first attempt. I...

7855792dbc5f3b4c365344314e2b1ad6 Talk
text =
"75
95 64
...

Ruby On I'm having trouble thinking...

by arvanasse, May 25, 2010 15:56

The 'row.length == 1' test ...

7855792dbc5f3b4c365344314e2b1ad6 Talk
text =
"75
95 64
...

Ruby On I'm having trouble thinking...

by arvanasse, May 25, 2010 15:42

Here's a first cut just mak...

7855792dbc5f3b4c365344314e2b1ad6 Talk
list = lists.collect do |list| 
  search(str, list).reject{|s| ignored(s.text)}.collect{|s| { :name=> "#{s.text}", :url => "#{s.url}" } } 
end.flatten

Ruby On Too many each loops

by arvanasse, May 07, 2010 18:58

@jose, if you #inject and s...

7855792dbc5f3b4c365344314e2b1ad6 Talk
list = lists.collect do |list| 
  search(str, list).reject{|s| ignored(s.text)}.collect{|s| { :name=> "#{s.text}", :url => "#{s.url}" } } 
end.flatten

Ruby On Too many each loops

by arvanasse, May 07, 2010 18:58

@jose, if you #inject and s...

7855792dbc5f3b4c365344314e2b1ad6 Talk