« first day (450 days earlier)      last day (4487 days later) » 

8:02 PM
In pseudocode, it's all about:

while(true) {
    socket_select(/* waits for socket*/);
    // check message type...
    // ... to connect client
    // ... or to disconnect one
    // ... and notify applications (which are basically objects with some functions-turned-events)
}
uhm, by the way, the part about notifying the apps is the one that takes 100ms to run (intentionally, for testing purposes).
 
hi all
 
what doesn't work
@ChristianSciberras the buffer gets full?
makes me want to keep working on my evented framework...
 
@ircmaxell I was thinking about this while I was making my tea...
 
The hard part is the event loop
 
Screw the event loop. Outsource it to a message queue for maximum mindf***ery.
 
8:15 PM
No, I want to do evented programming in PHP
similar to Node.js
 
@ircmaxell @NikiC By the way, that flame war in C++ about PHP was right about "pile of < EXPLETIVE > instead of standard library".
 
mostly as a for-fun project, not a practical one
@LeviMorrison lol
 
I assure you that an external message queue will be very impractical. ;)
Been pondering writing an event-based distributed horror show just to scare myself.
 
Well, I was thinking about having two main types of loops
"Events" which are non-streams that need to be polled, and streams which run via stream_select...
so the logic would be:
public function run() {
	try {
		while (true) {
			while (!empty($this->events)) {
				foreach ($this->events as $event) {
					$event();
				}
				$this->processStreamSelects();
			}
			$this->processStreamSelects();
		}
	} catch (ShutdownException $e) {}
}
 
Oh, I understand now.
Wasn't thinking about I/O based stuff.
 
8:22 PM
yeah, so you can do $loop->registerEvent(function() {})
@Charles Well, yes. So it's all continuation passing and async I/O (DB calls, CURL requests, File operations, etc)
 
I presume you're designing it against 5.4 for anonymous function binding and whatnot?
 
against 5.3, but it would work with 5.4...
 
Hey guys
do anyone use Navicat?
 
More HashDOS on @internals
Fun stuff
 
someone commented on my Singleton blog post with:
> Dependency Injections are (at least) just as bad tonymarston.net/php-mysql/dependency-injection-is-evil.html
after going through the linked article im not sure i want to approve the comment because its fubar
 
8:36 PM
> Design patterns are an option, not a requirement
Evolution is just a theory! Gravity too!
 
eih
 
He uses singletons in his examples and is forcing objects to pass by reference.
I'm going to put his opinions in the "invalid" category.
 
It's funny to read though
> If module A needs to perform some processing which is already contained within Module B then Module A simply calls Module B. This may create a dependency, but so what? It's certainly better than having the code within Module B duplicated within Module A. This is what "Modular Programming" is all about, and Object Oriented Programming is supposed to be an extension of this paradigm by using "objects" instead of "modules".
I used to think like that until someone showed me interface segregation. Back when I started to learn about objects
But well. The post seems to be at least 6 years old
So i guess thats fine
 
The "When is Dependency Injection a good idea?" heading pretty much says it all. "I don't use automated testing therefore DI is worthless to me."
 
@Charles But he is right. If he isn't testing, what does it matter? :)
 
8:43 PM
Testing only shows you those problems, it's not the reason we try to avoid them
 
@LeviMorrison It only really matters because he's going on and on in a rant about how DI sucks and is horrible when he could basically cut down the entire thing to just that little section and be just as clear.
 
Testing is never a reason to strive for proper class design. It's only a way to uncover issues.
 
True, but when testing begins to impose class design decisions on you, that's something else entirely
 
@Charles I dismissed his arguments as he clearly is someone who LIKES to go against the grain. Going against the grain is fine. Doing it just for doing its sake isn't, not in my opinion.
 
I can test highly coupled code too if I use a hammer big enough. The issue comes from not being able to have properly separated concerns in the (production) application. Thats what breaks ones neck
> If you say that B is tightly coupled to A you are implying that the coupling is so tight that B can only be coupled with A and cannot be accessed from any other module within the system.
 
