« first day (818 days earlier)      last day (4130 days later) » 

user652649
5:00 PM
@DaveRandom 3 classes: User, Page, UserPage... UserPage has ->getUser() ->getPage() and various constructors, for example UserPage::getByUserID() or UserPage::getByPageID()
 
@DaveRandom: No not really, but if someone goes to the javascript file and uses one of their tools to change something like if session user_id = 1{do this} else do that. Even that as little as it is may distrupt a lot of things, you know what i mean?
 
@wes Right, so UserPage is actually the UserCollection I was talking about?
@SaffronHarris But JS is client side. All they will be doing is screwing up their own user experience. You can't worry about that, there's nothing you can (or need to) do about it.
 
user652649
i was thinking that using two constructors, for example i just run "SELECT pages.id, users.id ..." instead of fetching all the data leaving "SELECT * FROM users" to the class User and "SELECT * FROM pages" to the class User and the class Page the task to get the actual data
 
$amd = new RequirePHP\AMD;

$amd->define('foo', function() { return 'bar'; });

$amd->with(array('exports', 'foo', 'define'), function($exports, $foo, $define) {
    $exports->something = $foo;
    $define('somethingElse', function() { return 'baz'; });
});

$amd->with(array('something', 'somethingElse'), 'var_dump');
string(3) "bar"
string(3) "baz"
 
user652649
@ircmaxell sandbox? whats that?
 
user652649
5:04 PM
@ircmaxell i want it
 
:-D
 
@DaveRandom Ha fair enough, that makes sense haha Thanks. What do you think about node.js?
 
user652649
@ircmaxell gimme that
 
it's a long way from ready. Right now, it has no idea how to load dependencies. I'm working on that though...
 
user652649
xD
 
user652649
5:05 PM
@ircmaxell how it is working?
 
In order to do it right though, I added deferred objects and promises. As well as a when() function
    public function load(array $deps) {
        $deferreds = array();

        foreach ($deps as $dep) {
            $localDef = new Deferred;
            $export = $this->getExport($dep);
            if ($export) {
                $localDef->resolve($export);
            } else {
                // Todo: load dep!
                throw new \LogicException('Problem!!!');
            }
            $deferreds[] = $localDef;
        }

        return whenAll($deferreds);
    }
