From mghaught at gmail.com Wed Sep 5 23:18:57 2007 From: mghaught at gmail.com (Marty Haught) Date: Wed, 5 Sep 2007 21:18:57 -0600 Subject: [Boulder Ruby Group] BRG - September Meeting - Sep 19th Message-ID: <57f29e620709052018r4c766c48i42cb5ab9039a68e1@mail.gmail.com> The Boulder Ruby group will be holding our monthly meeting in September on the 19th at 6:30. I'm still in the process of lining up speakers for September and October. If any of you have something you'd like to present on or share, please contact me offlist. Check our website for the meeting details as we get closer. I'll update it first. I will also send out the usual last minute reminder a few days before the meeting with the details as well. Cheers, Marty From mghaught at gmail.com Fri Sep 7 13:49:06 2007 From: mghaught at gmail.com (Marty Haught) Date: Fri, 7 Sep 2007 11:49:06 -0600 Subject: [Boulder Ruby Group] RubyConf 2007 registration open Message-ID: <57f29e620709071049q216fe7bak1ea1cd85affb8f38@mail.gmail.com> Shared by Chad it looks like registration is open: http://www.regonline.com/Checkin.asp?EventId=145820 Cheers, Marty From tim.pease at gmail.com Fri Sep 7 15:23:40 2007 From: tim.pease at gmail.com (Tim Pease) Date: Fri, 7 Sep 2007 13:23:40 -0600 Subject: [Boulder Ruby Group] RubyConf 2007 registration open In-Reply-To: <57f29e620709071049q216fe7bak1ea1cd85affb8f38@mail.gmail.com> References: <57f29e620709071049q216fe7bak1ea1cd85affb8f38@mail.gmail.com> Message-ID: <69f66b790709071223w61b66940oabf6ae42fac5ede7@mail.gmail.com> On 9/7/07, Marty Haught wrote: > Shared by Chad it looks like registration is open: > > http://www.regonline.com/Checkin.asp?EventId=145820 > Is anyone planning on attending and looking to share hotel accommodations? TwP From tony at clickcaster.com Fri Sep 14 00:12:39 2007 From: tony at clickcaster.com (Tony Arcieri) Date: Thu, 13 Sep 2007 22:12:39 -0600 Subject: [Boulder Ruby Group] Actor model in Ruby 1.9 Message-ID: I did a simple implementation of the Actor model (i.e. Erlang-style concurrency) using Ruby 1.9's Fibers mechanism. You can check it out here (if you have Ruby 1.9 installed): http://pastie.caboo.se/97050 Fibers are coroutines, which means they're like procs, except at any point they can call Fiber.yield and return control back to the process that started them. The controlling process can resume them with Fiber.resume This implementation adds a mailbox to a Fiber, and an Actor.receive method which runs a filter across the mailbox, wrapping Fiber.yield and calling it if the filter fails to match any of the messages in the mailbox. Here's an example of how to use it: http://pastie.caboo.se/pastes/97049 The basic idea is that you spawn Actors from the main process. Each Actor has an associated mailbox, and you can asynchronously send it messages (in this implementation, using <<). When you spawn an actor, you pass it a block to run. This actually runs within a fiber. In an Actor, you can call the Actor.receive method to read messages from the mailbox. You specify a filterset for reading the messages: either an argument to be directly compared with ===, or a proc that returns true on a match. A run queue is maintained which contains every single Actor which has received a message. When an Actor receives a message, its Fiber is resumed, and then the specified filter set is checked against the mailbox. If there's a match, the corresponding block is invoked, otherwise the Fiber yields until its gets another message. If all our Fibers are sleeping, control is returned back to the main program until it sends a message to one of the actors. Actors can make other Actors with the Actor.spawn method and can also send messages to other Actors, provided they have a handle to the Actor object they want to send a message to. If you dump the implementation into actor.rb then paste the example code into irb, you can play around with it. Just use << to send a message to any Actor object. Messages are totally arbitrary and get dumped into the Actor's associated mailbox: irb(main):040:0> actor2 << :cat I hate cats... you take it! I love cats My buddy got a cat => :cat Here we have messages being sent from actor2 -> actor1 -> buddy. actor2 receives the :cat message and forwards it onto actor1. actor1 receives it and sends a :gotacat message to buddy. Each line was printed out by a different fiber. Here's an example of the Proc-based pattern matching: irb(main):041:0> actor2 << "Foobar" I hate strings... you take it! I got a string: Foobar => "Foobar" Here actor2's proc-based filter detected it received a string, and decided to forward it back to actor1. actor1's filter was set up to print out strings it received using a proc to match them. -- Tony Arcieri ClickCaster, Inc. tony at clickcaster.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/bdrg-members/attachments/20070913/f4922489/attachment.html From mghaught at gmail.com Mon Sep 17 19:05:00 2007 From: mghaught at gmail.com (Marty Haught) Date: Mon, 17 Sep 2007 17:05:00 -0600 Subject: [Boulder Ruby Group] BRG - September Meeting - Sep 19th Reminder Message-ID: <57f29e620709171605x5b6e020dsf02a4c255fd4db9b@mail.gmail.com> Our September meeting will be held this Wednesday, Sept 19th at 6:30pm (directions below). Nathan Witmer will handle our first presentation on Rspec. We'll break for 20-30 minutes to mingle. Afterwards Jameson Watts will present the second talk on Radius MS ? RESTful texting. Radius MS is a RESTful api for text message data relay, and infinite depth menuing. As a substitute for WAP, Radius provides a stateful request/response for SMS interaction with a server. Should be an interesting set of talks. As always we have a good time conversing as a group. After the meeting, we will migrate over to the pub for some refreshments and continued good company. Look forward to seeing you all there. Cheers, Marty Haught http://boulderruby.org Directions: Collective Intellect 1601 Pearl St, Suite 200 Boulder, CO 80302 The office is above the restaurants Aji & Leaf. The main entrance is on 16th Street, just North to of the Leaf restaurant. Come up the stairs to the second floor. URL to google maps: http://rubyurl.com/112 From ara.t.howard at gmail.com Wed Sep 19 19:16:25 2007 From: ara.t.howard at gmail.com (ara.t.howard) Date: Wed, 19 Sep 2007 17:16:25 -0600 Subject: [Boulder Ruby Group] rfc Message-ID: <01195B4F-39B6-4380-A0F8-F536F5340B66@gmail.com> unless defined? SaneTransactions <<-README NAME sane_transactions SYNOPSIS the standard activerecord transactions are not sane. consider the following ActiveRecord::Base.connection.transaction do Model.create! raise end in this case the Model creation is NOT rolled back. the reason can be summarized thusly: ActiveRecord never starts a transaction when one is open, but commiting a transaction always occurs. this means that, no matter how hard you try, one errant save|destroy|create from deep in the bowels of a plugin will unravel your carefully laid plans - throwing data integrity out the window, along with part of your salary. for the most part people simply ignore this fact in rails, and live with the possibility of inconsistent data after a failed complex controller action. sane_transactions address this issue, and more, in a small, furry, rails munging way. USAGE * POLS transactions require 'sane_transactions' ActiveRecord::Base.connection.transaction do Model.create! raise end # Model creation is rolled back * nested transactions work, only the top level transaction executes sql require 'sane_transactions' ActiveRecord::Base.connection.transaction do Model.create! ActiveRecord::Base.connection.transaction do ActiveRecord::Base.connection.transaction do ActiveRecord::Base.connection.transaction do raise end end end end # Model creation is rolled back * shortcuts are given, db code is important so certain methods are available at the top level require 'sane_transactions' transaction do Model.create! raise end # ahhhhhh * throw/catch based switches enable you to bail out and commit or rollback a transaction early and from any depth require 'sane_transactions' transaction do Model.create! rollback! end # Model creation is rolled back * a commit switch is provided too require 'sane_transactions' transaction do a = Model.create! commit! b = Model.create! end # a IS created, b IS NOT * savepoints are implemented, and can be individually rolled back require 'sane_transactions' transaction do savepoint do a = Model.create! rollback! :savepoint end b = Model.create! end # a IS NOT created, b IS INSTALL - put this file into RAILS_ROOT/lib - add "require 'sane_transactions'" to RAILS_ROOT/environment.rb DISCLAIMER this is pre-pre-pre-pre-alpha code AUTHOR ara.t.howard [[at]] gmail [[dot]] com README class Object def transaction *argv, &block ActiveRecord::Base.connection.transaction *argv, &block end def transaction? *argv, &block ActiveRecord::Base.connection.transaction? *argv, &block end def savepoint *argv, &block ActiveRecord::Base.connection.savepoint *argv, &block end def rollback! *argv, &block ActiveRecord::Base.connection.rollback! *argv, &block end def commit! *argv, &block ActiveRecord::Base.connection.commit! *argv, &block end end class Module def thread_safe_attribute name, options = {} options.to_options! prefix = options[:prefix] prefix = "#{ prefix.name.underscore }_" if Module === prefix key = "#{ prefix }#{ name }".inspect code = <<-code def #{ name } *argv, &block if argv.empty? Thread.current[#{ key }] else if block value = Thread.current[#{ key }] begin Thread.current[#{ key }] = argv.first block.call ensure Thread.current[#{ key }] = value end else Thread.current[#{ key }] = argv.first end end end def #{ name }= value #{ name } value end def #{ name }? #{ name } end code module_eval code end end module ActiveRecord module Transactions class Savepoint < ::String class << self thread_safe_attribute 'initial', :prefix => ActiveRecord::Transactions::Savepoint end def initialize initial = self.class.initial reset! initial end def next succ! end def reset! initial = self.class.initial replace initial end initial "rails_savepoint_0" end class << self thread_safe_attribute 'using', :prefix => ActiveRecord::Transactions thread_safe_attribute 'are_active', :prefix => ActiveRecord::Transactions thread_safe_attribute 'savepoint', :prefix => ActiveRecord::Transactions end using :transaction are_active false savepoint Savepoint.new end module ConnectionAdapters module DatabaseStatements def transaction *argv, &block method = "transaction_using_# { ActiveRecord::Transactions.using }" send method, *argv, &block end def transaction? ActiveRecord::Transactions.are_active? end def transaction_using_transaction *ignored return yield if ActiveRecord::Transactions.are_active? finish = nil returned = nil begin ActiveRecord::Transactions.are_active true ActiveRecord::Transactions.savepoint.reset! begin_db_transaction finish = catch(:transaction){ returned = yield; nil } returned ensure ActiveRecord::Transactions.are_active false if finish finish == :rollback ? rollback_db_transaction : commit_db_transaction else $! ? rollback_db_transaction : commit_db_transaction end end end def transaction_using_savepoint *ignored raise TransactionError, 'no transaction in effect' unless ActiveRecord::Transactions.are_active? name = nil finish = nil returned = nil begin name = begin_db_savepoint finish = catch(:savepoint){ returned = yield; nil } returned ensure if finish rollback_db_savepoint name if finish == :rollback and name else rollback_db_savepoint name if $! and name end end end def savepoint raise TransactionError, 'no transaction in effect' unless ActiveRecord::Transactions.are_active? ActiveRecord::Transactions.using :savepoint do transaction{ yield } end end def rollback! target = :transaction raise TransactionError, 'no transaction in effect' unless ActiveRecord::Transactions.are_active? throw target, :rollback end def rollback_savepoint! rollback! :savepoint end def commit! target = :transaction raise TransactionError, 'no transaction in effect' unless ActiveRecord::Transactions.are_active? throw target, :commit end def commit! target = :transaction raise TransactionError, 'no transaction in effect' unless ActiveRecord::Transactions.are_active? throw target, :commit end def begin_db_savepoint name = ActiveRecord::Transactions.savepoint.next execute "SAVEPOINT #{ name }" name end def rollback_db_savepoint name execute "ROLLBACK TO SAVEPOINT #{ name }" name end def release_db_savepoint name execute "RELEASE SAVEPOINT #{ name }" name end end end end SaneTransactions = 42 end a @ http://drawohara.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama From ara.t.howard at gmail.com Thu Sep 20 01:30:19 2007 From: ara.t.howard at gmail.com (ara.t.howard) Date: Wed, 19 Sep 2007 23:30:19 -0600 Subject: [Boulder Ruby Group] rfc In-Reply-To: <7968d7490709192204te9c1970m8f350fc2071826cd@mail.gmail.com> References: <01195B4F-39B6-4380-A0F8-F536F5340B66@gmail.com> <7968d7490709192204te9c1970m8f350fc2071826cd@mail.gmail.com> Message-ID: <6FC8B071-066E-49EF-BBED-177E58148CD2@gmail.com> On Sep 19, 2007, at 11:04 PM, Lee Marlow wrote: > This definitely looks more sane and is what I would expect. I wonder > if you submitted it as a patch to rails whether it could make it into > 2.0. i haven't looked at the 2.0 source, but i imagine quite a bit has changed - probably too much for this patch... > Is this not in rails already because the savepoints and nested > transactions aren't standard across most databases? well - it doesn't really support nested transactions per-se. that is to say that rails wraps alot of stuff in transactions but, if you are already in one, it's kind of moot. so these transactions are really ruby transactions - where the many of them stack into only one db transaction. as far as savepoints it doesn't really matter if they are implemented or not. in sane_transactions you can simply not use them for unsupported dbs... but you are right that only pg/oracle and a few others support them. cheers. a @ http://drawohara.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama From ara.t.howard at gmail.com Thu Sep 20 11:57:17 2007 From: ara.t.howard at gmail.com (ara.t.howard) Date: Thu, 20 Sep 2007 09:57:17 -0600 Subject: [Boulder Ruby Group] rfc In-Reply-To: <6efbd9b70709191647l1a5826bauba43c57c78dd25c6@mail.gmail.com> References: <01195B4F-39B6-4380-A0F8-F536F5340B66@gmail.com> <6efbd9b70709191647l1a5826bauba43c57c78dd25c6@mail.gmail.com> Message-ID: On Sep 19, 2007, at 5:47 PM, Chris Riddoch wrote: > On 9/19/07, ara.t.howard wrote: >> unless defined? SaneTransactions > > Thanks for this! I was just reading up on Rails' transactions for a > project I'm doing, and it's very helpful to know how things are > broken... doubly so with a fix, too. > > Is there any chance of getting this solution into ActiveRecord? > > -- epistemological humility > Chris Riddoch dunno. i'm not 100% there isn't another workaround - but i sure haven't found it yet. there are also some similar patches proposed but, afaikt, none that let transactions and savepoints mix so easily. i've sent it off to marcel molina (rails core) for review - i'll get his input and, if positive, submit to rails-core. thanks alot for the feedback! ps. if anyone can drop this into their projects and see if things work it'd be great. there are few things with fixtures that *should* break if you've done the standard workarounds but, other than that, things should work unchanged. if not send me a stack trace! a @ http://drawohara.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama From nathan at teamjunkshow.com Tue Sep 25 21:32:16 2007 From: nathan at teamjunkshow.com (Nathan Witmer) Date: Tue, 25 Sep 2007 19:32:16 -0600 Subject: [Boulder Ruby Group] RSpec presentation slides & notes Message-ID: <29377135-5DE5-4FAC-9AC0-6DAC1E1B5C50@teamjunkshow.com> Here's the slides and notes from my rspec presentation last week. http://notebook.otherward.net/assets/2007/9/26/rspec.pdf Nathan From kevwil at gmail.com Wed Sep 26 11:02:43 2007 From: kevwil at gmail.com (Kevin Williams) Date: Wed, 26 Sep 2007 09:02:43 -0600 Subject: [Boulder Ruby Group] RSpec presentation slides & notes In-Reply-To: <29377135-5DE5-4FAC-9AC0-6DAC1E1B5C50@teamjunkshow.com> References: <29377135-5DE5-4FAC-9AC0-6DAC1E1B5C50@teamjunkshow.com> Message-ID: <683a886f0709260802udc72266s4832756fbdf08747@mail.gmail.com> Does the group web site have a "post presentations here" page? A common place to revisit these presentations would be cool. On 9/25/07, Nathan Witmer wrote: > Here's the slides and notes from my rspec presentation last week. > http://notebook.otherward.net/assets/2007/9/26/rspec.pdf > > Nathan > _______________________________________________ > Bdrg-members mailing list > Bdrg-members at rubyforge.org > http://rubyforge.org/mailman/listinfo/bdrg-members > -- Cheers, Kevin Williams http://kevwil.com/ http://www.almostserio.us/ http://kevwil.jaiku.com/ From ara.t.howard at gmail.com Wed Sep 26 11:37:11 2007 From: ara.t.howard at gmail.com (ara.t.howard) Date: Wed, 26 Sep 2007 09:37:11 -0600 Subject: [Boulder Ruby Group] RSpec presentation slides & notes In-Reply-To: <683a886f0709260802udc72266s4832756fbdf08747@mail.gmail.com> References: <29377135-5DE5-4FAC-9AC0-6DAC1E1B5C50@teamjunkshow.com> <683a886f0709260802udc72266s4832756fbdf08747@mail.gmail.com> Message-ID: <191DF4C9-272A-4DDC-A5E2-A2D50A3ED937@gmail.com> On Sep 26, 2007, at 9:02 AM, Kevin Williams wrote: > Does the group web site have a "post presentations here" page? > > A common place to revisit these presentations would be cool. all mine are here - i'd be happy to host them somewhere central. maybe we should just put them on s3 in a bucket we all have the password too? a @ http://drawohara.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama From ara.t.howard at gmail.com Sun Sep 30 12:02:43 2007 From: ara.t.howard at gmail.com (ara.t.howard) Date: Sun, 30 Sep 2007 10:02:43 -0600 Subject: [Boulder Ruby Group] rails/ruby memory leak Message-ID: <87C8ABE9-2EE5-4B3D-891E-CF7E3E30B80A@gmail.com> hi all i've been chasing my tail on a tiny memory leak for a few days. i isolated the cause to what amounts to a rails project with database sessions enabled. now i'm not sure that the leak is in rails, in fact i think it's in ruby's cgi/session.rb but i want to gather a few data points to confirm the leak i'm seeing. if you have a little time, check out http://drawohara.tumblr.com/post/13655303 or just grab the project from http://s3.amazonaws.com/drawohara.com.downloads/leak.tgz and get it running on your box. it should be *very* quick to do if you have sqlite3 installed. running it is also easy, but seeing the leak can take a bit of time - 30 minutes to 6 hours depending on how fast your box can hammer ./script/server. anyhow, people can report here or to me directly. i'll summarize my findings and, if there is in fact a leak in either ruby or rails - follow up with a bug report. kind regards. a @ http://drawohara.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama From kevwil at gmail.com Sun Sep 30 16:12:17 2007 From: kevwil at gmail.com (Kevin Williams) Date: Sun, 30 Sep 2007 14:12:17 -0600 Subject: [Boulder Ruby Group] rails/ruby memory leak In-Reply-To: <87C8ABE9-2EE5-4B3D-891E-CF7E3E30B80A@gmail.com> References: <87C8ABE9-2EE5-4B3D-891E-CF7E3E30B80A@gmail.com> Message-ID: <683a886f0709301312o7cd0fc31vce6387c5757c90a@mail.gmail.com> I couldn't run it long enough to get what I would call 'conclusive results' because my MBP seemed about to melt. :( There did seem to be a slight increase, but not as much as in your tumblr post. (same OS, same ruby version, same rails version) On 9/30/07, ara.t.howard wrote: > > hi all > > i've been chasing my tail on a tiny memory leak for a few days. i > isolated the cause to what amounts to a rails project with database > sessions enabled. now i'm not sure that the leak is in rails, in fact > i think it's in ruby's cgi/session.rb but i want to gather a few data > points to confirm the leak i'm seeing. if you have a little time, > check out > > http://drawohara.tumblr.com/post/13655303 > > or just grab the project from > > http://s3.amazonaws.com/drawohara.com.downloads/leak.tgz > > and get it running on your box. it should be *very* quick to do if > you have sqlite3 installed. running it is also easy, but seeing the > leak can take a bit of time - 30 minutes to 6 hours depending on how > fast your box can hammer ./script/server. anyhow, people can report > here or to me directly. i'll summarize my findings and, if there is > in fact a leak in either ruby or rails - follow up with a bug report. > > kind regards. > > a @ http://drawohara.com/ > -- > we can deny everything, except that we have the possibility of being > better. simply reflect on that. > h.h. the 14th dalai lama > > > > _______________________________________________ > Bdrg-members mailing list > Bdrg-members at rubyforge.org > http://rubyforge.org/mailman/listinfo/bdrg-members > -- Cheers, Kevin Williams http://kevwil.com/ http://www.almostserio.us/ http://kevwil.jaiku.com/ From tony at clickcaster.com Sun Sep 30 17:56:06 2007 From: tony at clickcaster.com (Tony Arcieri) Date: Sun, 30 Sep 2007 15:56:06 -0600 Subject: [Boulder Ruby Group] rails/ruby memory leak In-Reply-To: <87C8ABE9-2EE5-4B3D-891E-CF7E3E30B80A@gmail.com> References: <87C8ABE9-2EE5-4B3D-891E-CF7E3E30B80A@gmail.com> Message-ID: Are you using ObjectSpace to track leaks? At one point Evan Weaver had a graph of an ObjectSpace profiler versus one he wrote using direct heap instrumentation in C, and the ObjectSpace version gave the appearance of phantom leaks which really weren't there... Have you tried Bleak House? http://blog.evanweaver.com/articles/2007/09/25/bleak_house-3-tells-you-your-leaks/ On 9/30/07, ara.t.howard wrote: > > > hi all > > i've been chasing my tail on a tiny memory leak for a few days. i > isolated the cause to what amounts to a rails project with database > sessions enabled. now i'm not sure that the leak is in rails, in fact > i think it's in ruby's cgi/session.rb but i want to gather a few data > points to confirm the leak i'm seeing. if you have a little time, > check out > > http://drawohara.tumblr.com/post/13655303 > > or just grab the project from > > http://s3.amazonaws.com/drawohara.com.downloads/leak.tgz > > and get it running on your box. it should be *very* quick to do if > you have sqlite3 installed. running it is also easy, but seeing the > leak can take a bit of time - 30 minutes to 6 hours depending on how > fast your box can hammer ./script/server. anyhow, people can report > here or to me directly. i'll summarize my findings and, if there is > in fact a leak in either ruby or rails - follow up with a bug report. > > kind regards. > > a @ http://drawohara.com/ > -- > we can deny everything, except that we have the possibility of being > better. simply reflect on that. > h.h. the 14th dalai lama > > > > _______________________________________________ > Bdrg-members mailing list > Bdrg-members at rubyforge.org > http://rubyforge.org/mailman/listinfo/bdrg-members > -- Tony Arcieri ClickCaster, Inc. tony at clickcaster.com 720-227-0129 ext. 202 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/bdrg-members/attachments/20070930/25037677/attachment.html From ara.t.howard at gmail.com Sun Sep 30 21:29:01 2007 From: ara.t.howard at gmail.com (ara.t.howard) Date: Sun, 30 Sep 2007 19:29:01 -0600 Subject: [Boulder Ruby Group] rails/ruby memory leak In-Reply-To: <683a886f0709301312o7cd0fc31vce6387c5757c90a@mail.gmail.com> References: <87C8ABE9-2EE5-4B3D-891E-CF7E3E30B80A@gmail.com> <683a886f0709301312o7cd0fc31vce6387c5757c90a@mail.gmail.com> Message-ID: On Sep 30, 2007, at 2:12 PM, Kevin Williams wrote: > I couldn't run it long enough to get what I would call 'conclusive > results' because my MBP seemed about to melt. :( There did seem to be > a slight increase, but not as much as in your tumblr post. > > (same OS, same ruby version, same rails version) the results i posted was after around 24 of run time - it really is slow but, afaikt, a real leak. cheers. a @ http://drawohara.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama