1
2
3
4
def transact( objs, actions )
  return true if objs.empty?
...

Ruby On Code transactions

by Wolfbyte, August 20, 2008 09:01 Star_fullStar_fullStar_fullStar_fullStar_full

This version behaves in muc...

861f311cc4a077c439099d0e5d251e73 Talk
1
2
3
def transact( objs, actions )
  (objs.empty? or (objs[0].send(actions[0]) and transact(objs[1..-1],actions) )) or (objs[0].send(actions[1]) and false)
end

Ruby On Code transactions

by Wolfbyte, August 20, 2008 08:19 Star_fullStar_fullStar_fullStar_fullStar_full

Even less readable, but how...

861f311cc4a077c439099d0e5d251e73 Talk

Ruby On Ruby Custom Sort

by Wolfbyte, August 05, 2008 01:37

@macournoyer - Cool. I re-p...

861f311cc4a077c439099d0e5d251e73 Talk

Ruby On Ruby Custom Sort

by Wolfbyte, August 04, 2008 10:52

You can't seem to delete an...

861f311cc4a077c439099d0e5d251e73 Talk
1
2
3
4
require 'csv'

def sort_csv2(filename, fields=["ID"], reverse=false)
...

Ruby On Ruby Custom Sort

by Wolfbyte, August 04, 2008 10:41

This version constructs an ...

861f311cc4a077c439099d0e5d251e73 Talk
1
2
3
4
class Object
  def tap
    yield self if block_given?
...

Ruby On Easy - descending range

by Wolfbyte, August 01, 2008 05:18

To make it easier to extend...

861f311cc4a077c439099d0e5d251e73 Talk
1
2
3
4
byes, heard = 0, true
while byes < 3 do
  puts "Huh?! Speak up, sonny!" unless heard
...

Ruby On Exercise: Deaf Grandma

by Wolfbyte, August 01, 2008 03:11

@Maciej Piechotka - Yep you...

861f311cc4a077c439099d0e5d251e73 Talk

Ruby On Exercise: Deaf Grandma

by Wolfbyte, July 31, 2008 12:55

@houston b-g - You are corr...

861f311cc4a077c439099d0e5d251e73 Talk
1
2
3
4
def granny_can_hear( message )
  message.upcase == message
end
...

Ruby On Exercise: Deaf Grandma

by Wolfbyte, July 30, 2008 01:41

Hey, welcome to ruby. I'm n...

861f311cc4a077c439099d0e5d251e73 Talk
1
2
3
4
def granny_can_hear( message )
  message.upcase == message
end
...

Ruby On Exercise: Deaf Grandma

by Wolfbyte, July 30, 2008 01:40

Hey, welcome to ruby. I'm n...

861f311cc4a077c439099d0e5d251e73 Talk
1
2
3
4
module Enumerable
  def cluster
    c=inject(Hash.new(0)){|h,i|h[i]+=1;h}
...

Ruby On Enumerable#cluster

by Wolfbyte, July 22, 2008 03:05

@Jeremy - Be aware that uni...

861f311cc4a077c439099d0e5d251e73 Talk
1
2
3
4
puts "Yes means No and No means Yes. Delete all files [Y]?"

...

Ruby On BOFH shell login script

by Wolfbyte, July 22, 2008 02:46

OK well the original was da...

861f311cc4a077c439099d0e5d251e73 Talk
1
2
3
4
module Enumerable
  def cluster
    counts = {}
...

Ruby On Enumerable#cluster

by Wolfbyte, July 18, 2008 04:27

How about this that does it...

861f311cc4a077c439099d0e5d251e73 Talk
1
2
3
        /// <summary>
...

C# On I hate to do this, but...

by Wolfbyte, July 17, 2008 01:40 Star_fullStar_full

I can't resist posting the ...

861f311cc4a077c439099d0e5d251e73 Talk
1
2
3
4
require 'rexml/document'

class REXML::Elements
...

Ruby On cleaner way to limit result...

by Wolfbyte, July 15, 2008 05:43

Be wary of converting it to...

861f311cc4a077c439099d0e5d251e73 Talk
1
2
3
4
public static string AsCommaSeparatedValues<T>(this IEnumerable<T> items, Func<T, string> translator)
{
  return items.Select(translator).AsCommaSeparatedValues();
...

C# On Traversing a List and colle...

by Wolfbyte, July 10, 2008 08:22 Star_fullStar_fullStar_fullStar_fullStar_full

Curses! I wasn't logged in ...

861f311cc4a077c439099d0e5d251e73 Talk