Idea: Webshare

Do you do this? Why would not pass the whole request through, like a proxy server?

Cheers,

Patrick

···

On Monday, August 23, 2004, at 04:26 PM, Kirk Haines wrote:

Let me throw you a wrinkle to think about.

File uploads. If you adopt a model where you are passing a request object
to the webapp, and the webapp may not even be on the same machine as the
webserver, what is the best way to handle uploaded files?

You can't just create a tempfile like the current CGI does. Do you transfer
the data with the request, but then write it to tempfiles on the other
side? Does Drb provide a way that one could write the uploaded files to
tempfiles on the server, but that one could access the tempfiles via the
request object in the webapp? Could be cool. Might be a bad idea.

a = hsh[val] || hsh['*']

Another beautiful solution for my eyes. Thanks so much David! i am getting so used to the "or" instead of ||

Zach

David A. Black wrote:

···

Hi --

On Fri, 20 Aug 2004, Zach Dennis wrote:

David A. Black wrote:

I'm not quite following. What's not working as you'd like exactly?

hsh = { '*' => '(*)' , 'a' => '(1){2}' }
val = "b"
a = hsh[ val ] or hsh['*'] #to give me, a = '(*)'
puts a
val = "a"
a = hsh[ val ] or hsh['*'] #to give me, a = '(1){2}'
puts a

I want the fourth line to output (*) instead it gives me nil.
   
Whoops, I fell into the irb trap :slight_smile:

binds more tightly than or, so:

a = hsh[val] || hsh['*']

should give you what you want.

David

I've got a block of code:

process = proc { |str,val|
        process_hsh = { "String" => true , "Fixnum" => true }
        re = /\((.*)\)|\{(.*)\}/;
        m = str.scan( re )
        if( process_hsh["#{val.class.to_s}"] ) then
          m.each{ |v|
            next if( not v); #<-----------------THIS IS THE CULPRIT
            puts v
          }
        end
      }

But "v" is always put to the screen. The output I get is:

···

*
nil
*
nil
*
nil
*
nil

In my test case, I am expecting:

*

Does MatchData not take advantage of iterating via "next" ? Thanks,

Zach

Hello,

This seems to be a powerpc bug. Here is a more simple example:

   continuation = []
   at_exit{
     puts 'at_exit'
     continuation[0].call unless continuation[0].nil?
   }
   callcc{ |c|
     continuation[0] = c
   }
   puts 'running'

This code runs in the expected continuous loop on linux. On my mac (10.2) I get the error:

   [~/programming/narf] patsplat% ruby bug.rb
   running
   at_exit
   running
   bug.rb:9: compile error (SyntaxError)
   bug.rb:9: [BUG] Bus Error
   ruby 1.8.1 (2003-12-25) [powerpc-darwin]

   Abort
   [~/programming/narf] patsplat%

Does this happen on any other platform? Is this an OS X limitation?

Cheers,

Patrick

I found my problem:

m.each{ |v| ...}

is giving me "v" as an array of matches....I should have tested first!

Zach

Zach Dennis wrote:

···

I've got a block of code:

process = proc { |str,val|
       process_hsh = { "String" => true , "Fixnum" => true }
       re = /\((.*)\)|\{(.*)\}/;
       m = str.scan( re )
       if( process_hsh["#{val.class.to_s}"] ) then
         m.each{ |v|
           next if( not v); #<-----------------THIS IS THE CULPRIT
           puts v
         }
       end
     }

But "v" is always put to the screen. The output I get is:

*
nil
*
nil
*
nil
*
nil

In my test case, I am expecting:

*

Does MatchData not take advantage of iterating via "next" ? Thanks,

Zach

Hi --

I've got a block of code:

process = proc { |str,val|
        process_hsh = { "String" => true , "Fixnum" => true }
        re = /\((.*)\)|\{(.*)\}/;
        m = str.scan( re )
        if( process_hsh["#{val.class.to_s}"] ) then
          m.each{ |v|
            next if( not v); #<-----------------THIS IS THE CULPRIT

[...]

Does MatchData not take advantage of iterating via "next" ? Thanks,

m isn't a MatchData object; it's an Array (returned by scan). 'next'
definitely works; if it doesn't move to the next iteration, then "not
v" is not true. I think you may be testing for empty strings with
'not', which doesn't work because "" is true. If that turns out to be
the problem, you can do:

  next if v.empty?

David

···

On Fri, 20 Aug 2004, Zach Dennis wrote:

--
David A. Black
dblack@wobblini.net

Hmm...you may want to take this up on ruby-core.

T.

···

On Wednesday 08 September 2004 11:18 pm, Patrick May wrote:

This seems to be a powerpc bug. Here is a more simple example:

   continuation =
   at_exit{
     puts 'at_exit'
     continuation[0].call unless continuation[0].nil?
   }
   callcc{ |c|
     continuation[0] = c
   }
   puts 'running'

This code runs in the expected continuous loop on linux. On my mac
(10.2) I get the error:

   [~/programming/narf] patsplat% ruby bug.rb
   running
   at_exit
   running
   bug.rb:9: compile error (SyntaxError)
   bug.rb:9: [BUG] Bus Error
   ruby 1.8.1 (2003-12-25) [powerpc-darwin]

   Abort
   [~/programming/narf] patsplat%

Does this happen on any other platform? Is this an OS X limitation?

Cheers,

Patrick

--
T.