1
2
3
4
def self.capture_system(*args)
  args = args.flatten.compact.collect { |arg| arg.to_s }
  return false if args.blank?
...

Ruby Silencing current output, b...

by k776.myopenid.com, February 03, 2010 02:34, No refactoring, tagged with form, output, process, exec, system

Is there a shorter way to d...

74198b06bc9e68739debfe6c23e070d3 Talk
1
2
3
4
def score(dice)
  
  count = [0,0,0,0,0,0]
...

Ruby Looking for other/better so...

by websymphony.blogspot.com, February 02, 2010 21:42, 9 refactorings, tagged with dice game, ruby

# Greed is a dice game wher...

D7b8e44d9c430f24a9426725d4c33480 Talk
1
2
3
4
for y in 0...height
  for x in 0...width
    # BGR => RGB & miror y
...

Ruby Symplify few loops

by darkleo.myopenid.com, January 30, 2010 20:36, 6 refactorings, tagged with ruby, short

I need to reformat .bmp dat...

61f1b34f172ee1fbc1af42ab3ce0eca9 Talk
1
2
3
4
module FancyDates
  (1..12).each do |mo| 
    t = Time.mktime(1999,mo)
...

Ruby Cleaner way to define const...

by erikpukinskis.myopenid.com, January 19, 2010 20:45, 3 refactorings, tagged with ruby, DateTime

This is code that lets you ...

