1
2
3
4
require 'hpricot'

class Parser
...

Ruby Create a Hash from XML usin...

by smacks, June 25, 2009 12:23, No refactoring, tagged with ruby, hpricot, xml, soap, hash

With ruby you could use REX...

34d2ae3f7fdcec853ec24cf85715da96 Talk
1
2
3
4
@team.statements.scoped({ 
               :select => "statements.*, users.first_name",
               :joins => "INNER JOIN users ON users.id = statements.user_id",
...

Ruby Named Scopes in Relations

by sebastian.deutsch.myopenid.com, June 24, 2009 15:38, 1 refactoring, tagged with rails named_scope relation

I have two models: Teams an...

Bfca16459c82a7836c3d5c8d79f0b640 Talk
1
2
3
4
def upgrade_and_restart
  @myvocabulary.upgrade
  nextmyvocabulary = Myvocabulary.draw(current_user.id, params[:position], @myvocabulary.vocabulary.lesson.proficiency.id)
...

Ruby shorten long variable names...

by dive.myopenid.com, June 22, 2009 18:52, 5 refactorings, tagged with rails, models, variable names

I wonder how you make a lin...

6cb63e2304cb64236520d0e3e353c9bc Talk
1
2
3
4
class Message
  def initialize
    right_now = Time.now
...

Ruby Ruby: Date and Time methods

by ravinggenius, June 20, 2009 07:53, 7 refactorings, tagged with ruby, non-rails, sinatra

I have a small Ruby on Rail...

6c13f781b81579be36f2ec1193224db4 Talk
1
2
3
4
def prem(s,nx = [])
  return nx.join if s.empty?
  s.collect { |b| prem(s-[b],nx+[b]) }.flatten
...

Ruby Erlang Riddle for Rubists

by dorkalev, June 13, 2009 06:59, 3 refactorings, tagged with erlang, ruby, permutations

Originally published at htt...

0a5eb48929f4014d1a1bf448517158d5 Talk
1
2
3
4
# stats is an array

@popular_urls = stats.group_by{|s| s.request_uri}.sort_by {|s| s.second.size}.reverse
...

Ruby Extract method

by webandy.myopenid.com, June 12, 2009 15:28, 2 refactorings, tagged with ruby, rails

Hello. This is from my blog...

Avatar Talk
1
2
3
4
<script type="text/javascript">

  
...

Ruby cache the javascript object

by abhijeetgore.myopenid.com, June 12, 2009 12:35, No refactoring

Hi This question is specifi...

51224bdd17878b3b19e8987e9bb336a2 Talk
1
2
3
4
  - @media.in_groups_of(6, false) do |group|
    .row
      = render :partial => 'media/media', :object => group[0] unless group[0].blank?
...

Ruby Iterating An Array - Need t...

by DFischer, June 11, 2009 06:51, 2 refactorings, tagged with ruby rails haml

I have 6 items in a row. Th...

73af4fece11ee3767dc13e89cdc08500 Talk
1
2
3
4
module ActiveSupport
  Inflector.inflections do |inflect|
    inflect.plural(/$/, 's')
...

Ruby Redundant Method Calls

by reprogrammer.myopenid.com, June 10, 2009 23:23, 2 refactorings

What is the best way to sim...

Dde3b34749219173bbf3e07ca710eccc Talk
1
2
3
4
def schema
  raw_schema_json = ActiveSupport::JSON.decode(self.schema_json)
  schema = []
...

Ruby Decoding a json object whil...

by sebastian.deutsch.myopenid.com, June 10, 2009 18:01, 3 refactorings, tagged with ruby, rails, json

I'm decoding a json object....

Bfca16459c82a7836c3d5c8d79f0b640 Talk
1
2
3
4
class Array

   # insert i between each element in the array
...

Ruby Ruby: array intersperse, ef...

by spoonerism.myopenid.com, June 10, 2009 11:00, 4 refactorings, tagged with speed, big O, ruby

Intersperse is a method of ...

A5dbf79f90041e79418a6829d414b46e Talk
1
2
3
4
def current_snapshot
   d = nil
...

Ruby avoid for loops

by inriz.myopenid.com, June 09, 2009 13:16, 2 refactorings, tagged with ruby for loop

hey folks,

how it will l...

Avatar Talk
1
2
3
4
class User < ActiveRecord::Base
  has_many :assets, :foreign_key => 'creator_id'

...

Ruby Change a finder method w/ p...

by saizai.livejournal.com, June 06, 2009 00:16, No refactoring, tagged with rails, activerecord, associations, named_scope

How do I turn this into a h...

237338834f2f8948e862e91392a8c1b4 Talk
1
2
3
      send "Unrecognized command:  #{data}"
      puts "Unrecognized command:  #{data}"

Ruby Two lines: Same argument, ...

by claimid.com/findchris, June 03, 2009 19:20, 4 refactorings

Is there a way to DRY this ...

Avatar Talk
1
2
3
4
module Restfulda
  module Helpers
    def logged_in_as(person, &block)
...

Ruby should_be_restful shoulda m...

by papricek.myopenid.com, May 27, 2009 10:20, No refactoring

I am trying to write a modi...

B04a553de1b8b45433b841bba440cc42 Talk
1
2
3
4
    def self.at_beginning_of_interval(time, interval_type)
      #simple substraction does not (seem) to work for long intervals (summer/winter time ?)
      #and at_beginning_of_hour is not defined
...

Ruby At beginning of interval

by pragmatig, May 24, 2009 18:33, 1 refactoring, tagged with ruby, time, date

This code was necessary sin...

4fc8066b5aeba133f665ec8f30f92a9c Talk
1
2
3
4
# User.rb

def most_wanted_movies
...

Ruby Is there better way to writ...

by abhijeetgore.myopenid.com, May 23, 2009 18:44, 2 refactorings

Hay Guys

Following code...

51224bdd17878b3b19e8987e9bb336a2 Talk
1
2
3
4
desc "Load files from upload directory"
task :load_galleries => :environment do
  dir = ENV["UPLOAD_DIR"]
...

Ruby Rake task to load photos fr...

by ehayes.myopenid.com, May 19, 2009 05:29, 4 refactorings, tagged with rails, rake, background job

I'm using the following Rak...

12d36dd93362054c38e8cb7e71f58802 Talk
1
2
3
4
def process_workspaces
  if at_tags?
    at_tags.each do |at_tag|
...

Ruby Create object and many-to-m...

by tinypixel, May 16, 2009 19:21, No refactoring, tagged with rails

All this code is for doing ...

9389724dc0ba69ce08a6c2786d997931 Talk
1
2
3
acts_as_nested_set
...

Ruby Refactoring of the location...

by Dmitry Polushkin, May 14, 2009 13:09, 1 refactoring, tagged with location selector

It's a Location selector, f...

832ed6ace46d61032151f4e1864c057f Talk
1
2
3
4
module PluginManager
  @plugins = []
  
...

Ruby Plugin Architecture

by samnardoni.myopenid.com, May 13, 2009 22:05, 3 refactorings, tagged with ruby, plugin, architecture

I'm trying to find a simple...

A09a1dfb545dcd352d721ad0ea5aec3e Talk
1
2
3
def create
    logout_keeping_session!
...

Ruby Create user, company and ro...

by Pavel Druzyak, May 04, 2009 13:04, 3 refactorings, tagged with rails

I need create user, company...

E69ea2d40777aad638a6b85041f76140 Talk
1
2
3
4
s = "The green hat is the twin of the green hat"
h = Hash.new(0)
s.split.each do |w|
...

Ruby Count words in a string

by andyjeffries, May 02, 2009 13:41, 15 refactorings, tagged with simple, hash, string strip

This is a coding question I...

5cb7a05b6de4a6655319db9333be429c Talk
1
2
3
4
#!/usr/bin/env ruby
ARGV.map { |arg| arg.each_byte{ |b| printf "%1$08b : %1$-3d : %1$c\n", b }} 
...

Ruby Binary Reference Executable

by Tj Holowaychuk, May 02, 2009 05:53, 4 refactorings

Tinyyyyy ass program to ref...

F1e3ab214a976a39cfd713bc93deb10f Talk
1
2
3
4
  def render_page_hierarchy(roots)
    html = ""
    roots.each do |item|
...

Ruby acts_as_nested_set menu

by papricek.myopenid.com, May 01, 2009 13:53, 1 refactoring

Hi guys, how can be simplif...

B04a553de1b8b45433b841bba440cc42 Talk