[#377882] remove array bracket — Kamarulnizam Rahim <niezam54@...>

Hi when i run my script, the output is as followed:

18 messages 2011/02/02

[#378046] Setter method for Hash value — Rolf Pedersen <rolfhsp@...>

Hi

20 messages 2011/02/03
[#378052] Re: Setter method for Hash value — Brian Candler <b.candler@...> 2011/02/03

Rolf Pedersen wrote in post #979431:

[#378056] Re: Setter method for Hash value — Rolf Pedersen <rolfhsp@...> 2011/02/03

Hi Brian (and others who have contributed with suggestions along the same

[#378144] C extension: How to check if a VALUE is still alive (not being GC'ed)? — Iñaki Baz Castillo <ibc@...>

Hi, I'm coding an async DNS resolver for EventMachine based on udns (a

13 messages 2011/02/05
[#378171] Re: C extension: How to check if a VALUE is still alive (not being GC'ed)? — Tony Arcieri <tony.arcieri@...> 2011/02/06

On Sat, Feb 5, 2011 at 4:02 PM, I=F1aki Baz Castillo <ibc@aliax.net> wrote:

[#378179] Re: C extension: How to check if a VALUE is still alive (not being GC'ed)? — Iñaki Baz Castillo <ibc@...> 2011/02/06

2011/2/6 Tony Arcieri <tony.arcieri@medioh.com>:

[#378199] Choosing an office suite — Hilary Bailey <my77elephants@...>

I am trying to decide which office suite to choose from. The only

30 messages 2011/02/07
[#378229] Re: Choosing an office suite — Phillip Gawlowski <cmdjackryan@...> 2011/02/07

On Mon, Feb 7, 2011 at 11:15 AM, Hilary Bailey <my77elephants@gmail.com> wrote:

[#378202] making hash key from arrays — Arihan Sinha <arihan_sinha@...>

Hi All,

11 messages 2011/02/07

[#378254] "permission denied" happening too often — Peter Bailey <pbailey@...>

Hello,

15 messages 2011/02/08
[#378256] Re: "permission denied" happening too often — Anurag Priyam <anurag08priyam@...> 2011/02/08

> I've got Ruby scripts that have been working fine for years now. But,

[#378257] Re: "permission denied" happening too often — Markus Schirp <mbj@...> 2011/02/08

You can also try to strace your script. In the logs you'll find the system

[#378259] Re: "permission denied" happening too often — Peter Bailey <pbailey@...> 2011/02/08

Markus Schirp wrote in post #980289:

[#378307] undefined class/module YAML::PrivateType - Error — "Priya D." <dharsininitt@...>

Hi,

11 messages 2011/02/09

[#378341] System calls with ` in parameters — "Gerad S." <geradstemke@...>

Hi All,

12 messages 2011/02/09

[#378618] Defining class methods — Tony Arcieri <tony.arcieri@...>

It seems there are 3 ways of defining class methods (at least in common

12 messages 2011/02/16

[#378685] LiveAST: a pure Ruby 1.9.2 library obtaining live abstract syntax trees — "James M. Lawrence" <quixoticsycophant@...>

= LiveAST

13 messages 2011/02/18

[#378753] posix_mq : Problem installing on HPUX — Tadeusz Bochan <tad.bochan@...>

Hello,

13 messages 2011/02/20

[#378890] a, b = Array.new(2).map!{|x| data.dup} — Stefan Salewski <mail@...>

I think I can replace this code

19 messages 2011/02/23
[#378892] Re: a, b = Array.new(2).map!{|x| data.dup} — niklas | brueckenschlaeger <niklas@...> 2011/02/23

Are you sure you can't rework your code to *not* copy data 5x? I assume

[#378899] Re: a, b = Array.new(2).map!{|x| data.dup} — Stefan Salewski <mail@...> 2011/02/23

On Thu, 2011-02-24 at 07:00 +0900, niklas | brueckenschlaeger wrote:

[#378941] Automatic question generator libs in Ruby Language — Sniper Abandon <sathish.salem.1984@...>

is there any Automatic question generator libraries in Ruby Language ?

20 messages 2011/02/24
[#379058] Re: Automatic question generator libs in Ruby Language — Sniper Abandon <sathish.salem.1984@...> 2011/02/27

suppose if i have a paragraph (arround 250 words)

[#379172] Re: Automatic question generator libs in Ruby Language — Shadowfirebird <shadowfirebird@...> 2011/03/01

> i want to get all the possible question from that paragraph

[#379174] Re: Automatic question generator libs in Ruby Language — Peter Zotov <whitequark@...> 2011/03/01

On Tue, 1 Mar 2011 19:31:36 +0900, Shadowfirebird wrote:

[#379175] Re: Automatic question generator libs in Ruby Language — Adam Prescott <mentionuse@...> 2011/03/01

On Tue, Mar 1, 2011 at 10:55 AM, Peter Zotov <whitequark@whitequark.org>wrote:

[#379177] Re: Automatic question generator libs in Ruby Language — Peter Zotov <whitequark@...> 2011/03/01

On Tue, 1 Mar 2011 20:02:13 +0900, Adam Prescott wrote:

[#379179] Re: Automatic question generator libs in Ruby Language — Adam Prescott <mentionuse@...> 2011/03/01

On Tue, Mar 1, 2011 at 12:28 PM, Peter Zotov <whitequark@whitequark.org>wrote:

[#378949] why is $1 in a grep() equal to nil? — 7stud -- <bbxx789_05ss@...>

class DataSource

16 messages 2011/02/24
[#378953] Re: why is $1 in a grep() equal to nil? — Eric Christopherson <echristopherson@...> 2011/02/25

On Thu, Feb 24, 2011 at 2:59 PM, 7stud -- <bbxx789_05ss@yahoo.com> wrote:

[#378958] parsing rule for this code? — 7stud -- <bbxx789_05ss@...>

1)

11 messages 2011/02/25

[#379000] Symbol#to_proc helping out with #select to beat Scala-s solution — Jarmo Pertman <jarmo.p@...>

Hey!

9 messages 2011/02/25

[#379074] finding a tag in a binary file — rob stanton <tnotnats@...>

I have a binary file in which I'd like to find multiple strings of 10

12 messages 2011/02/27

Re: Zlib::GzipReader and multiple compressed blobs in a single stream

From: Jos Backus <jos@...>
Date: 2011-02-02 19:37:26 UTC
List: ruby-talk #377979
    Hi Jeremy,

Thanks for your reply.

On Mon, Jan 31, 2011 at 02:28:30AM +0900, Jeremy Bopp wrote:
> On 01/28/2011 05:09 PM, Jos Backus wrote:
[snip]
> > Hi,
> > 
> > I'm trying to inflate a set of concatenated gzipped blobs stored in a single
> > file. As it stands, Zlib::GzipReader only inflates the first blob. It
> > appears that the unused instance method would return the remaining data,
> > ready to be passed into Zlib::GzipReader, but it yields an error:
> > 
> > method `method_missing' called on hidden T_STRING object
> > 
> > What could be going on here?
> 
> I'm not sure what's going on, but I was hoping you could solve your
> problem by running something like this:
> 
> File.open('gzipped.blobs') do |f|
>   begin
>     loop do
>       Zlib::GzipReader.open(f) do |gz|
>         puts gz.read
>       end
>     end
>   rescue Zlib::GzipFile::Error
>     # End of file reached.
>   end
> end

I tried something like this but as you point out, it doesn't work.

> Unfortunately, Ruby 1.8 doesn't appear to support passing anything other
> than a file name to Zlib::GzipReader.open, and Ruby 1.9 seems to always
> reset the file position to the beginning of the file prior to starting
> extraction when you really need it to just start working from the
> current position.  So it doesn't appear that you can do this with the
> standard library.
 
That's what it looks like, yes. Bummer.

> As part of a ZIP library I wrote, there is a more general implementation
> of a Zlib stream filter.  Install the archive-zip gem and then try the
> following:
> 
> gem 'archive-zip'
> require 'archive/support/zlib'
> 
> File.open('gzipped.blobs') do |f|
>   until f.eof? do
>     Zlib::ZReader.open(f, 15 + 16) do |gz|
>       gz.delegate_read_size = 1
>       puts gz.read
>     end
>   end
> end
> 
> 
> This isn't super efficient because we have to hack the
> delegate_read_size to be 1 byte in order to ensure that the trailing
> gzip data isn't sucked into the read buffer of the current ZReader
> instance and hence lost between iterations.  It shouldn't be too bad
> though since the File object should be handling its own buffering.

This works, but sadly it is very slow. Whereas zcat takes under a second on my
test file, this code takes about 17 seconds.

> BTW, I wrote some pretty detailed documentation for Zlib::ZReader.  It
> should explain what the 15 + 16 is all about in the open method in case
> you need to tweak things for your own streams.

Great. But I didn't have to tweak anything, it just worked :)

> > On a related note, Zlib::GzipReader#{pos,tell} returns the position in the
> > output stream (zstream.total_out) whereas I am looking for the position in
> > the input stream. I tried making zstream.total_in available but the value
> > appears to be 18 bytes short in my test file, that is, the next header is
> > found 18 bytes beyond what zstream.total_in reports.
> 
> I think total_in is counting only the compressed data; however,
> following the compressed data is a trailer as required for gzip blobs.
> You could probably always add 18 to whatever you get, but as I noted
> earlier, the implementation of GzipReader seems to always reset any file
> object back to the beginning of the stream rather than start processing
> it from an existing position.  I can't find any documentation listing a
> way to force GzipReader to jump to any other file position after
> initialization either.

Yeah, you'd have to feed GZipReader the right part of the input stream
yourself and figure out how much it processed. Something tells me it's not
always 18 but depends on internal buffering, which would invalidate the
assumption of a fixed offset.

> > Does anybody know how to make the library return the correct offset into the
> > input stream so multiple compressed blobs can be handled?
> 
> Hopefully, my solution will work for you because I don't think the
> current implementation in the standard library will do what you need.
 
It does, but it's very slow. Sigh.

Thanks again, Jeremy.

Cheers,
Jos
-- 
Jos Backus
jos at catnook.com

In This Thread