1
2
3
4
h = Hash.new([])
h[:a].object_id # => 9762120
h[:b].object_id # => 9762120
...

Ruby On Assignment from array

by Markus Prinz, July 22, 2008 16:34 Star_fullStar_fullStar_fullStar_full

Actually you have to be car...

0176d9564601b43d75aff59f2cceed88 Talk

Ruby On Enumerable#cluster

by Jeremy, July 22, 2008 15:16

@Wolfbyte, good catch. I su...

5170ca260dbd2cdfd5a887a4dba7636f Talk
1
2
3
4
a ||= Hash.new([])  # default value for non-existing keys is now an empty array, unless a was already defined

a[:k] # => []
...

Ruby On Assignment from array

by lel, July 22, 2008 14:15

The above Hash.new can be m...

2fa67a053f1bb83dca069df3c9f51a8a Talk
1
2
3
4
module DashboardHelper
  def activity_message_for(object)
    render :partial => "#{object.class.name.downcase.pluralize}/activity"
...

Ruby On Dashboard

by danielharan, July 22, 2008 12:54

Argh - hopefully now I'm aw...

880cbab435f00197613c9cc2065b4f5a Talk
1
2
3
4
a = Hash.new{|h,k| h[k] = Array.new { nil } }

a[:k] # => []
...

Ruby On Assignment from array

by Markus Prinz, July 22, 2008 11:45 Star_fullStar_fullStar_fullStar_fullStar_full

You could also make the def...

0176d9564601b43d75aff59f2cceed88 Talk
1
a = a[:k][0] || 1 rescue 1

Ruby On Assignment from array

by Ben Hughes, July 22, 2008 11:44

A little crude, but works...

92772ff5353c89d9bd10f8e334161e16 Talk
1
a ||= {} ; a[:k] ||= []; v = a[:k][0]  ||  1

Ruby On Assignment from array

by David Calavera, July 22, 2008 11:15
0c39b828636367fc6e22b7be8c803c74 Talk

PHP On PHP5 Database Clas

by Ishkur, July 22, 2008 03:36

Well if I wanted to go that...

6dc0e9a07bcff97ac9b111f36e12f1f6 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
    self.uniq.sort.map { |u| self.select { |v| u == v } }
...

Ruby On Enumerable#cluster

by Jeremy, July 22, 2008 02:04

This is a pretty clean one-...

5170ca260dbd2cdfd5a887a4dba7636f Talk
1
2
3
4
module DashboardHelper
  def activity_message_for(object)
    render :partial => "#{object.class.name.downcase}/_#{object.class.name.downcase}_activity"
...

Ruby On Dashboard

by danielharan, July 21, 2008 23:01

HTML inside helpers is ugly...

880cbab435f00197613c9cc2065b4f5a Talk
1
2
3
4
module DashboardHelper

  def activity_message_for object
...

Ruby On Dashboard

by Jason Dew, July 21, 2008 22:59 Star_fullStar_fullStar_full

I would consider moving the...

D16d53391068ff0830269149b060789d Talk

PHP On PHP5 Database Clas

by Maciej Piechotka, July 21, 2008 19:24 Star_full

1. Why not PEAR DB?
2. Why ...

1e8f141e7857d397d8020ed3b759e88a Talk

C# On Balance HTML Tags

by Dinah, July 21, 2008 18:09

Has a final version of this...

D97c394b2cf92c49fca089d2484813f3 Talk

C# On Common StProc Code

by robzyc, July 21, 2008 14:19

Great, my thread has been h...

C290d3851c7837081d05b3491cbc331b Talk
1
b(lockquote)?

C# On Sanitize HTML

by Dinah, July 21, 2008 13:45

in the first line of the wh...

D97c394b2cf92c49fca089d2484813f3 Talk
1
2
3
4
 public Parameter parm(string str1, string str2)
    {
        comm.Parameters.Add(str1, SqlDbType.BigInt);
...

C# On Common StProc Code

by aifaz, July 21, 2008 07:43

how can i made class file, ...

0b709acb624bc939041eb9483570d7a6 Talk

Perl On MAC Formatting

by mrxinu, July 21, 2008 06:34

@Marco Brilliant! Thanks ma...

B5603dc8f1e87c251bf9b1d28f31d38f Talk
1
2
3
#!/usr/bin/perl
use strict;
...

Perl On MAC Formatting

by Marco Valtas, July 21, 2008 05:59 Star_fullStar_fullStar_fullStar_fullStar_full

I think there's a million w...

B8d457d2c39911ea4c74ba7d66b9c3f7 Talk
1
2
3
4
#!/usr/bin/perl
use strict;
use warnings;
...

Perl On MAC Formatting

by mrxinu, July 21, 2008 00:33

This occurred to me as I wa...

B5603dc8f1e87c251bf9b1d28f31d38f Talk
1
2
3
4
def self.find_by_url_like(url)
  # make sure url has a scheme before URI parses
  uri = url.match(/^https?:\/\//) ? URI.parse(url) : URI.parse("http://#{url}") 
...

Ruby On Find a URL in a database

by lel, July 18, 2008 23:54

Naming the method find_by_u...

2fa67a053f1bb83dca069df3c9f51a8a Talk
1
2
3
4
module Enumerable
  def cluster
    inject(Hash.new) do |all, one|
...

Ruby On Enumerable#cluster

by Jason Dew, July 18, 2008 23:36 Star_fullStar_fullStar_full

If you don't need the order...

D16d53391068ff0830269149b060789d Talk

Ruby On Find a URL in a database

by Joe Grossberg, July 18, 2008 21:43

I wouldn't make the query d...

F288a8afe5302a16a366d5e9d34f2fec Talk

Ruby On Find a URL in a database

by Joe Grossberg, July 18, 2008 21:42

I wouldn't make the query d...

F288a8afe5302a16a366d5e9d34f2fec Talk