On Nov 18, 2:28=A0pm, Peter Szinek <pe... / rubyrailways.com> wrote:
> > Yes, the quiz is (usually) posted Friday, so submissions typically =A0
> > start rolling in Sunday. And Martin did provide his alcohol =A0
> > submission yesterday. So feel free to post.
>
> OK. <drumroll> my first submission to Ruby-quiz:
>
> (After all those discussion on cheating, I am not sure if this =A0
> solution is not considered cheating of some sort ;-)
>
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> require 'rubygems'
> require 'cgi'
> require 'scrubyt'
>
> begin
> google_converter =3D Scrubyt::Extractor.define do
> =A0 =A0fetch "http://www.google.com/search?q=3D#{CGI::escape(ARGV[0])}
> +#{CGI::escape(ARGV[1])}+to+#{CGI::escape(ARGV[2])}"
>
> =A0 =A0google_result "//td[@dir=3D'ltr']" do
> =A0 =A0 =A0final_result(/=3D (.+) /)
> =A0 =A0end
> end
> =A0 =A0puts google_converter.to_hash[0][:final_result]
> rescue
> =A0 =A0puts "Sorry, even *google* can't translate that!"
> end
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>
> ex:
> ruby converter.rb 10 "meter per second" "mile per hour"
> 22.3693629
>
> ruby converter.rb 10 USD EUR
> 7.91201836
>
> ruby converter.rb 7 "ruby gems" "python eggs"
> Sorry, even *google* can't translate that!
> etc.
>
> disadvantage: you need to be online
> advantage: it's quite rich, robust and up-to date (e.g. currency =A0
> conversions)
>
> I am wondering if this solution is (at least somewhat) OK - I have a =A0
> similar one, though that doesn't require you to be on-line. However, I =
=A0
> am not going to implement it if the above solution is BS :-)


I think this is an interesting solution b/c it is prescient of a
future we are likely to see. When average broadband connections
approach 1gbs or so this kind of thing will be the norm. We are seeing
this evolution now, with software not being installed by physical
media any longer, but via online package management. And now with
things like RubyGems it is becoming even more fine grained.

Ultimately "usr/lib" will be on the wire.

So what is your similar solution? Taking a guess... is it this with a
cache?

T.


> Cheers,
> Peter
> ___http://www.rubyrailways.comhttp://scrubyt.org