[#385051] How to order Structs based on two fields — Iñaki Baz Castillo <ibc@...>

Hi, I've a struct like this:

20 messages 2011/07/01
[#385052] Re: How to order Structs based on two fields — Iñaki Baz Castillo <ibc@...> 2011/07/01

2011/7/1 I=C3=B1aki Baz Castillo <ibc@aliax.net>:

[#385057] Re: How to order Structs based on two fields — Robert Klemme <shortcutter@...> 2011/07/01

On Fri, Jul 1, 2011 at 12:55 PM, I=F1aki Baz Castillo <ibc@aliax.net> wrote=

[#385069] Offering Help — Joe Peric <peric.joe@...>

I'm new to Ruby and I am willing to learn. Anyone need help on a

18 messages 2011/07/01
[#385072] Re: Offering Help — Jeremy Heiler <jeremyheiler@...> 2011/07/01

On Fri, Jul 1, 2011 at 11:43 AM, Joe Peric <peric.joe@gmail.com> wrote:

[#385073] Re: Offering Help — Joe Peric <peric.joe@...> 2011/07/01

Never heard of it, but I'll get right on it. Thanks.

[#385082] Re: Offering Help — Joe Peric <peric.joe@...> 2011/07/02

Just finished this. I had to find some more info on exceptions to get

[#385083] Re: Offering Help — Jeremy Heiler <jeremyheiler@...> 2011/07/02

On Sat, Jul 2, 2011 at 1:39 PM, Joe Peric <peric.joe@gmail.com> wrote:

[#385102] symbol vs string for hash keys — Intransition <transfire@...>

What are the important factors to consider when deciding whether to

12 messages 2011/07/03

[#385160] Fatal Error with Ruby/GTK2, Homebrew, Green Shoes, and OSX Snow Leopard — Timothy Barnes <barnes7td@...>

I posted the below question to the Shoes mailing list and got back the

10 messages 2011/07/09

[#385194] RubyInstaller Extras — Jon <jon.forums@...>

Since 2009, we've been pleased to include Huw Collingbourne's The Book of Ruby with RubyInstaller. Well now, Huw has a newly updated version, and he's published it with No Starch Press.

11 messages 2011/07/12

[#385207] Creating a range of directories — Simon Harrison <simon@...>

I'm wanting to create a range of directories with a prefix, like the

13 messages 2011/07/13

[#385276] Is there a more efficient way to remove data from a string? — Eddie Catflap <catflaporama@...>

Hi

9 messages 2011/07/15

[#385297] Help needed for a new release of text-hyphen — Austin Ziegler <halostatue@...>

I've had folks asking me for a release of text-hyphen that works with

12 messages 2011/07/15

[#385326] Comparing hashes based on their keys — Stefano Mioli <stefano.mioli@...>

Hi list,

13 messages 2011/07/15

[#385342] moving a 1.8.6 install? — Roggie Boone <rogboone@...>

Is it possible to move the gems from a Ruby 1.8.6 install on an (old)

10 messages 2011/07/15

[#385410] Better name for #zip_with — Intransition <transfire@...>

Any ideas for a better name for:

13 messages 2011/07/18

[#385452] Ruby + USB + CCTV Camera Driver? — "Bob Carpenter." <rgc3679@...>

I want to write a Ruby driver that handles the feed from A CCTV camera.

23 messages 2011/07/18
[#385459] Re: Ruby + USB + CCTV Camera Driver? — William Rutiser <wruyahoo05@...> 2011/07/18

On 2011-07-18 1:00 PM, Bob Carpenter. wrote:

[#385461] Re: Ruby + USB + CCTV Camera Driver? — "Bob Carpenter." <rgc3679@...> 2011/07/18

William Rutiser wrote in post #1011466:

[#385462] Re: Ruby + USB + CCTV Camera Driver? — Hassan Schroeder <hassan.schroeder@...> 2011/07/18

On Mon, Jul 18, 2011 at 11:51 AM, Bob Carpenter. <rgc3679@yahoo.com> wrote:

[#385464] Re: Ruby + USB + CCTV Camera Driver? — "Bob Carpenter." <rgc3679@...> 2011/07/18

Hassan Schroeder wrote in post #1011472:

[#385471] Re: Ruby + USB + CCTV Camera Driver? — Hassan Schroeder <hassan.schroeder@...> 2011/07/18

On Mon, Jul 18, 2011 at 12:58 PM, Bob Carpenter. <rgc3679@yahoo.com> wrote:

[#385474] Re: Ruby + USB + CCTV Camera Driver? — Phillip Gawlowski <cmdjackryan@...> 2011/07/18

On Tue, Jul 19, 2011 at 12:18 AM, Hassan Schroeder

[#385477] Re: Ruby + USB + CCTV Camera Driver? — "Bob Carpenter." <rgc3679@...> 2011/07/19

Phillip Gawlowski wrote in post #1011503:

[#385509] A beginner question. — "Cajus A." <cajus_@...>

Hi i'm trying to write and example program where you speak to a

12 messages 2011/07/19

[#385542] Splitting strings — Ryan Mckenzie <ryan@...>

Hi all,

18 messages 2011/07/19

[#385565] error building ruby p290 — Dev Guy <devguy.ca@...>

I get the following build error on my Linux box while trying to build

12 messages 2011/07/20

[#385629] Are Job Ads OK? — Lee Hughes <lee@...>

Is it OK to post Ruby job ads on this forum?

12 messages 2011/07/21

[#385847] String manuplation example — kotin 76 <kotin76@...>

Hi,

15 messages 2011/07/27

[#385860] Counting lines of code in a ruby code file ignoring method code lines in the process — Harry Truax <htruax@...>

Hello,

8 messages 2011/07/27

[#385936] Help in Pointer — Tridib Bandopadhyay <tridib04@...>

Hello

18 messages 2011/07/29

[#386012] Ruby a "4th generation language"? Credible sources? — Albert Schlef <albertschlef@...>

I've noticed that Wikipedia says that "C#, Java" are 3'rd generation

13 messages 2011/07/31

[#386050] system stack error in ObjectSpace.each_object — luke gruber <luke.gru@...>

Hey guys, I'm just starting to mess around with metaprogramming in Ruby,

14 messages 2011/07/31
[#386052] Re: system stack error in ObjectSpace.each_object — Josh Cheek <josh.cheek@...> 2011/07/31

On Sun, Jul 31, 2011 at 4:29 PM, luke gruber <luke.gru@gmail.com> wrote:

[#386055] Re: system stack error in ObjectSpace.each_object — luke gruber <luke.gru@...> 2011/08/01

> Typically, SystemStackError is due to recursing for too long, perhaps I

[#386058] Re: system stack error in ObjectSpace.each_object — Robert Klemme <shortcutter@...> 2011/08/01

On Mon, Aug 1, 2011 at 3:56 AM, luke gruber <luke.gru@gmail.com> wrote:

Re: Issue downloading an image from a URL (HTTP request)

From: Jes俍 Gabriel y Gal疣 <jgabrielygalan@...>
Date: 2011-07-22 06:55:19 UTC
List: ruby-talk #385655
2011/7/22 Jes=FAs Gabriel y Gal=E1n <jgabrielygalan@gmail.com>:
> On Thu, Jul 21, 2011 at 7:42 PM, Hunter Mcmillen <mcmillhj@gmail.com> wro=
te:
>> I am trying to download the image of a chart I created using the
>> GoogleChart API using the 'net/http' module. I have the URL I want to
>> download the image from stored in a string variable named failures_url,
>> when I use the variable to download the image it doesn't work. But if I
>> use the string literal value of that variable it does work.
>
> I don't know why one of your attempts works and the other won't, maybe
> you should post a complete example that fails. But looking at how I'd
> do it I realized that in the failures_url variable there are a couple
> of characters that are not valid for a URL and should be escaped: %
> and |. So I tried this and it worked for me:
>
> ruby-1.8.7-p334 :022 > require 'open-uri'
> =A0=3D> true
> ruby-1.8.7-p334 :037 >
> failures_url=3D"chtt=3DFailure+By+Type+Over+Last+Year&cht=3Dp&chd=3Dt:26.=
8720821661998,25.6022408963585,24.9859943977591,17.9831932773109,2.80112044=
817927,0.65359477124183,0.354808590102708,0.336134453781513,0.2240896358543=
42,0.168067226890756,0.130718954248366,0.0373482726423903&chs=3D700x400&chc=
o=3D4466AA|9BC4E2|1464F4|0000FF|63D1F4|388E8E&chl=3DBuild/Compile+Failure+2=
6.87%|Unknown+Failure+25.6%|User+Manifest+Failure+24.99%|Invalid+Clientspec=
+17.98%|Incomplete+Build+2.8%|Coverity+System+Error+0.65%|Do+Not+Use+Error+=
0.35%|Version+Failure+0.34%|Coverity+Defects+0.22%|Flash+Build+Error+0.17%|=
Space+Insufficient+0.13%|Integrate+Failure+0.04%"
> ruby-1.8.7-p334 :038 > failures_url.gsub!("%", URI.escape("%"))
> =A0=3D> "chtt=3DFailure+By+Type+Over+Last+Year&cht=3Dp&chd=3Dt:26.8720821=
661998,25.6022408963585,24.9859943977591,17.9831932773109,2.80112044817927,=
0.65359477124183,0.354808590102708,0.336134453781513,0.224089635854342,0.16=
8067226890756,0.130718954248366,0.0373482726423903&chs=3D700x400&chco=3D446=
6AA|9BC4E2|1464F4|0000FF|63D1F4|388E8E&chl=3DBuild/Compile+Failure+26.87%25=
|Unknown+Failure+25.6%25|User+Manifest+Failure+24.99%25|Invalid+Clientspec+=
17.98%25|Incomplete+Build+2.8%25|Coverity+System+Error+0.65%25|Do+Not+Use+E=
rror+0.35%25|Version+Failure+0.34%25|Coverity+Defects+0.22%25|Flash+Build+E=
rror+0.17%25|Space+Insufficient+0.13%25|Integrate+Failure+0.04%25"
> ruby-1.8.7-p334 :039 > failures_url.gsub!("|", URI.escape("|"))
> =A0=3D> "chtt=3DFailure+By+Type+Over+Last+Year&cht=3Dp&chd=3Dt:26.8720821=
661998,25.6022408963585,24.9859943977591,17.9831932773109,2.80112044817927,=
0.65359477124183,0.354808590102708,0.336134453781513,0.224089635854342,0.16=
8067226890756,0.130718954248366,0.0373482726423903&chs=3D700x400&chco=3D446=
6AA%7C9BC4E2%7C1464F4%7C0000FF%7C63D1F4%7C388E8E&chl=3DBuild/Compile+Failur=
e+26.87%25%7CUnknown+Failure+25.6%25%7CUser+Manifest+Failure+24.99%25%7CInv=
alid+Clientspec+17.98%25%7CIncomplete+Build+2.8%25%7CCoverity+System+Error+=
0.65%25%7CDo+Not+Use+Error+0.35%25%7CVersion+Failure+0.34%25%7CCoverity+Def=
ects+0.22%25%7CFlash+Build+Error+0.17%25%7CSpace+Insufficient+0.13%25%7CInt=
egrate+Failure+0.04%25"
> ruby-1.8.7-p334 :040 > File.open("test.png", "wb") {|f| f.write
> open("https://chart.googleapis.com/chart?#{failures_url}").read}
> =A0=3D> 46677
>
> and I got your nice pie chart in test.png. Ideally you would
> URI.escape each parameter and value of the URL separately, but as in
> this example you already had the big string with everything I cherry
> picked the problematic characters. But if you are building the query
> string programatically, you should escape like this. Say you have a
> map with all the params and values for the query string:
>
> require 'uri'
>
> map =3D {"chtt" =3D> "Failure By Type Over Last Year", "cht" =3D> "p" } #=
 and so on
>
> failures_url =3D ""
> map.each {|key,value| failures_url << URI.escape(key) << "&" <<
> URI.escape(value)}
>
> and then the rest of the program.

Ooops, sorry, I got it wrong (I was joining with &):

map =3D {"chtt" =3D> "Failure By Type Over Last Year", "cht" =3D> "p" } # a=
nd so on
failures_url =3D map.map {|key,value|
"#{URI.escape(key)}=3D#{URI.escape(value)}" }.join("&")


Jesus.

In This Thread

Prev Next