function whenAll(array $args) {
    $toCall = count($args);
    $deferred = new Deferred;
    $results = array();
    foreach ($args as $key => $arg) {
        if (!$arg instanceof Promise) {
            throw new \InvalidArgumentException('When must be promises!');
        }
        $arg->done(function() use ($deferred, &$toCall, $key, &$results) {
            $toCall--;
            $args = func_get_args();
            $results[$key] = isset($args[0]) ? $args[0] : false;
            if ($toCall == 0) {
 
user652649
@ircmaxell it is in pure php?
 
yup
 
user652649
@ircmaxell holy shit... how do you parse php?
 
how do I parse PHP? HUH?
what do you mean?
 
5:08 PM
@wes No. That's multiple round trips to the DB for no good reason. I'm sorry I don't understand what the issue is I think, we seem to be talking at cross-purposes a little :S
 
user652649
@ircmaxell you don't parse actual php code?
 
user652649
@DaveRandom i did get your key point of view... forget about it, i hate those language difficulties ... i seriously need to re-learn english again xD
 
@SaffronHarris I like it but the use case for it is very narrow. It's certainly not a replacement for PHP, and it's not really that useful as a web server (as the primary function of the application) either for 99% of people. It's only really useful for low-level high(ish)-performance server applications.
 
user652649
@ircmaxell what that does? interprets a single php expression?
 
@wes I'm not fully concentrating, trying to refactor something that I was clearly drunk when I wrote it because it makes no sense.
Yet somehow it works.
 
user652649
5:14 PM
@DaveRandom i will make you an example code when i will have some time
 
@wes it's written in PHP
 
user652649
@ircmaxell what is its purpose?
 
it's an asyncronous dependency loader
 
user652649
5:26 PM
@ircmaxell ... what it is that, using words that a newbie like me can understand? xD
 
@DaveRandom: Wouldn't it be better to integrate node.js instead of having a lot of ajax calls? What do you think?
 
If anyone wants to add/change anything to that, either fork or ping me ^
I think it'll keep things centerlized and easy to maintain
 
$amd->define('foo', array('RequirePHP\Test\Class1'), function($dep1) {
    var_dump($dep1);
});
object(RequirePHP\Test\Class1)#13 (0) {
}
 
5:33 PM
Have a good weekend all!
 
@SaffronHarris The use of Node.js and the use of ajax have nothing to do with each other other than they are both based on the Javascript language. What you say there ^^ makes no sense.
It's kind of like saying "If I integrate PHP with Perl will I need to go to the shops less often?". No.
 
@DaveRandom: what i meant was, instead of getting data with php and ajax, isn't it faster to get staight from the server- with nodejs?
 
To do what with it? Ajax runs from a browser, Node is server side. You cannot replace one with the other, they do different things.
 
yes but with node you can lod data gotten from the server onto the browser.
 
here's a sneak peak:
 
5:39 PM
But withouth it, you can use just php(which requires a browser refresh to update) or ajax and php.
 
@SaffronHarris No you can't. Node has nothing to do with browsers. It is server side.
 
user652649
@DaveRandom i have a better example... 1 user may have 1+ pages... imagine you had already fetched some of them (QUERY #1) (for example only most recent ones) and after that i want to get ALL the pages owned by one user (QUERY #2)... since i already have some pages already fetched (by QUERY #1), does it make sense trying to avoid fetching them again in QUERY #2?
 
user652649
i think it is unnecessarily complicated
 
@ircmaxell Random question you probably don't know the answer to but worth a shot: Do you know when the openssl ext started supporting SHA512 algo? The constant was only added in 5.4.8 but (undocumented) you can pass the string 'sha512' to the algo arg for openssl_sign() and it works in 5.4.3 (just checked) - do you have any idea what the BC cutoff is? Can't find a believable ref
 
nope
I don't know that much about openssl ext
 
5:45 PM
No worries, worth a shot :-)
@wes There's really no way you can know ahead of time that you will eventually want all pages?
 
user652649
@DaveRandom no because i want templating to be totally free
 
user652649
do you understand what is my issue now?
 
Well, sort of. I certainly think that filtering out the records you already have is not going to gain you anything, because of all the extra logic required, it's probably going to be just as expensive as including those last few results in the second query.
 
user652649
yeah! that was what i'm thinking...
 
user652649
"do you understand what is my issue now?" -> "did i explained myself well?" i always fail in being pleasant while talking in english.. lol.. sorry for that
 
5:55 PM
Right for me, catch ya in a couple of hours or so
@wes Yeh it's all good :-)
 
user652649
@DaveRandom ok thank you for your opinion... see u later
 
@DaveRandom It's uses javascript, i'm pretty sure you can easily output data on the browser.
 
-3
Q: What are the ADA laws and handler/ patient rights for hippotherapy?

user1970367I am doing a school project and I need to know the ADA laws and handler/ patient rights for hippotherapy, and I have looked everywhere but I just can't find them. Please Help!

Hippo. Therapy.
 
NICE! I got module loading working!!!
$amd->config->paths['Test'] = __DIR__ . '/lib/RequirePHP/Test';
$amd->with(array('Test/Module1'), function($module) {
    var_dump($module);
});
and there's a file in Test/Module1/amd.php:
<?php

$amd->define(function() {
    return 'Hi!';
});
 
6:11 PM
@ircmaxell What are the implications of this, for those of us that haven't followed whatever has lead to this apparently momentous event?
 
it's a different style dependency injection container
with an emphasis on modularity (you can define your own loaders) and asyncronous (you can provide async loaders, hooking into things like React, and it'll load things properly, asyncronously for you)
 
imo class/file loading and DIC are conceptually different, I don't really like that people use AMD to mix them
but maybe that's just an arbitrary distinction based on how it works in PHP
 
@ircmaxell Oh, that explains why I was lost. Cool.
 
@igorw this doesn't do class loading, but class instantiating.
you still need an autoloader or another mechanism to load the classes...
this just takes the loaded class, scans its dependencies and tries to load them...
 
user652649
@ircmaxell is that really needed in php? autoload works as well.......
 
user652649
6:17 PM
ahhh
 
user652649
i understand
 
it's more of a dependency loader, figuring out how to wire them together to give you the requested dependencies...
 
user652649
you are talking about class initialization , namespaces initialization?
 
user652649
otherwise i don't get the actual point of that
 
user652649
because php's autoload already scans dependencies and loads them
 
6:22 PM
in JS a module can return a "class" or it can be an instance of a class. there isn't really an explicit separation between those two concepts. correct?
 
@igorw Correct, in a way
 
correct
 
To be precise, there is no such thing as a class: there's only functions and functions are objects so you can return them just as easily as other objects
 
@wes No it doesn't. It loads the classes. Not objects
 
user652649
but if i load an object (for example unserializing it) that contains references to other classess, they will be loaded by autoload
 
6:26 PM
(The what's what in javascript may seem like crazy talk if you're not used to working with it, though :P)
 
so you can either inject the class an instantiate it in your module => that would be class loading. or you inject an instance => that would be DIC.
in the former case you've coupled construction to the receiving module
in the latter case you have shared state between all instances
 
And in this case, you haven't done either
you're asking for the dependency, and it can be resolved separately, or shared depending on the loader being used
The goal is to get away from the dirty crap that Pimple does...
 
6:44 PM
I think one confusing thing about this is that modules somehow seem coupled to the file system. once I stopped thinking about them as files and rather as service identifiers it makes a lot more sense ;-).
 
Well, and in JS AMD is a class loader
just not in my implementation ;-)
 
Hellas
 
in fact there's been some work done on an async DIC which works quite similarly. mostly just using different terminology.
 
Yeah, I want it to be very familiar
 
7:04 PM
 
evening
 
@ircmaxell the thing is that the "async" in AMD is really just about loading the contents (from file or network) of that module. which is why it is imo closer to class loading than to service construction.
 
fair enough
 
you cannot asynchronously return the value of a module. for example you cannot open a db connection and when the connection is established return it. because there must be a return.
 
Well not for connection
but for HTTP connection you can. Set socket non-block, and then define() it after it's laoded....
 
user895378
7:16 PM
You could do the same for a db connection, but you'd have to implement the db spec yourself.
 
Hey all.
Hows it going?
 
CAM
OOP Refactoring Question
 
that's problematic, because the define gets its dependencies passed in. if db connection depends on those dependencies, you only have access from within the define :)
 
CAM
I want to use a particular function from a non namespaced non class file within my class
 
CAM
7:22 PM
btw @ircmaxell good vid on Depdency Injection
 
@CAM non namespaced non class doesn't sound like this is really a OOP question :)
 
CAM
@PeeHaa Yea Refactoring to OOP the product is pretty much olive garden (Spaghetti errwhere)
 
Yummy :D
 
CAM
uhhh... yea, see my last tweet @camdesigns
http://architects.dzone.com/articles/my-very-own-daily-wtf story of my life. #Lmfao #js #refactoring
we're talking procedural PHP with if chains like 10 indentations deep intermingled in the markup and JS on a page thats ≈ 6000 lines
not fun. forcing me to not use the native PDO driver
 
7:26 PM
@CAM Can't you just refactor the code into /dev/null? :P
 
CAM
HAHAHA
 
double ping because its friday
 
CAM
no ideas for teh external function in the class??
 
@ircmaxell here's an example of what I mean: gist.github.com/e3da1cd551ef4e22f6e6
@CAM what exactly is the question?
 
CAM
ok
I have a function foo(){...} in an external file
 
7:31 PM
Hello everyone!
 
CAM
and I am creating a class bar(){} that will need to use foo()
 
Who know is it possible to run process and make it save it's pid file into custom directory?
 
@CAM thanks!
 
CAM
rather than replicating the function what would be the best course of action?
 
@CAM replicating?
 
CAM
7:33 PM
and there is no namespacing implemneted
 
@igorw I'm handling that by allowing define() calls to return deferred objects...
 
@CAM I know what it is thank you :P
 
CAM
@PeeHaa HAHHHA you were suggesting that as a solution ?
 
I just don't get what / how / why you are replicating some function
 
7:34 PM
@ircmaxell great, would have done it exactly the same way. :) thumbs up
 
:-D
the unit tests for the Deferred class and Promise class are several times the size of the code to implement them
async is hard to test
 
That function is as global as it gets so I don't see what you want to replicate :)
 
CAM
... so I can just call it ??
 
@ircmaxell I'm assuming you've seen github.com/reactphp/promise?
 
no
 
7:37 PM
Well again it has absolutely nothing to do with OOP, but yeah :) @CAM
 
mine's more generic (resolve takes any amount of paramteers, just uses func_get_args()
but yours is cleaner
 
it's mostly the work of @jsor
single return values are a bit annoying indeed, but there is a good reason to have them
it allows for promise-driven task scheduling with generators
i.e. $response = yield $httpClient->request('http://example.com');
 
yeah, fair enough
 
CAM
thx @PeeHaa
 
np
 
7:46 PM
night ...
 
Bye
 
animation: {
  speed: this.options.type == 'error' ? 0: 500;
},
Is this proper way to do in JS?
 
Hello!
 
user652649
8:06 PM
@webarto what do you want "this" means there?
 
current object
animation: {
  speed: (this.options.type == 'error' ? 0: 500)
},
 
wiiii
 
user652649
everything is an object in js! you need to be more precise!
 
Should be like this. Also you can set speed like this.animation.speed = 500.
 
@webarto have you been programming it the jquery language again ?
 
8:09 PM
@tereško I'm fixing "Noty" jQuery plugin, it's totally broken, I've could written it by now, instead of fixing.
 
it think that's the prevailing experience with jquery plugins
 
user652649
@tereško sadly i have to agree
 
people who are capable of fixing any of those turds are usually better of by doing it all on their own
 
@tereško github.com/needim/noty/issues/54 can you believe it? Setting inline CSS on the fly, without classes.
 
user652649
8:12 PM
 
user652649
someone knows what race is that^?
 
F1 Flying Cup
 
user652649
LOL
 
Maybe F2, doesn't look like F1 bolids :)
 
user652649
i don't see any grosjean... not f1 then!
 
user895378
8:13 PM
He was trying to take the MarioKart shortcut. Must've used a mushroom.
 
@rdlowrey :D
 
user652649
/me stuck to mariokart64
 
I've been staring at the gif for over a minute now
@wes good job
 
user652649
/me still playing doom1/2
 
something is starting to freak me out. whenever i write new code it seem there is a chance it will eventually be obsolete so my question is: is it inevitable?
 
8:22 PM
@Happyninja Yes.
@Happyninja Another inevitable thing is that, a few years from now, you will look back on that code and marvel at how much of an idiot you were when you wrote it. In fact, if you don't experience that feeling, something is very wrong.
This effect will continue throughout your career.
 
@Charles i experience that already. sometime i feel guilty about feeling guilty for the code i wrote
 
@Happyninja That's also normal, but only if the code is someone else's problem now.
Always try and code as if the next person that will maintain it is a murderous psychopath that knows where you live.
 
@Charles how long should my code live, i mean is there a pattern in php release in a way to dictate product cycle?
 
@Happyninja There's no way to predict or govern that. If the people that wrote the code I now have to maintain knew that it'd still be in service nine years later, I'm sure they'd have done things differently...
 
@Charles it is implicit statement and cannot turn as argument against someone asking a programmer to code something?
 
8:29 PM
Hi, may I interrupt with a question here??
 
@Happyninja Sorry, rephrase?
@mamdouhalramadan SILENCE, PEON. By which I mean go ahead.
 
having a question which i answered and i know 100% that i'm right
but he keeps saying that it's not working for him
 
You are not obligated to continue to help him.
 
so he got me confused whether i'm right or not
anyone can care to take a look
 
@Charles it is my responsibility as the programmer to tell my client the code will not stand forever?
 
8:32 PM
in Dart Lang, 19 secs ago, by rdlowrey
I'm going to have to put a post-it note on my monitor that says, "Don't use goto" because it's so nice.
 
user895378
/shame
 
I know. but I need to know what's wrong, I have done this thousands of times
and I'm sure it's good. but just got curios about it.
that's why I bothered you guys here :)
 
@Happyninja No, but it is your responsibility to do what you can to make sure that your code will continue to work. This doesn't mean you have to make it perfect, but it does mean that you have to know that you know what you're doing. The fact that you're thinking this is a good thing. :)
@mamdouhalramadan To be honest, from the way this guy is replying, I don't think that he has any idea what he's doing.
 
yes I know. but have you seen anything wrong with my answer?
 
@mamdouhalramadan I don't know enough about how CI works to make a judgement call one way or another.
I don't see anything immediately wrong, but I also don't know if it's "rude" to just return data like that.
Etc, etc.
 
8:37 PM
what do you mean? @Charles
 
@mamdouhalramadan I mean, know what the current best practices are. Avoid deprecated functions, document your code well, don't be sloppy. Etc.
Have a written specification, annotate the specification with implementation notes as you find it doesn't match reality.
Go out of your way to make sure that when someone down the line has to modify, fix, port, alter or otherwise maintain the thing you're doing, they don't hate you forever.
6
 
good morneeveafternoon
 
user895378
@Lusitanian hola
 
I resent the lack of clarity, specification and design in the code I have to maintain. It drives me up the wall. It was so bad that we ended up kicking off a tremendous refactor of the entire codebase...
... and then that got mired in politics and managerial idiocy, and I got fed up and accepted a promotion just to end the stupid.
 
Ok. sure, just an honest mistake here. - @Charles
 
8:42 PM
@Charles I prefer: "pretend the person who will be maintaining your code is a maniac serial killer who knows your address"
 
@mamdouhalramadan Another thing you can do... pay attention to the smart people and see what they're doing. Don't copy them, just watch them carefully. It's why I hang out here...
 
^ This is my strategy :)
 
