php-general Digest 20 Sep 2012 05:53:24 -0000 Issue 7971
Topics (messages 319143 through 319153):
Re: Programmers and developers needed
319143 by: Matijn Woudt
319150 by: Govinda
319151 by: Aaron Holmes
319152 by: Ashley Sheridan
319153 by: Matijn Woudt
stream_read function for registered wrapper class.
319144 by: Rob
319145 by: Adam Richardson
319147 by: Matijn Woudt
319148 by: Rob
319149 by: Rob
Re: PHP Re: Programmers and developers needed
319146 by: Tim Streater
Administrivia:
To subscribe to the digest, e-mail:
php-general-digest-subscr...@lists.php.net
To unsubscribe from the digest, e-mail:
php-general-digest-unsubscr...@lists.php.net
To post to the list, e-mail:
php-gene...@lists.php.net
----------------------------------------------------------------------
--- Begin Message ---
On Wed, Sep 19, 2012 at 4:50 PM, Doug Heimbecker <d...@tac.us> wrote:
>> Not to say I'm all in for communism... but communism failed for the same
>> reason capitalism is failing. Corruption!
>
>
> Here might be a way to deal with this political issue, while keeping on
> topic with the "world peace PHP project":
>
> I've had this idea for years, but why not start a "technocracy" or "ultra
> social-democracy" that runs on a decentralized server, kind of like P2P
> (Kad, Bitcoins, etc.) -- only problem being the logic running the system
> (say, PHP scripts) would need to be programmed as a whole (so anyone could
> re-program the structure of such a social system, so it functioned the way
> everyone wanted). Think Wikipedia, but completely decentralized -- nobody
> could "corrupt" the system unless they were a majority. This seems to be the
> direction we're heading in -- what with hidden corruption, and most
> governments being slow processing laws, reforms, etc.
"unless they were a majority" is the thing that bothers me. Getting a
majority is hard, take for example the Dutch Politics [1]. Our country
is now led by a parliament of 10 different political parties. Getting
things done now is really hard, because each party has their own goals
and finding a majority is for almost impossible. If all the parties
were strictly following their own will, there would probably only a
handful things done. The only way to get things done now is by making
compromises.
Another example is of course religion [2]. You can see that there's no
majority there. Christianity being the largest with 33%. Even if that
would be over 50%, you won't get peace if you say Christianity is the
only correct religion..
- Matijn
[1] http://en.wikipedia.org/wiki/Politics_of_the_Netherlands
[2] http://en.wikipedia.org/wiki/Religion
--- End Message ---
--- Begin Message ---
On 2012-09-18, at 4:36 PM, Paul M Foster wrote:
> [snip]
> I've gone so far as to force my computer/browser to
> believe most common providers of ad content are localhost, making
> most requests for ad content yield 404 errors.
I thought that ^^^ sounded really clever. Care to share your hosts file? ;-)
Thanks,
-Govinda
--- End Message ---
--- Begin Message ---
Hi,
Can we let this thread die now?
--- End Message ---
--- Begin Message ---
Aaron Holmes <aa...@aaronholmes.net> wrote:
>Hi,
>Can we let this thread die now?
But, but, what about world peace and stuff?!
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
--- End Message ---
--- Begin Message ---
Op 20 sep. 2012 01:45 schreef "Ashley Sheridan" <a...@ashleysheridan.co.uk>
het volgende:
>
>
>
> Aaron Holmes <aa...@aaronholmes.net> wrote:
>
> >Hi,
> >Can we let this thread die now?
>
> But, but, what about world peace and stuff?!
>
If it ever was alive, it will die the same way as this thread, after a long
discussion...
--- End Message ---
--- Begin Message ---
I have a very large XML file that I have to process. It's about 7 GB.
Some of the individual elements that I need are larger than 8192 bytes.
I'm trying to write a Stream wrapper class to give me a specific element
at a time, but I keep running into issues with the stream wrapper and
fread, stream_get_content functions.
fread will never return more than 8192 bytes (is that a bug?), so I can't
use that at all. When I use stream_get_content, and pass in 16384, weird
things happen in my stream_read method. If I return 16384 bytes, it gets
truncated to 8192, and the stream_read method is called again and again,
until the total returned is 16384. Normally, stream_read is called twice
in this case (since it "returns" 8192 both times).
This really screws up what I'm trying to do with this stream wrapper.
Admittedly, I don't know much about stream wrappers. This is my first
one, and I can't find much relevant documentation on them. But it
doesn't seem like it's working correctly to me. If I ask for 16384 bytes
with fread, shouldn't it give me 16384 bytes? And if I return 16384
bytes when I use stream_get_contents, shouldn't it return 16384 bytes the
first time?
Thanks for any help.
-- Rob
--- End Message ---
--- Begin Message ---
On Wed, Sep 19, 2012 at 12:43 PM, Rob <rob_ad...@hotmail.com> wrote:
> I have a very large XML file that I have to process. It's about 7 GB.
> Some of the individual elements that I need are larger than 8192 bytes.
> I'm trying to write a Stream wrapper class to give me a specific element
> at a time, but I keep running into issues with the stream wrapper and
> fread, stream_get_content functions.
You could just use the XML Parser (SAX) as it doesn't require loading
the entire document into memory:
http://php.net/manual/en/book.xml.php
Adam
--
Nephtali: A simple, flexible, fast, and security-focused PHP framework
http://nephtaliproject.com
--- End Message ---
--- Begin Message ---
On Wed, Sep 19, 2012 at 6:43 PM, Rob <rob_ad...@hotmail.com> wrote:
> I have a very large XML file that I have to process. It's about 7 GB.
> Some of the individual elements that I need are larger than 8192 bytes.
> I'm trying to write a Stream wrapper class to give me a specific element
> at a time, but I keep running into issues with the stream wrapper and
> fread, stream_get_content functions.
>
> fread will never return more than 8192 bytes (is that a bug?), so I can't
> use that at all. When I use stream_get_content, and pass in 16384, weird
> things happen in my stream_read method. If I return 16384 bytes, it gets
> truncated to 8192, and the stream_read method is called again and again,
> until the total returned is 16384. Normally, stream_read is called twice
> in this case (since it "returns" 8192 both times).
>
> This really screws up what I'm trying to do with this stream wrapper.
> Admittedly, I don't know much about stream wrappers. This is my first
> one, and I can't find much relevant documentation on them. But it
> doesn't seem like it's working correctly to me. If I ask for 16384 bytes
> with fread, shouldn't it give me 16384 bytes? And if I return 16384
> bytes when I use stream_get_contents, shouldn't it return 16384 bytes the
> first time?
>
> Thanks for any help.
>
> -- Rob
I'm not sure if I'm missing something here, but PHP manual clearly
states that when using fread on streams you need to call fread in a
loop to get the amount of bytes required, as it will only return 1
packet at a time (TCP/IP are usually 8192 bytes).
(Though Adam is probably right that the builtin XML parser is the best way)
- Matijn
--- End Message ---
--- Begin Message ---
Sorry, I just realized my replies were going to email instead of the news
group.
I'm going to try upgrading to php 5.4 so I have access to this:
http://php.net/manual/en/function.stream-set-chunk-size.php
And see if that fixes some of my problems. Thanks for the suggestions.
--- End Message ---
--- Begin Message ---
Followup:
I installed php 5.4.7 and tried using stream_set_chunk_size. It is now
working as expected with stream_get_contents.
Here is my stream wrapper class:
http://pastebin.com/aGhxSuQh
Here is how it is used:
http://pastebin.com/jd42uxiy
Hope that helps someone else that is having issues with stream wrappers.
-- Rob
--- End Message ---
--- Begin Message ---
On 19 Sep 2012 at 16:32, Matijn Woudt <tijn...@gmail.com> wrote:
> "unless they were a majority" is the thing that bothers me. Getting a
> majority is hard, take for example the Dutch Politics [1]. Our country
> is now led by a parliament of 10 different political parties. Getting
> things done now is really hard, because each party has their own goals
> and finding a majority is for almost impossible. If all the parties
> were strictly following their own will, there would probably only a
> handful things done. The only way to get things done now is by making
> compromises.
And so Dutch governments only last short periods of time, and it takes a long
time to create a coalition. This is why Proportional Representation is such a
bad idea. Better to have strong government with a clear mandate, and if you
don't like it, vote it out next time.
By the way what does any of this have to do with PHP? Nothing, I think.
--
Cheers -- Tim
--- End Message ---