[#335632] SOAP - issue with openssl verification failure — Venkat Alla <spinhoo2000@...>

I have the following code in a script that I am trying to use at work -

10 messages 2009/05/01

[#335755] Should I upgrade Ruby from 1.8.5 to 1.8.7? — Cali Wildman <caliwildman2004-info@...>

I just upgraded to Rails 2.3.2 but my Ruby is still 1.8.5. Rails 2.3.2

23 messages 2009/05/04

[#335777] my logroll code, please critique — Derek Smith <derekbellnersmith@...>

My goal is to keep 10 files each at 100Mb. Please critique and suggest

12 messages 2009/05/05

[#335842] '=||' — James Byrne <byrnejb@...>

Can someone point out to me where exactly in the API I find a discussion

18 messages 2009/05/05
[#335843] Re: '=||' — Eleanor McHugh <eleanor@...> 2009/05/05

On 5 May 2009, at 20:51, James Byrne wrote:

[#336031] Superclass of eigenclass — Danny O cuiv <danny.ocuiv@...>

On page 261 of The Ruby Programming Language, they state:

30 messages 2009/05/07
[#336052] Re: Superclass of eigenclass — Rick DeNatale <rick.denatale@...> 2009/05/07

On Thu, May 7, 2009 at 8:35 AM, Danny O cuiv <danny.ocuiv@gmail.com> wrote:

[#336056] Re: Superclass of eigenclass — Rick DeNatale <rick.denatale@...> 2009/05/07

On Thu, May 7, 2009 at 11:50 AM, Rick DeNatale <rick.denatale@gmail.com> wrote:

[#336061] Ruby memory usage — Pete Hodgson <ruby-forum@...>

Hi Folks,

23 messages 2009/05/07

[#336087] File over tcp? with out using net/ftp — Bigmac Turdsplash <i8igmac@...>

Im trying to send a file back and forth between a client.rb and

12 messages 2009/05/07

[#336160] CGI help — Jeff Leggett <hikerguy@...>

So, I am trying ot read the contents of a file and format the contents

19 messages 2009/05/08

[#336168] ruby string slice/[] w/ range, weird end behavior — Gary Yngve <gary.yngve@...>

First the docs:

17 messages 2009/05/08
[#336169] Re: ruby string slice/[] w/ range, weird end behavior — Eleanor McHugh <eleanor@...> 2009/05/08

On 9 May 2009, at 00:26, Gary Yngve wrote:

[#336205] converting UTF-8 to entities like &#x525B; — Jian Lin <winterheat@...>

15 messages 2009/05/09

[#336385] Any current preprocessor/Ruby language add-ons? — "C. Dagnon" <c-soc-rubyforum@...>

This is kind of a wide-ranging question but for some fairly specific

16 messages 2009/05/12

[#336411] Whaaaaat? — Tom Cloyd <tomcloyd@...>

p [0..5].include? 0

26 messages 2009/05/12

[#336458] what could be improved in Ruby for Science? — Diego Virasoro <Diego.Virasoro@...>

Hello,

20 messages 2009/05/13

[#336505] Syntactic sugar idea — Daniel DeLorme <dan-ml@...42.com>

It seems that often an object will be passed into a block only to invoke

26 messages 2009/05/14
[#336508] Re: [bikeshed] Syntactic sugar idea — Jan <jan.h.xie@...> 2009/05/14

* Daniel DeLorme <dan-ml@dan42.com> [2009-05-14 11:42:31 +0900]:

[#336766] Berkeley DB or Store equivalent? — Mk 27 <halfcountplus@...>

I have never used mySQL because perl's Storable or BerkeleyDB modules

16 messages 2009/05/17

[#336783] permute each element of a ragged array? — Phlip <phlip2005@...>

Rubies:

19 messages 2009/05/17

[#336821] Sorting numbers as strings — Jack Bauer <realmadrid2727@...>

I'm trying to sort some strings containing numbers. The strings

14 messages 2009/05/18

[#336850] Introducing RubyScience on GitHub! — Joshua Ballanco <jballanc@...>

In the tradition of actions vs. words, I present to you:

14 messages 2009/05/18

[#336930] Create an exe with Ruby 1.9.1 — Marc-antoine Kruzik <kadelfek@...>

Hello !

23 messages 2009/05/19

[#336939] Pythonic indentation (or: beating a dead horse) — J Haas <Myrdred@...>

Greetings, folks. First time poster, so if I breach

235 messages 2009/05/19
[#337016] Re: Pythonic indentation (or: beating a dead horse) — Roger Pack <rogerpack2005@...> 2009/05/20

> ...maybe something like this:

[#337699] Re: Pythonic indentation (or: beating a dead horse) — J Haas <Myrdred@...> 2009/05/28

On May 27, 10:21=A0pm, James Britt <james.br...@gmail.com> wrote:

[#337734] Re: Pythonic indentation (or: beating a dead horse) — James Britt <james.britt@...> 2009/05/28

J Haas wrote:

[#337740] Re: Pythonic indentation (or: beating a dead horse) — Juan Zanos <juan_zanos@...> 2009/05/28

On May 28, 2009, at 2:33 PM, James Britt wrote:

[#337745] Re: Pythonic indentation (or: beating a dead horse) — J Haas <Myrdred@...> 2009/05/28

On May 28, 11:15=A0am, Eleanor McHugh <elea...@games-with-brains.com>

[#337954] Re: Pythonic indentation (or: beating a dead horse) — Steven Arnold <stevena@...> 2009/05/30

After listening to this debate for some time, the position of allowing

[#338133] Re: Pythonic indentation (or: beating a dead horse) — Andy F <andchafow-ruby@...> 2009/06/02

[#338172] Re: Pythonic indentation (or: beating a dead horse) — Eleanor McHugh <eleanor@...> 2009/06/02

On 2 Jun 2009, at 06:20, Andy F wrote:

[#337023] Re: Pythonic indentation (or: beating a dead horse) — J Haas <Myrdred@...> 2009/05/20

On May 20, 8:51=A0am, Rick DeNatale <rick.denat...@gmail.com> wrote:

[#337025] Re: Pythonic indentation (or: beating a dead horse) — Rick DeNatale <rick.denatale@...> 2009/05/20

On Wed, May 20, 2009 at 2:35 PM, J Haas <Myrdred@gmail.com> wrote:

[#337045] Re: Pythonic indentation (or: beating a dead horse) — J Haas <Myrdred@...> 2009/05/20

On May 20, 12:25=A0pm, Tony Arcieri <t...@medioh.com> wrote:

[#337581] Re: Pythonic indentation (or: beating a dead horse) — J Haas <Myrdred@...> 2009/05/27

On May 22, 9:01=A0am, Roger Pack <rogerpack2...@gmail.com> wrote:

[#337673] Re: Pythonic indentation (or: beating a dead horse) — Juan Zanos <juan_zanos@...> 2009/05/28

[#337686] Re: Pythonic indentation (or: beating a dead horse) — Eleanor McHugh <eleanor@...> 2009/05/28

On 28 May 2009, at 15:06, Juan Zanos wrote:

[#337002] Ruby 1.8 vs. Ruby 1.9 — Calvin <cstephens4@...>

Hi,

17 messages 2009/05/20

[#337094] snailgun-1.0.2 — Brian Candler <b.candler@...>

New experimental project:

18 messages 2009/05/21

[#337115] w00t! Party for Gregory! — pat eyler <pat.eyler@...>

> On May 20, 2009, Gregory Brown wrote:

12 messages 2009/05/21

[#337221] Cryptogram II (#206) — Daniel Moore <yahivin@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

17 messages 2009/05/22

[#337323] String concatenation in Ruby — Jagadeesh <mnjagadeesh@...>

Hi,

18 messages 2009/05/25

[#337340] Do you nest classes inside classes? — Mike Stephens <rubfor@...>

Object Orientation is conceptually about a sea of objects interacting

11 messages 2009/05/25

[#337366] Runnin code at a certain time? — Tom Ricks <carrottop123@...>

Hello all,

20 messages 2009/05/25
[#337392] Re: Runnin code at a certain time? — Caleb Clausen <vikkous@...> 2009/05/25

On 5/25/09, Tom Ricks <carrottop123@gmail.com> wrote:

[#337413] Other languages to try? — Adam Gardner <adam.oddfellow@...>

So, I've been programming in Ruby for a good while now. Not an expert,

20 messages 2009/05/26

[#337421] Newbie on Threads — Nabs Kahn <nabusman@...>

I'm creating a screen scraping software and I want to have X (let's say

13 messages 2009/05/26
[#337424] Re: Newbie on Threads — Robert Klemme <shortcutter@...> 2009/05/26

2009/5/26 Nabs Kahn <nabusman@gmail.com>:

[#337507] Something Not going with my LDAP using SSL — Xeno Campanoli <xeno.campanoli@...>

I have the following working with cleartext LDAP:

20 messages 2009/05/26
[#337539] Re: Something Not going with my LDAP using SSL — Brian Candler <b.candler@...> 2009/05/27

Xeno Campanoli wrote:

[#338073] Re: Something Not going with my LDAP using SSL — Xeno Campanoli <xeno.campanoli@...> 2009/06/01

Brian Candler wrote:

[#338082] Re: Something Not going with my LDAP using SSL — Brian Candler <b.candler@...> 2009/06/01

Xeno Campanoli wrote:

[#338084] Re: Something Not going with my LDAP using SSL — Xeno Campanoli <xeno.campanoli@...> 2009/06/01

Brian Candler wrote:

[#338094] Re: Something Not going with my LDAP using SSL — Brian Candler <b.candler@...> 2009/06/01

Xeno Campanoli wrote:

[#338095] Re: Something Not going with my LDAP using SSL — Xeno Campanoli <xeno.campanoli@...> 2009/06/01

Brian Candler wrote:

[#338096] Re: Something Not going with my LDAP using SSL — Xeno Campanoli <xeno.campanoli@...> 2009/06/01

Xeno Campanoli wrote:

[#337574] Installing Ruby 1.9.1 Binary on Windows Vista — Joel Dezenzio <jdezenzio@...>

I've searched and only found one topic which did not have an answer or

27 messages 2009/05/27

[#337671] death toll — deka <rocha.deka@...>

Hi, I am a Brazilian girl and I have a doubt abour numbers in English.

13 messages 2009/05/28

[#337823] Endless Ruby 0.0.2 — Caleb Clausen <vikkous@...>

endless.rb is a pre-processor for ruby which allows you to use python-ish

22 messages 2009/05/29

[#337841] Regular expression — Harry Kakueki <list.push@...>

I want to write a regular expression to do the following.

13 messages 2009/05/29

[#337869] Quine (#207) — Daniel Moore <yahivin@...>

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

46 messages 2009/05/29
[#338000] Re: [QUIZ] Quine (#207) — pjb@... (Pascal J. Bourguignon) 2009/05/31

Robert Dober <robert.dober@gmail.com> writes:

[#338018] Re: [QUIZ] Quine (#207) — Aureliano Calvo <aurelianocalvo@...> 2009/06/01

I did something like that, but with parenthesis.

[#337899] Requesting Japanese Translation — James Gray <james@...>

I'm adding a little Japanese to a Ruby presentation I am giving. I

13 messages 2009/05/30

[#337961] nokogiri 1.3.0 Released — Aaron Patterson <aaron@...>

nokogiri version 1.3.0 has been released!

32 messages 2009/05/30
[#337962] Re: nokogiri 1.3.0 Released — Roger Pack <rogerpack2005@...> 2009/05/30

Aaron Patterson wrote:

[#337966] Re: nokogiri 1.3.0 Released — Aaron Patterson <aaron@...> 2009/05/30

On Sun, May 31, 2009 at 06:43:05AM +0900, Roger Pack wrote:

[#337968] Re: nokogiri 1.3.0 Released — Iii Iii <bqotatjyujepur@...> 2009/05/30

> gem install nokogiri

[#337985] Re: nokogiri 1.3.0 Released — Aaron Patterson <aaron@...> 2009/05/31

On Sun, May 31, 2009 at 08:37:54AM +0900, Iii Iii wrote:

[#338049] Re: nokogiri 1.3.0 Released — Roger Pack <rogerpack2005@...> 2009/06/01

[QUIZ][SUMMARY] Digits of Pi (#202)

From: Daniel Moore <yahivin@...>
Date: 2009-05-03 00:55:15 UTC
List: ruby-talk #335679
This week's quiz sparked quite a discussion!

Dan Diebolt introduced the Bailey-Borwein-Plouffe formula[1][2], a
formula for computing the nth binary digit of =F0 without computing the
previous digits, though no solutions were provided that incorporated
this formula.

Additionally, there was some talk of finding the first non-trivial
Ruby program encoded in the digits of =F0, but choosing an appropriate
encoding also proved to be non-trivial.

Harry Kakueki provided the first solution and made use of BigMath:

    require 'bigdecimal'
    require 'bigdecimal/math'
    include BigMath

    puts PI(100_000)

Executing this solution took a little over five minutes on my machine.
It is always good to know what libraries are already available.

Luke Cowell's solution uses the Leibniz formula for pi[3].

    require "rational"
    require 'enumerator'
    require 'bigdecimal'
    require 'bigdecimal/math'
    include BigMath

    iterations =3D 10000000000
    current =3D 1
    final =3D BigDecimal.new("4")
    other =3D false

    while(current < iterations) do
      current =3D current + 2
      if(other)
        final =3D final + Rational(4,current)
      else
        final =3D final - Rational(4,current)
      end

      other =3D !other
      print current.to_s + ":"
      puts final.to_f
    end

Unfortunately, Leibniz's formula is very inefficient for either
mechanical or computer-assisted =F0 calculation. Calculating =F0 to 10
correct decimal places using Leibniz' formula requires over
10,000,000,000 mathematical operations[3]. Luke stated on the mailing
list this algorithm was only able to generate about eight digits in
five minutes.

Jay Anderson provided a solution using a Machin-like formula[4] based
on the implementation from the LiteratePrograms wiki[5]:

    def arccot(x, unity)
        xpow =3D unity / x
        n =3D 1
        sign =3D 1
        sum =3D 0
        loop do
            term =3D xpow / n
            break if term =3D=3D 0
            sum +=3D sign * (xpow/n)
            xpow /=3D x*x
            n +=3D 2
            sign =3D -sign
        end
        sum
    end

    def calc_pi(digits =3D 10000)
        fudge =3D 10
        unity =3D 10**(digits+fudge)
        pi =3D 4*(4*arccot(5, unity) - arccot(239, unity))
        pi / (10**fudge)
    end

    digits =3D (ARGV[0] || 10000).to_i
    p calc_pi(digits)

This solution produces 100k digits in around 2 minutes on my machine.

Robet Dober mentions a speed increase when using Hwang Chien-Lih's
Machin-like formula with additional terms[6]:

    pi =3D 4*(183*arccot(239, unity) + 32*arccot(1023, unity) -
68*arccot(5832, unity) + 12*arccot(110443, unity) - 12*arccot(4841182,
unity) - 100*arccot(6826318, unity))

This does indeed improve the efficiency of the algorithm, I achieved
15-20% reduction in the time the algorithm took, down to about 100
seconds.

Charles Oliver Nutter pointed out the Ruby pidigits implementation on
the Computer Language Benchmarks Game[7] and provided some benchmarks
for various Ruby implementations:

    (jruby time is on Java 6 server VM)

    JRuby 1.3-dev:    0m47.903s
    Ruby 1.9.1:       1m27.527s
    Rubinius master:  2m50.545s
    MacRuby 0.4:      1m9.832s
    IKRuby*:          3m26.861s
    Ruby 1.8.7:       1m47.887s

    MacRuby 0.5-experimental crashed after only a few digits. IKRuby
is JRuby on CLR (Mono, here) using IKVM.

These benchmarks only produced 10k digits of =F0 (for expediency). One
lesson to take away from this is that algorithm choice often has the
biggest impact on performance.

    10,000 Digits (Ruby 1.8.6 on my machine)
      Machin-like formula : ~ 1s
      BigMath                   : ~ 2.5s
      pidigits                    : ~ 1m30s
      Leibniz formula       : ~ ?

And sometimes the fastest code is the code you don't write. Michael
Kohl's solution:

    require 'rubygems'
    require 'hpricot'
    require 'open-uri'

    doc =3D Hpricot(open('http://www.eveandersson.com/pi/digits/100000'))
    puts (doc/'pre').inner_html

It finishes in less than one second for the entire 100,000 digits!

Thank you everyone for your solutions and discussion! =F0 is a timeless
concept that has fascinated great minds for thousands of years and
will continue to do so. If you are interested in learning more please
follow the references as this summary barely scratches the surface.
Thanks again to all who participated this week.

[1]: http://everything2.com/title/Algorithm%20for%20calculating%20individua=
l%20hexadecimal%20digits%20of%20pi
[2]: http://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_fo=
rmula
[3]: http://en.wikipedia.org/wiki/Leibniz_formula_for_pi
[4]: http://mathworld.wolfram.com/Machin-LikeFormulas.html
[5]: http://en.literateprograms.org/Category:Pi_with_Machin%27s_formula
[6]: http://en.wikipedia.org/wiki/Machin-like_formula#More_terms (It
appears that this Wikipedia article is displaying arctan instead of
arccot)
[7]: http://shootout.alioth.debian.org/u32q/benchmark.php?test=3Dpidigits&l=
ang=3Druby&id=3D1

P.S. If you have any future quiz ideas be sure to submit them:
http://rubyquiz.strd6.com/suggestions.

--=20
-Daniel
http://rubyquiz.strd6.com

In This Thread

Prev Next