i'm trying to figure out how to manage multiple concurrent session in php
 
@mamdouhalramadan I totally just realized that you aren't the same person as @Happyninja, so those @-s were misdirected!
Sorry about that, must have confused the crap out of you!
I wasn't ranting about your answer or anything.
 
hahahah you really really did :)
 
8:47 PM
Your code is fine :)
 
@Lusitanian Of course with you that's actually true
Evening all
 
@DaveRandom (:
 
@Charles - I forgot to add the dataType to the ajax request. :)
 
fuck ie8. and 7 and 6. actually, just fuck ie.
 
@Lusitanian ie7
@Lusitanian ie9.. what about it? ie10?
 
8:58 PM
both of them too
 
$messages = [
['type' => 'warning', 'message' => ''],
['type' => 'error', 'message' => ''],
['type' => 'alert', 'message' => ''],
['type' => 'error', 'message' => '']
]
How to show 'error' types first?
 
@webarto Give them another typecode key that you can array_multisort() by
Use constants so you can slide extra levels in the middle later without relying on the actual levelcode values.
 
Could I make another array...

$typeCodes = [error => 1, warning => 2, ...]
@DaveRandom Oh, neat :)
 
@webarto Well yeh, if you want I guess, is the data coming from externally or sth?
 
@webarto Does the order matter afterwards?
(besides errors first)
 
