1
2
3
#!/usr/bin/env ruby

...

Ruby Sort photos into folders on...

by deepspring.myopenid.com, March 15, 2010 19:07, 1 refactoring, tagged with ruby, sort, photos

Basically, I have a large n...

Avatar Talk
1
2
3
4
        def dedent()
            sRaw    =   self;
            sep     =   "\n";
...

Ruby ruby dedent whitespace in a...

by dreftymac.myopenid.com, March 05, 2010 16:37, 2 refactorings, tagged with ruby, string, monkeypatch

Remove leading whitespace f...

Avatar Talk
1
2
3
4
def hash_from_string(string, value)
  hash, split = {}, string.split(".")
  (split.size-1).downto(0) do |i|
...

Ruby Nested Hash from delimiter-...

by rubiii, March 04, 2010 21:38, 4 refactorings, tagged with ruby, functional

the string can contain 1-n ...

61d580cc983d52f3dc5050a6858fc788 Talk
1
2
3
4
File.open( "binary.bin", "wb" ) do |io|
  obj = BinData::String.new(:initial_value => "Binary file start-point").write(io)      
  obj = BinData::Uint32be.new(:initial_value => 0).write(io)
...

Ruby Creating a binary file with...

by podcaster, March 01, 2010 12:14, 3 refactorings, tagged with binary, ruby, io, bindata

Hi, I'm currently using Bin...

13d7a3ab12ec57e0d372d7115362cb91 Talk
1
2
3
4
    def flights_by_airline(airline_id, flight_number=nil, date=nil, params={})
      if flight_number && date
        t = convert_date(date)
...

Ruby Better way to offer several...

by jarodluebbert.myopenid.com, March 01, 2010 08:21, 3 refactorings, tagged with api, ruby, parameters

I'm wrapping an API in ruby...

3a5f66f6c3feb6092d375c3e145de0d4 Talk
1
2
3
4
# Initial attributes Hash
# 
attributes = {
...

Ruby Ruby Hash Extraction Using ...

by notbrain.myopenid.com, February 24, 2010 23:13, 7 refactorings, tagged with ruby, rails, regex, hash, block

I'm looking for a better wa...

Avatar Talk
1
2
3
def encode
    self[:code] = self[:code].gsub(/\&/, "&amp;").gsub(/\</, "&lt;").gsub(/\>/, "&gt;")
end

Ruby Ruby Html Encode

by codeimpossible, February 14, 2010 03:09, 2 refactorings, tagged with ruby, regular expression

I'm looking for an easier/b...

55997cec217233703cbf68b689578771 Talk
1
2
3
4
  #   code_for(0) => 0
  #   code_for(62) => 10
  #   code_for(124) => 20
...

Ruby Create a baseXX string base...

by adamfortuna, February 11, 2010 18:15, 6 refactorings, tagged with ruby

I'm trying to create Bit.ly...

8571728785e5e350ddb58cd458533b12 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, 7 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, 4 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
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
        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
#!/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
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
def merge_query!(options)
  return unless params[:query]
  statements = []
...

Ruby Merging conditions into an ...

by sferik, November 05, 2009 03:33, 2 refactorings, tagged with ruby, rails, merb

This is some controller cod...

1f74b13f1e5c6c69cb5d7fbaabb1e2cb Talk
1
2
3
4
module PrototypeFaceboxRender
  def render_to_facebox(options = {})
    options[:template] = "#{default_template_name}" if options.empty?
...

Ruby Prototype Facebox Render

by Stephane Paul, November 03, 2009 04:57, 1 refactoring, tagged with ruby, rails, facebox, prototype

I didn't want to add jQuery...

0970617d70dab1f32d8c237808e59c4d Talk
1
2
3
4
User has_many Students
Student has_one ReportCard
ReportCard has_many Metrics
...

Ruby Ruby - Chained collect stat...

by umanghc.myopenid.com, October 23, 2009 23:02, 4 refactorings, tagged with ruby, array

Is there a better way to do...

Avatar Talk
1
2
3
so whats so magical about this Hash?
...

Ruby Magical Hash

by michal.hantl.myopenid.com, October 08, 2009 07:32, 8 refactorings, tagged with ruby, hash, nested hash

Yesterday i wrote this neat...

C2a5bc0633a2eef9274744bd273063a4 Talk
1
2
3
q = "query1=apa&query2=apa2"
Hash[q.split("&").collect{|a| a.split("=")}.flatten]
=> {"query1"=>"apa", "query2"=>"apa2"}

Ruby Parse a querystring

by Simon, October 05, 2009 19:47, 2 refactorings, tagged with ruby, short, fun

I'm looking if someone can ...

865351a8b8bb963c7ee935b3f342854e Talk
1
2
3
<!-- Given the following locals -->
...

Ruby Building params hashes (for...

by sferik, September 30, 2009 19:28, No refactoring, tagged with ruby, rails, merb

This code happens to be for...

1f74b13f1e5c6c69cb5d7fbaabb1e2cb Talk