8:46 PM
Is this a bad usage?
 
All right. I can stop now too. Nothing to learn from that now :)
 
public function __construct($address, $port = 80) {
    $this->address = $address;
    $this->port = $port;
    parent::__construct(AF_INET, SOCK_STREAM, SOL_TCP);
}
 
He, welcome back @GrumpyCanuck
 
@edorian hey, I missed your message from earlier where you were asking about how to organize PHPUnit tests
 
@ircmaxell Why should it? :)
 
8:46 PM
@ircmaxell Isn't that going to complain loudly about constructors not matching?
 
@Charles it will...
 
Hurray for little red circles driving people back in the chat :)
@Charles I sure it it's not!
Some minor php versions where broken that way
 
@edorian E_STRICT
 
But you should be able to freely chance constructors all you like
@ircmaxell Really? In 5.3.8 and 5.4?
I thought the dicussion concluded that this is the good way of going about this issue... after people broke it again and again
@GrumpyCanuck I was just curious about your thought as I have strong opinions on that myself
@GrumpyCanuck And since no one has properly written down test organisation I was interested in your approach
 
hrm, odd. It's not throwing it on codepad
 
8:49 PM
When I start getting too many tests I try and think of the best way to group them together based on the structure of the app itself
Group all my model tests (for example)
or if your application is comprised of modules than group the tests by modules
luckily PHPUnit doesn't care cuz it will just recurse through all yout stuff
 
 php -d error_reporting=-1 -r 'class foo { public function __construct($a, stdclass $b) {} } class bar extends foo { public function __construct(stdclass $x) {} } $x = new Bar(new stdclass); '
No errors. Like I think it should be
@GrumpyCanuck So do you advice any specific folder layout for tests?
 
A stream class. should it create the resource in the constructor?
nevermind
 
@ircmaxell Thats a question I face again and again.. I tend to go with "do what is needed to provide proper error messages at the right point in time"
 
I did
 
cough depedency injection cough
 
8:53 PM
public function __construct($domain, $type, $protocol) {
    $this->resource = socket_create($domain, $type, $protocol);
    if (!is_resource($this->resource)) {
        $message = sprintf(
            'Socket Creation Failed: [%d] %s',
            socket_last_error(),
            socket_strerror(socket_last_error())
        );
        throw new RuntimeException($message);
    }
}
@GrumpyCanuck that directed at me?
 
@edorian no specific layout, just one that makes sense based on the app itself
@ircmaxell maybe a little :P
 
what dependency would you inject?
 
@ircmaxell Looks good to me. I don't really see how you could take that out there if you don't want a "connect" method for the socket class (which is a option I assume you have considered)
 
Well, creating it doesn't really do anything aside from getting a file descriptor from the OS
it doesn't connect to anything (or bind anywhere)
 
@GrumpyCanuck Interesting. I'm pretty set in always using the same basic structure to store unit, integration and functional tests and the resources (static xml files and so on) they need. Hence me asking
 
8:56 PM
oh, I thought you were talking about just unit tests
I definitely recommend putting unit, integration and functional tests in their own folders
 
@GrumpyCanuck huh? in which case?
 
@ircmaxell relax, you're doing it in the constructor
injecting the stuff it needs
 
@GrumpyCanuck Agree github.com/ircmaxell/PHP-CryptLib/tree/master/test (Unit and Vectors are the two classes of tests)
 
although for testing purposes you could consider creating the socket outside
if you ever wanted to be masochistic and mock out a socket
 
@GrumpyCanuck Well, yeah, but this is a low level library, so I don't know if it should do DI that deep
 
8:58 PM
gotta go :)
cu laters
 
I'm not sure you should wrap "Socket" there... I mean.. I would. But then again I'm doing java with dollar signs
 
@hakre hf
 
@edorian lol
 
@GrumpyCanuck Book cover? :)
 
8:59 PM
only if I want zero sales
 
