Send PDXRuby mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://lists.pdxruby.org/mailman/listinfo/pdxruby
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]
You can reach the person managing the list at
[EMAIL PROTECTED]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of PDXRuby digest..."
Today's Topics:
1. Top N Values Per Group (Carlos Rodriguez)
2. Re: Top N Values Per Group (Sam Livingston-Gray)
3. Oscon Exhibition Hall Pass (Nick Ames)
4. Re: Oscon Exhibition Hall Pass (John Labovitz)
5. Re: Oscon Exhibition Hall Pass (Max Murphy)
6. RE: Top N Values Per Group (Jason)
7. Re: Oscon Exhibition Hall Pass (Sam Keen)
8. URGENT: We need a working projector for FOSCON (Chris Dawson)
9. Re: URGENT: We need a working projector for FOSCON (Ben
Bleything)
----------------------------------------------------------------------
Message: 1
Date: Tue, 25 Jul 2006 00:14:23 -0700
From: Carlos Rodriguez <[EMAIL PROTECTED]>
Subject: [PDX.rb] Top N Values Per Group
To: [email protected]
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
Hi,
I was hoping that someone could help me with something that's been
stumping me.
I want to do, as the subject suggests, a top N values per group query
and I was wondering if there was a way to do it "The Ruby Way" as
opposed to writing a complicated find_by_sql or some such.
Here it is:
Table Stuff
id
title
category_id
Table Categories
id
name
Stuff has many categories.
Let's say in the Categories table, I have the values "books, dvds,
music, games."
What I want to do is select the first N from each category. So one
(or two or three..., depending what N is) from books, music, dvd, and
games.
I haven't found very many ways to do this in SQL without writing
complicated queries (see this example: http://support.microsoft.com/
kb/210039/en-us) so I was hoping that Ruby\Rails had some magic
coolness that I didn't know about.
Thanks to anyone in advance that can help me.
If you're going to FOSCON, I'll see you there!
Carlos Rodriguez
[EMAIL PROTECTED]
------------------------------
Message: 2
Date: Tue, 25 Jul 2006 08:06:17 -0700
From: "Sam Livingston-Gray" <[EMAIL PROTECTED]>
Subject: Re: [PDX.rb] Top N Values Per Group
To: "Portland Ruby Brigade" <[email protected]>
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
That's exactly the kind of thing that I'd argue makes SQL such a great
language, actually -- it's possible to express this kind of query in
just a few lines. (=
It actually looks like Category has_many :stuff, from the sample table
schema given.
I'm still relatively new to Ruby myself, but perhaps you can get away
with something like this?
items = categories.collect { |c| c.stuff[0..2] }.flatten
(.flatten is optional; a nested array might make it easier to print
category headers in a table. I also assume .stuff is sorted via the
:order parameter to has_many.)
I haven't run the above, so YMMV. Note also that this will query for
the entire contents of both tables; you're essentially trading code
written by speed-hungry database geeks for code running in Ruby. If
performance matters, try find_by_sql as well. Either one should
probably be hidden in a class method on Category for consistency's
sake.
Hope this helps,
-Sam
On 7/25/06, Carlos Rodriguez <[EMAIL PROTECTED]> wrote:
Hi,
I was hoping that someone could help me with something that's been
stumping me.
I want to do, as the subject suggests, a top N values per group query
and I was wondering if there was a way to do it "The Ruby Way" as
opposed to writing a complicated find_by_sql or some such.
Here it is:
Table Stuff
id
title
category_id
Table Categories
id
name
Stuff has many categories.
Let's say in the Categories table, I have the values "books, dvds,
music, games."
What I want to do is select the first N from each category. So one
(or two or three..., depending what N is) from books, music, dvd, and
games.
I haven't found very many ways to do this in SQL without writing
complicated queries (see this example: http://support.microsoft.com/
kb/210039/en-us) so I was hoping that Ruby\Rails had some magic
coolness that I didn't know about.
Thanks to anyone in advance that can help me.
If you're going to FOSCON, I'll see you there!
Carlos Rodriguez
[EMAIL PROTECTED]
_______________________________________________
PDXRuby mailing list
[email protected]
IRC: #pdx.rb on irc.freenode.net
http://lists.pdxruby.org/mailman/listinfo/pdxruby
------------------------------
Message: 3
Date: Tue, 25 Jul 2006 11:30:16 -0700
From: "Nick Ames" <[EMAIL PROTECTED]>
Subject: [PDX.rb] Oscon Exhibition Hall Pass
To: "Portland Ruby Brigade" <[email protected]>
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii"
So what's the deal with the Oscon Exhibition Hall Passes? I remember
hearing/reading that they were free. Anybody got the lowdown?
-Nick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://hosting.planetargon.com/pipermail/pdxruby/attachments/
20060725/f3a51f6d/attachment-0001.htm
------------------------------
Message: 4
Date: Tue, 25 Jul 2006 11:33:45 -0700
From: John Labovitz <[EMAIL PROTECTED]>
Subject: Re: [PDX.rb] Oscon Exhibition Hall Pass
To: Portland Ruby Brigade <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes;
format=flowed
So what’s the deal with the Oscon Exhibition Hall Passes? I
remember hearing/reading that they were free. Anybody got the
lowdown?
They should be free, yes. But I'm not there yet; maybe someone else
can give a more definite answer on how it works?
--John
------------------------------
Message: 5
Date: Tue, 25 Jul 2006 11:34:05 -0700
From: Max Murphy <[EMAIL PROTECTED]>
Subject: Re: [PDX.rb] Oscon Exhibition Hall Pass
To: Portland Ruby Brigade <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="windows-1252"
I think you just need to go to:
http://conferences.oreillynet.com/pub/w/46/register.html
and register for "Exhibition Hall Only" to get your free pass that
you pick up at the convention center.
-Max
On Jul 25, 2006, at 11:30 AM, Nick Ames wrote:
So what’s the deal with the Oscon Exhibition Hall Passes? I
remember hearing/reading that they were free. Anybody got the
lowdown?
-Nick
_______________________________________________
PDXRuby mailing list
[email protected]
IRC: #pdx.rb on irc.freenode.net
http://lists.pdxruby.org/mailman/listinfo/pdxruby
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://hosting.planetargon.com/pipermail/pdxruby/attachments/
20060725/15e76680/attachment-0001.htm
------------------------------
Message: 6
Date: Tue, 25 Jul 2006 15:03:56 -0700
From: "Jason" <[EMAIL PROTECTED]>
Subject: RE: [PDX.rb] Top N Values Per Group
To: "'Portland Ruby Brigade'" <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="US-ASCII"
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Carlos Rodriguez
Sent: Tuesday, July 25, 2006 12:14 AM
To: [email protected]
Subject: [PDX.rb] Top N Values Per Group
Hi,
I was hoping that someone could help me with something that's
been stumping me.
I want to do, as the subject suggests, a top N values per
group query and I was wondering if there was a way to do it
"The Ruby Way" as opposed to writing a complicated
find_by_sql or some such.
Here it is:
Table Stuff
id
title
category_id
Table Categories
id
name
Stuff has many categories.
From your pseudo-schema, it looks more like Stuff "belongs_to"
Category. If
you want Stuff to "have many" Categories, then categories needs to
have the
foreign key (altho I suspect if you didn't want "belongs_to" then
you might
want a has_and_belongs_to_many relationship between stuffs and
categories).
Let's say in the Categories table, I have the values "books,
dvds, music, games."
What I want to do is select the first N from each category.
So one (or two or three..., depending what N is) from books,
music, dvd, and games.
Can you be more specific about what puts a Stuff object at the top?
Is there
a "position" or is it a count of something? (hard to guess since
"Stuff"
could be anything...)
I haven't found very many ways to do this in SQL without
writing complicated queries (see this example:
http://support.microsoft.com/
kb/210039/en-us) so I was hoping that Ruby\Rails had some
magic coolness that I didn't know about.
In any case, if you find that you're doing complex and/or expensive
queries
to get counts on something, you can always add a "count" column to
a model
and use "increment_counter" and "decrement_counter"
http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M000871
- Jason
Thanks to anyone in advance that can help me.
If you're going to FOSCON, I'll see you there!
Carlos Rodriguez
[EMAIL PROTECTED]
------------------------------
Message: 7
Date: Tue, 25 Jul 2006 15:15:25 -0700
From: Sam Keen <[EMAIL PROTECTED]>
Subject: Re: [PDX.rb] Oscon Exhibition Hall Pass
To: Portland Ruby Brigade <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=windows-1252; format=flowed
Max Murphy wrote:
I think you just need to go to:
http://conferences.oreillynet.com/pub/w/46/register.html
and register for "Exhibition Hall Only" to get your free pass that
you
pick up at the convention center.
-Max
On Jul 25, 2006, at 11:30 AM, Nick Ames wrote:
So what’s the deal with the Oscon Exhibition Hall Passes? I remember
hearing/reading that they were free. Anybody got the lowdown?
-Nick
_______________________________________________
PDXRuby mailing list
[email protected] <mailto:[email protected]>
IRC: #pdx.rb on irc.freenode.net
http://lists.pdxruby.org/mailman/listinfo/pdxruby
---------------------------------------------------------------------
---
_______________________________________________
PDXRuby mailing list
[email protected]
IRC: #pdx.rb on irc.freenode.net
http://lists.pdxruby.org/mailman/listinfo/pdxruby
fyi, also I had no issue just showing up and registering for a exhibit
pass last year.
exhibit hall pass gets you this
* Entrance to the Exhibit Hall and all events held in the Exhibit
Hall, including the Exhibit Hall Reception
* Admission to the Products & Services track
<http://conferences.oreillynet.com/cs/os2006/print/e_trak/355>
* Admission to Vendor Presentations held in the Exhibit Hall (see
below for full schedule)
* Access to OSCamp <http://oscamp.org/>
* Access to BOFs
<http://conferences.oreillynet.com/pub/w/46/bof.html>, evening
events <http://conferences.oreillynet.com/pub/w/46/events.html>,
and community meetings
<http://conferences.oreillynet.com/pub/w/46/expo-hall.html>
cheers,
Sam Keen
------------------------------
Message: 8
Date: Tue, 25 Jul 2006 19:29:54 -0700
From: "Chris Dawson" <[EMAIL PROTECTED]>
Subject: [PDX.rb] URGENT: We need a working projector for FOSCON
To: "Portland Ruby Brigade" <[email protected]>
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
I am down at FreeGeek right now. I just turned on their projector and
within a minute the bulb went "pop!" So, I am in the midst of finding
a new one here. However, regardless of whether I find one or not, we
should definitely have a contingency plan. Does anyone have a
projector? I think I recall someone saying they did. I would
recommend that whoever has one, brings it.
I would also recommend that we notify each speaker to test their
presentations at multiple resolutions; lots of projectors work only at
800x600, or 640x480, or whatever.
Can someone let me know ASAP if they have a projector and if they can
bring it? I don't want to spend my night here searching through
mounds of projectors (I've tried three to no avail so far...).
Good news is that the sound system seems to be working well. Speakers
are good and I've cobbled together a wireless microphone system of
sorts.
Thanks,
Chris
------------------------------
Message: 9
Date: Tue, 25 Jul 2006 19:36:53 -0700
From: Ben Bleything <[EMAIL PROTECTED]>
Subject: Re: [PDX.rb] URGENT: We need a working projector for FOSCON
To: Portland Ruby Brigade <[email protected]>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=us-ascii
On Tue, Jul 25, 2006, Chris Dawson wrote:
I am down at FreeGeek right now. I just turned on their projector
and
within a minute the bulb went "pop!" So, I am in the midst of
finding
a new one here. However, regardless of whether I find one or not, we
should definitely have a contingency plan. Does anyone have a
projector? I think I recall someone saying they did. I would
recommend that whoever has one, brings it.
I'm pretty sure we've had this covered for some time. I don't
think we
were ever planning on using the freegeek projector (though someone can
correct me if I'm wrong)
I would also recommend that we notify each speaker to test their
presentations at multiple resolutions; lots of projectors work
only at
800x600, or 640x480, or whatever.
It's probably way too late for anybody to change their presentation at
this point. If we have the projector I think we have, it won't be a
problem anyway.
Can someone let me know ASAP if they have a projector and if they can
bring it? I don't want to spend my night here searching through
mounds of projectors (I've tried three to no avail so far...).
Other FOSCON organizer people: we have a projector lined up,
right? The
wiki says Aaron's bringing his.
Good news is that the sound system seems to be working well.
Speakers
are good and I've cobbled together a wireless microphone system of
sorts.
Rad.
Ben
------------------------------
_______________________________________________
PDXRuby mailing list
[email protected]
http://lists.pdxruby.org/mailman/listinfo/pdxruby
End of PDXRuby Digest, Vol 11, Issue 12
***************************************