1 2 3 4
key = [:fact_id, :image_id, :video_id, :community_idea_id, :stock_ad_id].detect {|k| params.has_key?(k)} if key ...
Ruby On Ugly IF, ELSE
by danielharan,
December 18, 2009 17:13
1 2 3 4
require 'ostruct' class Page < OpenStruct ...
Ruby On Can this be less clunky?
by danielharan,
November 26, 2009 16:53
I'd avoid the confusing has...
1 2 3 4
def has_only_widgets_or_doohickeys? @item.widgets.blank? || @item.doohickeys.blank? end ...
Ruby On 6 embarassingly ugly line m...
by danielharan,
November 23, 2009 04:42
The people on StackOverflow...
1 2 3 4
@subscriptions = [:free, :lite, :brisk, :jammin].inject({}) do |result, ele| result[ele] = SubscriptionType.make(ele) result ...
1 2 3 4
def self.merge_sum_new(*hashes) returning(Hash.new {|h,k| h[k] = 0}) do |new_hash| hashes.each do |hash| ...
Ruby On Total the values in multipl...
by danielharan,
July 08, 2009 02:03
Using Rails' K combinator, ...
Ruby On Create user, company and ro...
by danielharan,
May 04, 2009 21:35
Check out giraffesoft's act...
1 2 3 4
pp 'The green hat is the twin of the green hat'.downcase.split.to_freq_hash # from http://github.com/danielharan/support/blob/14178d993a566d8d2e583c24591f4e381e49d327/lib/support/array_ext.rb ...
1 2 3 4
URL url = new URL("https://dev.psigate.com:7989/Messenger/XMLMessenger"); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.setDoInput(true); ...
Java PSiGate
This seems particularly egr...
1 2 3 4
def haar_1d(a) r = [] (Math.log(a.length) / Math.log(2) - 1).to_i.downto(0) { |j| ...
Ruby On Fast Haar Wavelet Transform
by danielharan,
January 26, 2009 04:31
Oy, I'd want unit tests bef...
1 2 3 4
open("output.txt", 'a') do |file| 1000.times do file.puts create_word('cvcvv') + '.com' ...
Ruby On Web2.0 Domain Name Generator
by danielharan,
December 08, 2008 14:13
Devin, your second entry gi...
1 2 3 4
def image_path(type) img_url = "http://s3.carfinancechief.com.au" photo = find_photo("F") ...
1 2 3 4
a = [['a', '1'], ['b', '2', '3']] p Hash[*a.flatten] ArgumentError: odd number of arguments for Hash ...
Ruby On Conversion from the 2d arra...
by danielharan,
October 22, 2008 14:41
Actually, I assumed it was ...
1 2 3 4
def setup_search @timetable = Timetable.find( :first, :conditions => [ 'day = ? AND status = "active"', params[:id] ] ...
Ruby On lengthy if statement. (Ruby...
by danielharan,
October 22, 2008 02:43
Here's what I'd be aiming f...
1 2 3 4
def search Course.paged_search nil, nil, nil, params[:page] # ... add breadcrumb and course_categories ...
Ruby On Search with fulltext, ago-c...
by danielharan,
October 07, 2008 14:40
Is this what's going on whe...
1 2 3 4
class ReportReader def initialize(file_name) @lines = File.open(file_name).read.split("\n") ...
Ruby On Parsing non-delimited text
by danielharan,
October 06, 2008 13:54
Separate out parsing logic ...
Ruby On Map fields array and data a...
by danielharan,
September 22, 2008 17:07
It's rather odd not to know...
1
biggest_square = [1,4,3,5].inject(0){ |memo, i| [memo, square(i)].max }
Ruby On Conditional Assignment
by danielharan,
September 22, 2008 16:34
I sent MA a link to your re...


This smells of too many res...