Well, here's the thing. I'm trying to do evented-IO in PHP. So at some level I need to completely isolate the low level functions. I don't want people to need to use socket_create...
 
I'd buy it!
 
im so bad at this, i messaged the system admin guy. i wish adding a module was as easy as adding a library for other languages
 
Back to the crazy DI guy:
Dependency injection is effective in these situations:
You need to inject configuration data into one or more components.
You need to inject the same dependency into multiple components.
You need to inject different implementations of the same dependency.
You need to inject the same implementation in different configurations.
You need some of the services provided by the container.
Dependency injection is not effective if:
You will never need a different implementation.
 
9:01 PM
ircmaxell evented-IO in PHP?
really?
I appreciate your balls of steel
 
@GrumpyCanuck that's what I'm trying to do
LOL
actually, I'm trying to do a full blown evented framework (for lack of a better term). Think Node.js in PHP...
 
@GrumpyCanuck So you don't just mirror your application folder layout in your test folders? Why not If i may ask (for the unit tests)
 
/me just vomitted at the thought of node.js for PHP
 
LOL
 
Well we already have npm!
We called it pear and it had lots of unmaintained stuff before it was cool!
 
9:03 PM
@edorian Sometimes I find it better conceptually to group tests based on the things you are actually testing. There is really no right answer
If I was going to do evented-IO I'd use Python (Twisted or Tornado) and wait until Node gets to 1.0 before trusting it to do ANYTHING for me
 
You and funkatron keep saying that. Of course there isn't :) It's PHP. The right answer is always the one that works best for you / the current case
 
Well, I just meant the concept
ok, this feels really bad:
public function accept() {
    $resource = socket_accept($this->resource);
    if ($resource) {
        $socket = new static($this->domain, $this->type, $this->protocol);
        socket_close($socket->resource);
        $socket->resource = $resource;
        return $socket;
    }
}
 
@ircmaxell Yeah.. it should feel bad
 
evented code in a not-built-to-be-evented environment always feels weird
 
hrm...
 
9:05 PM
Also you are enforcing constructor signatures which also feels wired
 
yeah...
 
9:18 PM
@ircmaxell would love to see it :-) good luck!
 
Let's say you have several modes of operation. A user supplies an invalid mode to the factory. What exception would you suggest throwing?
(Yes, I'm back to PHP's exceptions)
 
@KamilTomšík Trying, for fun
@LeviMorrison DomainException?
 
@LeviMorrison DomainException?
 
hello friends i am stuck with a gallery code of php can anyone help
 
@ircmaxell doesnt matter, still interested in what will come from that
 
9:20 PM
My immediate reaction was InvalidArgumentException. After thinking about it for a tiny bit I thought the same. Figured I'd ask.
 
btw: have you noticed that poll in upper right corner?
(pear vs. pecl) ;)
 
It's the Java in my blood, I guess.
 
@LeviMorrison bad for you :-D
 
I'm getting some REALLY odd code here though
public function poll() {
    $socket = $this->tcp->accept();
    if ($socket) {
        $parser = new HTTP($this->eventLoop);
        $parser->parse($socket, function(Request $request) {
            $request->handle();
        });
    }
}
 
btw: today I've written about 10 lines of java code, the rest of my work was oracle stuff and fixing integration scripts :-D
 
9:22 PM
hey guys want to hear how big an idiot i am
 
isnt that fun?
 
@JMRboosties If you want it nicely, you are in the correct place. If you want to hear it rudely, move to C++.
 
@JMRboosties well, thats a good start :-)
 
@ircmaxell did you see the link i posted earlier on? github.com/fhoenig/Kellner
 
my system admin added that module last friday, i usually get emails from my host when a support ticket has been edited, but i didnt see it this time
so ive been struggling to try and add a module thats been there the entire time
 
9:23 PM
@KamilTomÅ¡ík 2000 LOC per Year. That's 2 times the speed of excel development
 
nice
 
fml
 