9:06 PM
@DaveRandom Nope, they are message from controllers, $this->messages->add('You laugh, you lose'); etc
@PeeHaa No, doesn't matter at all, errors are "fixed", others disappear after 5s, so it's not nice (visually) when they are all mixed.
 
@webarto If the order doesn't matter you can simply do a usort
hackish, but it will get the job done
 
I vote for numeric types and array_multisort(), will be more efficient because of function call overhead with usort() (he said, micro-optimising)
 
usort($array, function($message){return $message['type'] === 'error';}); @PeeHaa :) ?
@DaveRandom :D I'm not proficient with multi sorts, time to learn :P
 
@webarto Example #3 Sorting database results in the manual
 
@DaveRandom You can actually link to it you know :P
 
9:11 PM
Actually the multi array construction might make usort() cleaner
@webarto To a specific example?
 
classes? Hurt performance? Tell that to Python...
 
(without having to inspect the DOM and find the ID?)
 
But it's not clickable, why is that? @LeviMorrison
 
I blame @GoogleGuy
 
9:12 PM
:D
 
@DaveRandom Me too :)
I'm not familiar with the JS that creates the ID's but I know GoogleGuy is.
@Lusitanian Strong language filter please!
 
It's not a broken feature, it's a "never been there" feature. It's never existed afaik
 
