Tor Erik Linnerud | 1 Nov 2009 01:12
Picon
Gravatar

Re: #system() hangs, child is defunct

The thing is that this is a test setup, so we want to keep it just like 
production. I tried running the VM under VirtualBox instead of VMware 
Server, which seemed to make the problem go away for now. I would still 
like to know what was going on though.

--

-- 
Posted via http://www.ruby-forum.com/.

7stud -- | 1 Nov 2009 01:13
Picon
Favicon

Re: In-place parameter modification

Dave Anderson wrote:
> Rick Denatale wrote:
> ...
>> Objects are instances of classes, and typically have state, in some
>> cases like Fixnums the only state is really the object's identity, and
>> such objects are immutable, if two such objects have different state,
>> then they MUST be different objects.  There is only one 1 object and
>> one 5 object.  Symbols are similar in that there is only one instance
>> of symbol with a particular value.
> 
> Thanks for the fascinating and valuable insights, Rick. I didn't realize 
> what a can of worms I was opening here. And it's nice to know that 
> someone here remembers Fortran II, although that might make you a good 
> candidate for a Men-In-Black neurolizer. ;-) As an old hand at C++, this 
> variable/value/type stuff is a very worthwhile lesson.
> 
> One practical thing I can draw out of this is the difference between 
> these two functions:
> 
>   def X_1( str )
>     str[0] = 'X'
>   end
> 
>   def X_2( str )
>      str = 'X' + str[ 1..-1 ]
>   end
> 
> The X_1 function alters the passed-in object in place, 

Remember that in ruby "[]=" is the name of a method:
(Continue reading)

Jiten Bhagat | 1 Nov 2009 01:16
Picon
Gravatar

Re: Desktop GUI apps in Ruby

Hi,

I recently came across limelight -
http://limelight.8thlight.com/main/sparkle.

Haven't had a chance to play with it yet but it sounds like it might be
worth consideration.

Cheers,
Jits

2009/10/28 Marnen Laibow-Koser <marnen <at> marnen.org>

> Hi folks!
>
> I'm an experienced Rails developer, but for once this is not a Rails
> question.  Rather, I have a desktop app I'd like to create -- we're
> talking something like a spreadsheet-type app, though not quite.  Since
> I've been using Ruby more than any other language for the last 2 years,
> and since I love working in Ruby, I'd like to try to write the app in
> Ruby to the extent possible.
>
> Since this is meant as an end-user productivity application for
> nontechnical users, and since I'd like the barriers to use of this app
> to be as low as possible, I have a couple of requirements:
> * Must run on Linux, Mac OS X, and Windows, preferably with a minimum of
> hassle in the build process
> * Must install with a minimum of extra dependencies -- ideally I'd like
> people to be able to download an executable, unzip it, and run it
> immediately, without needing administrator permissions
(Continue reading)

7stud -- | 1 Nov 2009 01:27
Picon
Favicon

Re: In-place parameter modification

7stud -- wrote:
>

Because you mentioned C++, I'll just point out that "ruby references" 
are not like C++ reference types.  In C++, a reference variable is an 
alias for another variable, which means that both variables refer to the 
same location in memory.  If you use one of the variable names to change 
what is at that location in memory, the other variable, because it 
retrieves its value from the same location in memory, also refers to the 
changed value.

In my ruby example above, x and y are not aliases--even though they 
refer to the same object 10.  As a result, when y is assigned a new 
value, it does not affect x.

--

-- 
Posted via http://www.ruby-forum.com/.

Jeremy Hinegardner | 1 Nov 2009 01:55

Re: compile architecture-specific, portable ruby

On Sun, Nov 01, 2009 at 07:40:13AM +0900, Sean O'Donnell wrote:
 >
