1 2 3 4
def dedent() sRaw = self; sep = "\n"; ...
Ruby ruby dedent whitespace in a...
Remove leading whitespace f...
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-...
the string can contain 1-n ...
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...
Hi, I'm currently using Bin...
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...
I'm wrapping an API in ruby...
1 2 3 4
# Initial attributes Hash # attributes = { ...
Ruby Ruby Hash Extraction Using ...
I'm looking for a better wa...
1 2 3
def encode self[:code] = self[:code].gsub(/\&/, "&").gsub(/\</, "<").gsub(/\>/, ">") end
Ruby Ruby Html Encode
I'm looking for an easier/b...
1 2 3 4
# code_for(0) => 0 # code_for(62) => 10 # code_for(124) => 20 ...
Ruby Create a baseXX string base...
I'm trying to create Bit.ly...
1 2 3 4
def score(dice) count = [0,0,0,0,0,0] ...
Ruby Looking for other/better so...
# Greed is a dice game wher...
1 2 3 4
for y in 0...height for x in 0...width # BGR => RGB & miror y ...
Ruby Symplify few loops
I need to reformat .bmp dat...
1 2 3 4
module FancyDates (1..12).each do |mo| t = Time.mktime(1999,mo) ...
Ruby Cleaner way to define const...
This is code that lets you ...
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
How can I turn this into so...
1 2 3 4
original_file = File.open('content1.txt', 'r') new_file = File.open('master1.txt', 'w') ...
Ruby Making email addresses out ...
I have a text file with jus...
1 2 3 4
def splitlines() sraw = self.to_s sraw = sraw.gsub(/\r\n/,"\n"); ...
Ruby line up delimited text into...
allow any character(s) as t...
1 2 3 4
class Item < ActiveRecord::Base ALL_VOTES = "all_votes" SCORE = "score" ...
Ruby Complex query in Ruby on Ra...
I have a method called rank...
1 2 3 4
require 'net/http' require 'rexml/document' require 'download.rb' ...
Ruby help with processing nzb/xm...
I was bored during ruby cla...
1 2 3 4
#!/usr/bin/env ruby -w require 'rexml/document' ...
Ruby Let me merge my Tomboy notes!
Learning Ruby, and learning...
1 2 3 4
pages.keys.each do |k| logger.debug "Pages for #{k} channel:" ...
Ruby Can this be less clunky?
"pages" is a Hash and conta...
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...
Hi everyone,
I'm trying ...
1 2 3 4
def merge_query!(options) return unless params[:query] statements = [] ...
Ruby Merging conditions into an ...
This is some controller cod...
1 2 3 4
module PrototypeFaceboxRender def render_to_facebox(options = {}) options[:template] = "#{default_template_name}" if options.empty? ...
Ruby Prototype Facebox Render
I didn't want to add jQuery...
1 2 3 4
User has_many Students Student has_one ReportCard ReportCard has_many Metrics ...
Ruby Ruby - Chained collect stat...
Is there a better way to do...
1 2 3
so whats so magical about this Hash?
...
Ruby Magical Hash
Yesterday i wrote this neat...
1 2 3
q = "query1=apa&query2=apa2" Hash[q.split("&").collect{|a| a.split("=")}.flatten] => {"query1"=>"apa", "query2"=>"apa2"}
Ruby Parse a querystring
I'm looking if someone can ...
1 2 3
<!-- Given the following locals -->
...
Ruby Building params hashes (for...
This code happens to be for...
Basically, I have a large n...