1
2
3
4
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
1
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
1
2
3
4
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
1
2
3
4
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
1
2
3
4
<?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
1
2
3
4
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
1
2
3
4
<?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
1
2
3
4
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
1
2
3
4
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
1
2
3
4
<?php
  date_default_timezone_set("GMT");

...

PHP On Determine whether it's day ...

by Ben Marini, November 03, 2009 03:10 Star_fullStar_fullStar_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
1
2
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
1
2
3
4
# 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
1
@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
1
2
3
4
# Case 1: {comma,period} followed by exactly 3 digits and no occurrence of 4+ digits in a row
# Case 2: {comma,period} followed by exactly N digits where N != 3
# Case 3: No commas or periods
...

Perl On Handling both dots and comm...

by Ben Marini, October 03, 2009 02:56

Seems like all of these tes...

D85d44a0eca045f40e5a31449277c26c Talk

Ruby On Loop through Activerecord r...

by Ben Marini, October 02, 2009 14:42

A little more code would he...

D85d44a0eca045f40e5a31449277c26c Talk
1
2
3
4
def destroy_hash_and_increment_clicks(hash_string)
  if hash = advertisement_hashes.find_by_hash_string(hash_string)
    increment!(:clicks) # Need the ! if you want to save to the db immediately
...

Ruby On Incrementing an attribute

by Ben Marini, October 01, 2009 17:21
D85d44a0eca045f40e5a31449277c26c Talk