6015f1c7d2c5057f668f4951f3303b28 Talk
1
2
3
Clip.find_by_sql(["select * from clips where not exists
        (select 'clip_id' from histories where histories.clip_id = clips.id
        and histories.user_id = ?) ORDER BY clips.created_at DESC LIMIT 20", user.id])

Ruby ActiveRecord find_by_sql

by David, January 17, 2010 20:52, 5 refactorings, tagged with activerecord, rails, ruby, sql, short

How can I turn this into so...

Avatar Talk
1
2
3
def rot_encode(s, offset=2)
   s.split('').map{ |char| (char.ord + offset).chr }.join
end  

Ruby rot encode

by Sam Figueroa, January 17, 2010 11:44, 5 refactorings, tagged with rot, rotation, encode, strings

Rotation encoding with vari...

45596033957b2b6d7ef8fe6545e0b7e7 Talk
1
2
3
4
original_file = File.open('content1.txt', 'r')
new_file = File.open('master1.txt', 'w')

...

Ruby Making email addresses out ...

by vire7, January 15, 2010 17:46, 1 refactoring, tagged with ruby, text, output

I have a text file with jus...

87f4477dced7fcff3ac2154e88d53210 Talk
1
2
3
4
101.times do |n|

  next if n == 0
...

Ruby Fizz Buzz

by jhindle, January 15, 2010 13:08, 8 refactorings, tagged with fizzbuzz, short

Wrote a Fizz Buzz http://en...

6bff7d5313e73334ef0edc691a7564f7 Talk
1
2
3
4
  module Rack
    class Request
      def subdomains
...

Ruby Personalized URL (Purl) Sub...

by grayfm, January 11, 2010 22:25, No refactoring, tagged with url, rack, sinatra, subdomain, domain

So i need to define @purl_b...

41b76a0d9fd81133d545fb2b994013ab Talk
1
2
3
4
        def splitlines()
            sraw    = self.to_s
            sraw    = sraw.gsub(/\r\n/,"\n");
...

Ruby line up delimited text into...

by dreftymac.myopenid.com, January 11, 2010 17:02, No refactoring, tagged with ruby, delimited, pretty, formatting

allow any character(s) as t...

Avatar Talk
1
2
3
4
class Item < ActiveRecord::Base
  ALL_VOTES = "all_votes"
  SCORE = "score"
...

Ruby Complex query in Ruby on Ra...

by Pablo, January 10, 2010 13:27, No refactoring, tagged with ruby, rails, joins, activerecord, sql

I have a method called rank...

931970b8dc51b72e05e3a12b88612d61 Talk
1
2
3
4
require 'net/http'
require 'rexml/document'
require 'download.rb'
...

Ruby help with processing nzb/xm...

by bain19.myopenid.com, January 09, 2010 23:51, 4 refactorings, tagged with nzb, usenet, download, parse, slow, ruby, xml

I was bored during ruby cla...

642d333608cc3483f64dba38cb81bdd2 Talk
1
2
3
4
# generate(100, 200, 2, 3) =>
#   [[100, 200], [125, 188], [150, 176], [125, 212], [150, 200], [175, 188]]

...

Ruby rotating a rectangle

by slothbear.myopenid.com, January 02, 2010 17:29, 2 refactorings, tagged with geometry

Think of a section of squar...

D40bc12523cf0ac31e001afd996f7c33 Talk
1
2
3
4
  def sort
    if params[:fact_id]
      @fact = Fact.find_by_id(params[:fact_id]) || Fact.new
...

Ruby Ugly IF, ELSE

by serek.openid.pl, December 18, 2009 10:17, 3 refactorings, tagged with rails, short, dry

Trying to make this a lot c...

597821ce12359ab2d95437c8164d5254 Talk
1
2
3
4
namespace :deploy do
  
  require 'net/ssh'
...

Ruby Git deployment rake task

by mdub, December 15, 2009 22:56, 2 refactorings, tagged with git, ssh, deployment, bundler, rake

Simple and FAST frameworkle...

494d68f967700bab431fd7ab45ec85a2 Talk
1
2
3
4
class Array
  def with_indices
    n = 0
...

Ruby Stable sort in ruby

by Kartik Agaram, December 14, 2009 07:05, 7 refactorings, tagged with stable sorting

Ruby's sort isn't stable. L...

14d99459914c594998d2506db1e868c2 Talk
1
2
3
require 'yaml'

...

Ruby YAML Options Class

by Ryguy, December 05, 2009 13:39, No refactoring, tagged with yaml, options

Sets the class Options to r...

Ba665f86f90a1982af7b9c857418fcdb Talk
1
2
3
4
#!/usr/bin/env ruby -w

require 'rexml/document'
...

Ruby Let me merge my Tomboy notes!

by Scott Robinson, December 04, 2009 02:27, 1 refactoring, tagged with ruby, xml, functional

Learning Ruby, and learning...

1945ab4cdb87eaf5a5c906fa884c29f1 Talk
1
2
3
4
pages.keys.each do |k|

      logger.debug "Pages for #{k} channel:"
...

Ruby Can this be less clunky?

by bruno antunes, November 26, 2009 15:40, 4 refactorings, tagged with ruby, hash, find_all

"pages" is a Hash and conta...

1b491994d6011d720e332af6e1ffd03b Talk
1
2
3
  def create
...

Ruby Dynamic admin with Globalize2

by Fenak, November 23, 2009 13:17, 1 refactoring, tagged with rails, i18n, globalize2

I have a multilingual admin...

D21232f63a7065c902362a61b045ed1d Talk
1
2
3
4
      def has_just_one_kind_of_thing?(item, controller)
        if (controller == 'foos' && item.widgets.blank?) || (controller == 'foos' && item.doohickeys.blank?) || (controller == 'bars' && item.widgets.blank?) || (controller == 'bars' && item.doohickeys.blank?) || (controller == 'bazes' && item.widgets.blank?) || (controller == 'bazes' && item.contraptions.blank?)
...

Ruby 6 embarassingly ugly line m...

by chrisadams.me.uk, November 23, 2009 01:16, 3 refactorings, tagged with ruby, when, case

Hi everyone,

I'm trying ...

9c5f7685501ec87178055f41147c75c5 Talk
1
2
3
4
class Numeric
  def evenize(round="+")
    eval "self #{round} (self.modulo(2))"
...

Ruby Numeric#evenize

by scottburton11, November 18, 2009 03:21, 5 refactorings, tagged with ruby numeric

It almost feels stupid to d...

F9bf9d54441b20b8d880313b569cf88d Talk
1
from_date.empty? || ( from_date.empty? == false && role.updated_at > from_date)

Ruby boolean

by macsig.myopenid.com, November 17, 2009 23:44, 2 refactorings

Is there a way to make this...

F4e37ffbbf81653b797ec4cf995a23b1 Talk
1
2
3
4
    def get_token
      self.class.precedence.each do |token|
        if val = send(token)
...

Ruby lexer

by Tj Holowaychuk, November 13, 2009 16:41, 5 refactorings

Everything else in my lib i...

F1e3ab214a976a39cfd713bc93deb10f Talk
1
2
3
4
module Prototype

...

Ruby JRuby : including Java clas...

by marek-kowalcze.myopenid.com, November 06, 2009 19:29, 2 refactorings, tagged with jruby, java

Hi,
i had problems with t...

Ecfe48fba86dbee29f54ad6a7f8aaaa3 Talk