@edorian do you count removed lines? :-) (I'd be in negatives for this year)
 
id love to add support for the module to my IDE so i dont get these nasty red underlines
 
@KamilTomÅ¡ík The paper sadly didn't. But removing is usually better anyways :)
 
9:25 PM
@edorian yep, +1 on that
since by removing lines, you're usually also increasing mantainability
 
@edorian "Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." ~Antoine de Saint-Exupery
 
@LeviMorrison yep, or: Everything should be made as simple as possible, but no simpler. (papa bert)
 
ok, this feels even more dirty
public function parse(\Events\Resources\Socket $socket, \Closure $callback) {
    $parser = $this;
    $loop = $this->eventLoop;
    $this->eventLoop->attachEvent($func = function() use ($parser, $socket, $callback, $loop, &$func) {
        static $buffer = '';
        $buffer .= $socket->read(1024);
        if ($parser->isValid($buffer)) {
            $callback($parser->createRequest($buffer));
            $loop->detachEvent($func);
        }
    });
}
 
When I refactor code to remove singletons, I find that almost always I and up creating a factory that deploys the object instance around to everything. Anyone have the same experience?
 
Ohh, idea. time to throw away everything
 
9:35 PM
@LeviMorrison I try and avoid singletons AND factories or at least pretend they don't exist :P
 
If you only have one instance of that object that you need why not pass it around instead of a factory?
 
@edorian People who write singletons tend to use a lot of global state. So, in order to make it as compatible as I can with currently implemented code, I have a factory that violates all sorts of rules but at least the things it makes can be fully tested.
 
Oh that. Yeah, been there
 
I should put Singleton Removal Specialist as a skill I have on my test resume. That's basically all I've done in about the last two months :/
 
Huh all * sucks messages are pinned?
 
9:40 PM
Well, PHP does suck . . . but it doesn't matter: codinghorror.com/blog/2008/05/…
 
lol
 
> Does PHP suck? Of course it sucks. Did you read any of the links in Tim's blog entry? It's a galactic supernova of incomprehensibly colossal, mind-bendingly awful suck.
 
Yay 10k rep.
The question I got the latest rep from: stackoverflow.com/questions/8792084/…
:P
 
@LeviMorrison Ah, the good portion of PHP flaming we all love so much :)
good night :)
 
Congrats @PeeHaa
hrm, this new idea is worthless. Time to throw everythign away again
 
9:51 PM
Thanks @ircmaxell! Now respect my authoritah! ;)
 
get 20k rep, and then we'll talk :-P
 
I have to throw out code . . . again.
 
Hey has anyone had problems with css gradients in ff 5 and 7 (the type with more than 2 colours)?
 
@StephenWolfe No, I use an image if I need more than two colors.
 
Iv used an image for IE but it seems such a waste to do it for FF :(
 
10:03 PM
@ircmaxell I will... eventually :)
 
@StephenWolfe Usually I can layer 2 color gradients to get what I need if an image won't do. For example, HTML and BODY cover the exact same area in most of my sites. I can leverage this to use 1 gradient for HTML, and one for BODY, and viola, I have what I need.
 
@LeviMorrison im just checking my code. because i have i have a 4 point gradient that works but the 3 point doesn't so might just change the gradient
@LeviMorrison for IE i made all the image colours and gradients into on compressed image
works very well
 
hrm, throw more away
So far, I've written 10 versions of an Event loop class, and thrown away all 10 of them. This evented programming concept is hard...
 
Form class structure: every form has a validator and a processor. Should I actually BUILD it that way?

interface Form {
function __construct(Validator $validator, Processor $processr);
}
 
10:13 PM
why?
 
I have a form that has minor changes based on the type of user logged in.
There are three user types.
If I use polymorphism, I can eliminate a lot of ifs.
Which makes it nice.
My question on this one is how far to take the polymorphism and OO approach.
I'm usually not creating forms, so I'm a little bit out of my normal comfort zone.
 
