def apply_credit(credit, tuple)
  num = tuple.shift

...

Ruby On apply a credit over an orde...

by Ben Marini, October 23, 2011 19:18

Recursion seems to fit well...

D85d44a0eca045f40e5a31449277c26c Talk
class Animal
  def queue_event
    with_new_options do
...

Ruby On if/else with code duplication

by Ben Marini, October 01, 2011 12:56

Why not let your subclasses...

D85d44a0eca045f40e5a31449277c26c Talk
class Node < Struct.new(:name, :parent)
  def ancestors
    parent.nil? ? [] : [ parent ] + parent.ancestors
...

Ruby On Parents

by Ben Marini, June 14, 2011 21:27

Here's one way

D85d44a0eca045f40e5a31449277c26c Talk
FILENAMES = Dir["a/certain/dir/*"]

Ruby On Inject all filenames of a s...

by Ben Marini, May 24, 2011 21:22
D85d44a0eca045f40e5a31449277c26c Talk
def disease_search(query)
  treatment_results = Array.new
  symptom_results = Array.new
...

Ruby On Messy Blocks

by Ben Marini, April 07, 2011 15:10

My progressive refactoring,...

D85d44a0eca045f40e5a31449277c26c Talk
class String
  def blank?
    self == ""
...

Ruby On Clear a hash of empty strin...

by Ben Marini, March 16, 2011 05:14
D85d44a0eca045f40e5a31449277c26c Talk
# * Create a factory method for creating events. Make length required.
# * Require start and end times for persistence.
# * Don't allow length to be changed. It is confusing...should the start time
...

Ruby On Event: set end time based o...

by Ben Marini, November 29, 2010 02:32 Star_fullStar_fullStar_fullStar_full

My thought is the interface...

D85d44a0eca045f40e5a31449277c26c Talk
class TriangleError < StandardError; end

def triangle(a, b, c)
...

Ruby On Triangles

by Ben Marini, October 18, 2010 15:36 Star_fullStar_fullStar_fullStar_fullStar_full
D85d44a0eca045f40e5a31449277c26c Talk
module Actions
  attr_accessor :prefix

...

Ruby On instance extending problem

by Ben Marini, July 18, 2010 20:56 Star_fullStar_fullStar_fullStar_fullStar_full

String is not outputting th...

D85d44a0eca045f40e5a31449277c26c Talk
res = arr.group_by { |f| [f.status_id, f.profile_id] }.values

Ruby On group objects in array

by Ben Marini, March 31, 2010 00:27 Star_fullStar_fullStar_fullStar_fullStar_full

You don't need to do a sele...

D85d44a0eca045f40e5a31449277c26c Talk
require 'rubygems'
require 'active_support'
Foo = Struct.new(:id, :status_id, :profile_id)
...

Ruby On group objects in array

by Ben Marini, March 29, 2010 15:13

#group_by does what you nee...

D85d44a0eca045f40e5a31449277c26c Talk

Ruby On Symplify few loops

by Ben Marini, February 03, 2010 16:09

Here's my functional versio...

D85d44a0eca045f40e5a31449277c26c Talk
module Bitmap
  def self.bgr_to_rgba(raw_bgr_array, width, height, new_dimension)
    width_padding  = new_dimension - width
...

Ruby On Symplify few loops

by Ben Marini, February 03, 2010 16:09 Star_fullStar_fullStar_fullStar_fullStar_full

Here's my functional versio...

D85d44a0eca045f40e5a31449277c26c Talk

Ruby On Symplify few loops

by Ben Marini, January 31, 2010 20:33

I'd like to help out, but I...

D85d44a0eca045f40e5a31449277c26c Talk
<?php
  // Benchmarks for writes and reads, separated.
  $times = 10000;
...

PHP On How should I optimize this ...

by Ben Marini, December 08, 2009 08:13

Your benchmarking code is b...

D85d44a0eca045f40e5a31449277c26c Talk
class Channel < Struct.new(:name, :pages)
end

...

Ruby On Can this be less clunky?

by Ben Marini, November 30, 2009 17:26

I'm with Daniel, the source...

D85d44a0eca045f40e5a31449277c26c Talk
<?php
  // $id = Request::get("id");
  class Request {
...

PHP On An easy one: traversing thr...

by Ben Marini, November 16, 2009 17:15 Star_fullStar_fullStar_full

I might be tempted to do so...

D85d44a0eca045f40e5a31449277c26c Talk

Ruby On lexer

by Ben Marini, November 13, 2009 21:31

Sounds like something you i...

D85d44a0eca045f40e5a31449277c26c Talk
module Prototype
  klasses = { 
    "com.utils"  => [ 'guimodel.PresentationEntry', 'guimodel.PresentationGroup'],
...

Ruby On JRuby : including Java clas...

by Ben Marini, November 07, 2009 00:08

Does this not work?

D85d44a0eca045f40e5a31449277c26c Talk
def color_range(start,finish, intervals)
  range = Range.new(start[1..-1].hex, finish[1..-1].hex)
  incr  = (range.last - range.first) / intervals
...

Ruby On Fading from one color to an...

by Ben Marini, November 04, 2009 21:15 Star_fullStar_fullStar_fullStar_fullStar_full

I think this does what you ...

D85d44a0eca045f40e5a31449277c26c Talk
<?php
  date_default_timezone_set("GMT");

...

PHP On Determine whether it's day ...

by Ben Marini, November 03, 2009 03:10 Star_fullStar_full

First off, your $latitude a...

D85d44a0eca045f40e5a31449277c26c Talk

Ruby On Adding an object with acces...

by Ben Marini, October 11, 2009 20:50

Jim Weirich's builder gem f...

D85d44a0eca045f40e5a31449277c26c Talk
c = {}
c[:label1] = MyObject.new("label1", "value1")

Ruby On Adding an object with acces...

by Ben Marini, October 08, 2009 06:57

Is the only point of Object...

D85d44a0eca045f40e5a31449277c26c Talk
# Method 1 (Using ObjectContainer)
obj = MyObject.new("label", "value")
container = ObjectContainer.new
...

Ruby On Adding an object with acces...

by Ben Marini, October 08, 2009 06:53

Seems to me like you might ...

D85d44a0eca045f40e5a31449277c26c Talk
@total_pages = total.quo(per_page).ceil

Ruby On Pagination total page count

by Ben Marini, October 07, 2009 06:44

A variation that's arguably...

D85d44a0eca045f40e5a31449277c26c Talk