You could "fix" that in prototype for sure.
 
Yeh @Lusitanian, mentioning I******t E******r, I am offended
 
title: Meanwhile in Russia
 
9:20 PM
LOLOL
 
user652649
BAM
 
Anonymous
How is up for a newbie question?
 
9:37 PM
@TheCOMPLETEPHPNewbie what is your question?
 
Quadruple remote desktop, a new record I think
 
CAM
well played @tereško
 
@TheCOMPLETEPHPNewbie shoot
 
Anonymous
How do I bypass the 'Missing one argument' error when calling out a function, that passes parameters? I know it is impossible to avoid the error if function lets say, foo(); is empty, but what if I am passing three arguments, but when to use only two inside the foo(); @DaveRandom @Happyninja
 
Anonymous
Suppose this for a moment
 
9:43 PM
function foo($arg1, $arg2, $arg3 = NULL) {
}
 
Anonymous
function foo($one,$two,$three){

$one = 'one';

}
 
^^ that can be called with either two or three arguments, the last can be omitted
However, you can't omit the $arg1 or $arg2 because you cannot do named parameters in PHP
 
Anonymous
function foo($one,$two,$three){

$one = 'one';
$two = 'two';
$three = 'three';
}
 
Anonymous
now, how to echo only foo('one','two');
 
Anonymous
@DaveRandom if I as shown in your example then param $arg3 will be ignored?
 
9:46 PM
function foo($one, $two, $three = NULL){
  echo "one: ", $one, " two: ", $two;
  if (isset($three)) {
    echo " three: ", $three;
  }
}
@TheCOMPLETEPHPNewbie codepad.org/MiaAcVuW
@TheCOMPLETEPHPNewbie php.net/manual/en/…
 
Anonymous
@DaveRandom Wow, super. I have a db query I will try the code thanks I thought it was impossible an hour ago.
 
@TheCOMPLETEPHPNewbie The manual is a wonderful thing ;-)
 
Anonymous
Unfortunately, it seems to be endless too
 
CAM
Just attended the phpmaster series Webinar (AWESOME!) and during the "your code sucks..." presentation it was suggested that in practicing object calenstethics "indent only once" , that being said how can I achieve this with this bit of code :
            $within = 0;
            $exceed = 0;
            $near   = 0;
            foreach($data as $key => $value)
            {
                $r = businessHours(strtotime($value->ordereddate))/3600;
                $diff = $r - $value->standard_sla;
 

« first day (818 days earlier)      last day (4130 days later) »