Do you have a reason to inject the validator now?
(as opposed to creating them internally)?
My rule: if it doesn't seem obvious how to expose it in the API, I don't
 
Only some of the account validators use a database connection. I need to use DI to test the validator.
If you mean, does the form need the validator? No, but the API gets clumsier when you have to render the errors without it.
 
What is a Form supposed to be responsible for?
 
fair enough
 
10:19 PM
@LeviMorrison You could inject a data structure of information to render instead of the object creating the data.
 
@CharlesSprayberry Correct, but the implementation of it seems quite clumsy. Maybe I just implemented it poorly.
 
@ircmaxell I don't know TBH
I thought the network stack had it's own way of tracking packets
Uhm, actually, it most certainly does.
 
It does, but if the queue is full, it'll fall off the top...
 
But afaik I don't tell how big the buffer is
so how do I know when it's full?
 
just keep reading from it whenever data is available (read as much as possible), and buffer it yourself...
 
10:25 PM
I've been sending a 'packet' containing '{"msg":"hi"}' every 50ms, it drops 5 out of 8 (more or less).
 
read faster...
 
that's a bit hard to achieve when the rest of the app is busy handling the request
 
@ChristianSciberras you need async handling my friend...
 
at this point, the only solution would be threading
yeah :/
 
Nah, you don't need threads
just wait for my EventedPHP library to come out
 
10:27 PM
I honestly can't see a work around without offloading work to a thread (while leaving the main one to read fast).
 
namespace Events;

class EventLoop {
}
@ChristianSciberras what takes so long
 
@ircmaxell For now I'm simulating work with a sleep(100);
scratch that
 
don't do that. Give the loop back control over the application
 
it's usleep(100000) (100ms)
 
either that, or litter each file with declare(ticks=1) and set an alarm...
 
10:30 PM
Sorry, I don't follow. Where do ticks come in?
Wait, this makes it asynchronous?!
 
no, it's a hack
it uses signals to take control over the application once per second...
loop through all connections and buffer the data from them
 
That would be my main loop. Then I'd use this tick/alarm business to make use of the buffered data every second or so, did I understand right?
 
I'd restructure the application thoguh
 
How?
I'm really curious about your event system :) do you have anything I can see?
 
not do everything procedurally. Use a really light event loop to work with your streams and I/O
28 mins ago, by ircmaxell
So far, I've written 10 versions of an Event loop class, and thrown away all 10 of them. This evented programming concept is hard...
so no, no I do not (yet)...
 
10:35 PM
hehe :)
Good luck :)
 
Thanks, I'm going to try...
 
Saw it this morning. Can't say I understand its point.
Though the XP box does stand out from the rest ;) :D
 
11:06 PM
Global state sure is a bugger. My current project has session data mixed with the code EVERYWHERE. It is hard to refactor, especially since there is no User or Session Handler class.
 
Hi, is anyone good at Java here?
I kind of need to help in Java but no one is in the room
Could anyone please help me?
 
hey
@user1079641 i know some java whats up
 
Well could you just come to the Java room since I don't want to clog PHP room with java code
 
yep
 
anyone know how to get a text to alternate thought colours, without using flash
 
11:10 PM
@StephenWolfe You mean live? Not, each character gets more like the next color type of thing?
 
i want to make a number like on this site
 
@StephenWolfe Use JavaScript or a .gif image. The website you provided uses a .gif.
 
I dont want to use flash if possible
 
@StephenWolfe I think that can be done use js
 
What should i search for?
 
11:15 PM
@StephenWolfe well you need to 'loop' through the string
 
ahh i see
 
what exactly is httpd.conf?
 
@JMRboosties webservice configuration file
@JMRboosties apache's
 
is there a specific directory it ought to go in? im looking through my files and cant find an existing one. its an apache server
 
@JMRboosties are you on linux?
 
11:19 PM
yea
 
@JMRboosties just do a:
locate httpd.conf
 
