layouts = Dir.glob("_layouts/*")
layouts.each do |layout|
layout.gsub!(/^_layouts\/(.*)\..*$/, '\1')
...
Weeks = [["2012-01-15","2012-01-22"], ["2012-01-22","2012-01-29"], ["2012-01-29","2012-02-05"],["2012-02-05","2012-02-12"], ["2012-02-12","2012-02-19"], ["2012-02-19","2012-02-26"]] ...
Ruby clean the code
by https://www.google.com/accounts/o8/id?id=AItOawlaTnwjQ00W1XCRaUEGIonvKgruTMebfak,
January 30, 2012 03:54,
4 refactorings, tagged with ruby, rails 3
Plz help me clean the code
...
# Start of file, showing the name of the application # Size, and all relevent parts of the title ...
Ruby Address Book
by https://www.google.com/accounts/o8/id?id=AItOawkiJON4MFJ9bopD8IvwQ1pbpH3ag7yrtnI,
December 28, 2011 07:36,
5 refactorings, tagged with ruby, methods, regexp, regular expression
This is a fairly simple add...
#more elegante way? sector = Sector.create(:name => name) unless sector = Sector.find_by_name(sector)
Ruby more elegant way
no ideas about it, rails 3....
#MM-YYYY
"2011-10".split("-").reverse.join("/") => "10/2011"
Ruby parsing date
anyone has the better solut...
def set_name
deal_date = self.deal_date
if (4..12).to_a.include?(self.deal_date.month)
...
Ruby Refactor this code
by https://www.google.com/accounts/o8/id?id=AItOawl-DJ5xgYVFKrrLOGZqwCiGLkx38LeB1cU,
November 10, 2011 21:43,
No refactoring, tagged with ruby, rails3
Please refactor this code.....
"\none\n two\n three".scan(/^( *)\w+/).flatten #=> ["", " ", " "]
Ruby Get rid of useless `flatten`
Hi.
I want to get the ar...
#customers
%table#customerTable
- @customers.each_with_index do |customer, i|
...
Ruby Refactor for table "ge...
by danielz.myopenid.com,
October 02, 2011 03:51,
6 refactorings, tagged with ruby, table, haml, challenge
Hey Guys,
I'm stuck with...
#!/usr/bin/env ruby require 'rubygems' ...
Ruby automatic info plist versio...
I hacked up a script to aut...
require 'set' class StatComputations ...
Ruby Mean Median in Ruby
by https://www.google.com/accounts/o8/id?id=AItOawl0nTuHS77YHoJ_YssSDUGitTHCLZVvgrA,
August 28, 2011 20:10,
1 refactoring, tagged with ruby, ruby1.9, mean, median
Here is the snippet of mean...
@visits_by_day_and_hour = visits.group_by{|day| day.created_at.strftime("%Y-%m-%d")}.map {|d, items| [d, items.group_by{|hour| hour.created_at.strftime("%H")}.map{|k,v| [k, v.length]}]}
Ruby Group array elements by day...
by https://www.google.com/accounts/o8/id?id=AItOawlsPHX5ps6aEa58SFp7fTjKFgMmK9Hi-Dg,
August 07, 2011 23:45,
2 refactorings, tagged with ruby, arrays, group_by, map array
Hi, I have a set of objects...
# Operators => Priority
OPERATORS={
'+' => 0,
...
Ruby Simple tokenizer
Takes a string and returns ...
if @image.update_attributes params[:product_image]
if request.xhr?
render :json => { :status => 'success', :data => {:message => I18n.t('product_image.results.reordered')} }
...
Ruby DRY up a controller action
Any suggestions for DRYing ...
def some_method(format, language) raise Error unless %w(wiki xml).include?(format.to_s) raise Error unless %w(de en).include?(language.to_s) ...
Ruby Check for bounds
I need to check the given i...
module Reopened def reopened ...
Ruby Execute code when a class i...
by dagobah.myopenid.com,
July 15, 2011 05:07,
1 refactoring, tagged with class, ruby, mixins, reopen, trace
Is there a less hacky way t...
module Protected module ClassMethods ...
Ruby Access control on methods
by dagobah.myopenid.com,
July 12, 2011 07:39,
No refactoring, tagged with ruby, mixins, authorization, rbac, modules, access control, keys, locks
Is there a better/more eleg...
class IsbnsController < ApplicationController before_filter :correct_user, :only => [:destroy, :edit, :show, :update, :index, :new, :create] before_filter :correct_user_admin, :only => [:destroy] ...
Ruby Horrific if/else nonsense i...
by https://www.google.com/accounts/o8/id?id=AItOawmBoZDYdn9kg9NpUnuCgDniTetBixwn3iQ,
June 10, 2011 05:16,
2 refactorings, tagged with rails, ruby, if-else
Posting for the comedy/shoc...
a = {}
a["test"] = [] if a["test"].nil?
a["test"] << 5
Ruby Fill Array or create it
How can I write this in a c...
# start here, on_data called where thereis data on a socket(data can be partial-packet) def on_data bytes @stream << bytes ...
Ruby Packet handling in network-app
Just looking for better arc...
The title says it all, I'm ...