> > > Thoughts? I guess the high-level question is this: Are there
> > > additional flags that I need to pass to `configure` to build a self-
> > > contained, architecture-specific version?
> >
> > Built a fully staticly linked ruby instead. ?If you plan on using zlib or
> > openssl in your teaching you'll need to build them and put them in the
> > tarball too.
> >
> > Edit the ext/Setup file in the ruby distribution tarball to turn on the
> > 'nodynamic' option and uncomment each extension you would like compiled
> > statically.
> >
> > Then run :
> >
> > ? ? ./configure --disable-shared --prefix=/Users/student/local/ruby
> > ? ? make && make install
> >
> > Then I believe you'll be a step closer. ?Doing this will disable the
> > dynamic loading of extensions, so I'm assuming that you will not later
> > deploy gems with extensions on top of this.
> 
> Thanks - I may go this way. However, if I were to continue with a non-
> static version, how would I force the path to point to the desired
> shared library? Like this?
> 
> ./configure --prefix=/Users/student/local --libdir=/Users/student/
> local

(Continue reading)

David A. Black | 1 Nov 2009 02:18

Re: In-place parameter modification

Hi --

On Sun, 1 Nov 2009, Jordi Bunster wrote:

> On Oct 31, 2009, at 1:03 PM, David A. Black wrote:
>
>> I don't think "replace" has any generalizable semantics. You can't
>> replace 2 with 3, for example (fortunately :-)
>
> You could just memcpy a to b (as long as their classes are eql?). If for a 
> given object it doesn't make sense, like for singleton ones, then you don't 
> allow it.
>
> I wonder if they would take a patch. Is not as if Ruby doesn't already have a 
> ton of edge cases anyway.

The "There's a precedent" argument can always be inverted, though,
into the "We've reached our quota" argument :-) Of course, that's
where Matz and his wonderful sense of balance come in.

In any case, I wouldn't call such a method "replace", because it's
radically different from the existing replace methods. Somewhere
there's at least one implementation (maybe in evil.rb) of a method
called "become", which I think does what you're describing, or
something similar: a.become(b) means that all existing references to a
become references to b, if I'm remembering/summarizing correctly.

David

--

-- 
(Continue reading)

Derek Smith | 1 Nov 2009 02:52
Picon
Favicon

Re: mtime.max


> puts stats.sort {|x,y| x[1] <=> y[1]}.max
> 
> This explicitly sorts by the 2nd value in the to_a array, which is the 
> mtime.

Thanks, but that does not work because its sorting on the time only, for 
example sorting on 1052, 1054, 110, 1042.

root  wheel  38608780 Oct 29 10:52 
/usr/local/vrep/prod_db_bkup_Thr2009-10-291052.gz
root  wheel  38608793 Oct 29 10:54 
/usr/local/vrep/prod_db_bkup_Thr2009-10-291054.gz
root  wheel  38608802 Oct 29 11:00 
/usr/local/vrep/prod_db_bkup_Thr2009-10-29110.gz
root  wheel  38609193 Oct 30 10:42 
/usr/local/vrep/prod_db_bkup_Fri2009-10-301042.gz

so I am using this, but I could not get my each loop to work
please help!

stats = Hash.new
    DB_BKUP1.each do |dbfile|
        stats[dbfile] = [File.stat(dbfile).mtime.to_i]
    end

    statsA     = stats.sort { |x,y| x[1] <=> y[1] }.to_a
    oldest     = statsA[0][1].to_s.to_i

    p statsA
(Continue reading)

George Neuner | 1 Nov 2009 03:10
Picon

Re: Ruby can't subtract ?

On Sat, 31 Oct 2009 12:48:28 -0500, Christopher Dicely
<cmdicely <at> gmail.com> wrote:

>On Fri, Oct 30, 2009 at 11:40 PM, George Neuner <gneuner2 <at> comcast.net> wrote:
>> On Wed, 28 Oct 2009 14:30:21 -0500, Marnen Laibow-Koser
>> <marnen <at> marnen.org> wrote:
>>
>>>Robert Klemme wrote:
>>>> On 28.10.2009 19:21, Matthew K. Williams wrote:
>>>>> As a rule of thumb, if you really care about the decimals, either use
>>>>> BigDecimal or integers (and keep track of where the decimal should be --
>>>>> this is common for $$$$).  Unfortunately, this is not limited to ruby,
>>>>> either -- C, Java, and a host of other languages all are subject.
>>>>
>>>> Absolutely: this is a common issue in *all* programming languages which
>>>> are not systems for symbolic math (like Mathematica) because they do not
>>>> work with real numbers but just rational numbers.
>>>
>>>That is not the issue here -- after all, BigDecimal does precise
>>>arithmetic, but only with rational numbers.  The issue is rather that
>>>IEEE 754 does an inadequate job of representing arbitrary rational
>>>numbers, and the small errors are accumulated and magnified in
>>>calculations.
>>
>> The problem is that the 754 representation has finite precision.
>
>Well, the problem isn't that. The problem is that the IEEE 754 (1985)
>provides only binary floating point representations, when many common
>problem domains deal almost exclusively with values that have finite
>(and short) exact representations in base 10, which may or may not
(Continue reading)

George Neuner | 1 Nov 2009 03:25
Picon

Re: Ruby can't subtract ?

On Sat, 31 Oct 2009 13:51:58 +0100, Robert Klemme
<shortcutter <at> googlemail.com> wrote:

>On 10/31/2009 07:35 AM, George Neuner wrote:
>
>> It's also worth noting that most floating point hardware is not
>> anywhere close to 754 compliant even though most FPUs do use the
>> standard number formats (at least for single and double precision).
>
>Interesting!  I wasn't aware of that.  Why is that?  Do they just leave 
>out operations or are HW vendors actually cutting corners and digressing 
>from the prescribed algorithms / results?

Actually the primary reason for deviating from the standard is to
achieve better performance.  The standard algorithms are designed to
correctly handle a lot of corner cases that most users will never
encounter in practice.  Many manufacturers have chosen to make
expected normal use as fast as possible at the expense of handling the
corner cases incorrectly.

Many CPUs do not implement all the standard rounding modes.  Some use
projective affinity where the standard specifies affine infinity
(makes a difference whether +inf == -inf) and most do not support
gradual denormalization (underflow) but simply pin the result to zero
when underflow occurs.

What confuses people is that most CPUs now use (at least) IEEE-754
single and double precision bit formats ... because of that many
people conclude erroneously that the CPU is performing math according
to the 754 standard.
(Continue reading)

Picon
Favicon

Re: How do you get the tail end of a string?


"David A. Black" <dblack <at> rubypal.com> wrote in message 
news:alpine.LFD.2.00.0910300803050.7908 <at> rubypal.com...
>
> On Fri, 30 Oct 2009, Bertram Scharpf wrote:
>> Am Freitag, 30. Okt 2009, 13:25:05 +0900 schrieb Michael W. Ryder:
>>> Michael W. Ryder wrote:
>>>> Just Another Victim of the Ambient Morality wrote:
>>>>>     I'm actually hoping this is an embarrassing question but how do 
>>>>> you
>>>>> get the tail end of a string?  All I've figured out is this:
>>>>>
>>>>> index = 4
>>>>> string[index, string.size - index]
>>>>>
>>>>>     ...but surely there's a better way.
>>>>>
>>>> You mean like string[-1]?
>>>
>>> I'm sorry, I missed the part about the index number of characters.  Try
>>> string[-index, index].
>>
>> That's really ugly. You shouldn't have to mention `index' twice.
>
> I don't think there's anything wrong with it. It works well, and
> there's nothing stylistically wrong with using a local variable twice.
> If index is a method that does a (re)calculation every time, you'd
> want to cache it, but that's not the case in the example.

    There's nothing wrong with it other than it doesn't work.  As others 
(Continue reading)


Gmane