opening the shell...
its not working... fun.
`[jmrboosties@apollo ~]$ locate httpd.conf`
`-bash: locate: command not found`
`[jmrboosties@apollo ~]$ ssh -1 locate httpd.conf`
`ssh: Could not resolve hostname locate: Name or service not known`
 
find / http.conf
?
don't know the exact syntax though
 
what have i done
its going through every folder
i guess thats what i wanted lol
 
:)
 
11:22 PM
Hi guys, I have a piece of javascript running (a pop up window) - I only want to show it once per a users visit. I’m assuming a cookie is the best way to achieve this. Do you think a PHP session or a javascript cookie would be better...?
 
its going so fast lmao
 
@JMRboosties btw what os?
 
id have to look
@PeeHaa it didnt find httpd.conf at all
Linux 3.1.4
 
@JMRboosties k another route
@JMRboosties if you do a phpinfo(); you should see 'Server Root' somewhere
1 sec lemme start ssh myself so I dont have to do it blind :P
 
k i will wait, thank you
 
11:27 PM
@JMRboosties Now that I think of it it might also be called apache.conf I think
@JMRboosties anyhow it is in the following folder on my machine:
/etc/httpd/conf/httpd.conf
centos
 
im running centos as well
Kernel Linux 3.1.4
Distro CentOS release 5.5 (Tikanga)
 
@JMRboosties and you cannot run locate :|
 
locate doesnt do anything
my /etc/httpd/conf only has subfolders, no httpd.conf file
 
quick question
 
@JMRboosties whats in the subfolders?
@JMRboosties btw you can install locate using yum:
yum -y install slocate
might come in handy in the future
 
11:30 PM
yum command not found, do i need to do ssh -1 yum...
 
Is using keywords the best way to automatically categorize a webpage (article)?
And sorry for the intrusion.
 
@Justin np
@JMRboosties sudo yum
 
uh oh, im not in the sudoers folder
 
@JMRboosties :(
 
oh well.
 
11:32 PM
@JMRboosties I don't think 'normal' users are allowed to change apache config by default
 
@PeeHaa well its my server, but maybe thats reserved for system admin
 
@JMRboosties do you have root password?
 
i think
i have 1 password when it comes to all of my hosting stuff
 
Any ideas?
 
@JMRboosties try
su
and enter password
@JMRboosties btw what do you need httpd.conf for? maybe you can use .htaccess
 
11:35 PM
trying to install this module code.google.com/p/mod-auth-token
 
lemme check
 
the system admin installed it, but i need to get into httpd.conf in order to change the settings for it
 
@JMRboosties If there are .conf files in the /conf folder which are used by your site you could also add it there
@JMRboosties but I think you will need to restart the httpd service in order for it to work
 
restart the httpd service?
 
Hi i have a button on my site that says "download", it will open up/download a docx file. is it best to give the person the option of pdf as well?
 
11:40 PM
@PeeHaa is it possible that i dont have an httpd.conf file?
 
@JMRboosties it might have another name
 
it would, lol
 
:P
@JMRboosties I'm sorry I have to take the dog out now. And going to bed after that. Try to ask your sys admin what's it called and ask him whether you are permitted to restart the apache server
 
right, thanks a lot for the help
 
if you just @ me here I will read it tomorrow or someone else will be able to help you
 
11:44 PM
cool, thanks
 
cya
 
he mentions htaccess
we will see but i think thats different
 
@JMRboosties You might be able to set it using .htaccess file if it is allowed
 
now ive gotta find that lol
dont mean to keep you, see you later
 
You can just create a .htaccess in your document root
 
11:46 PM
you mean the root/ folder, or just the folder above www?
or even just the directory im trying to lock up?
someone else can answer i dont want to keep you
 
And add the stuff there you need to add. This way you won't even have to restart the service because .htaccess is read for every request
the root of your website
now I'm really off talk you later
:)
 
11:58 PM
@JMRboosties If the admin says it is installed, then ask him to check why it isn't listed in your build. That is part of his job, not yours.
 

« first day (450 days earlier)      last day (4487 days later) »