« first day (1487 days earlier)      last day (3465 days later) » 

12:00 AM
JavaScript has many flaws. But it doesn't suck as much as PHP.
(pls star kthx)
 
@AndreaFaulds (pls move to trash kthx)
 
@bwoebi (pls kthx)
 
anyway… good night It's late now ;-)
 
Goodnight!
@DaveRandom Am I bad for wishing PHP didn't throw a notice for undefined offsets?
 
What, everywhere?
 
12:04 AM
The fact JS doesn't error there and just gives you undefined is so useful
Then again, we have ?? now, I guess.
 
@AndreaFaulds Yeh but it also doesn't have classes, so it makes more sense there
 
@DaveRandom Ehhh... Maybe.
@DaveRandom It'd be nice to be able to mark classes as non-extensible
Like, prevent class Foo {} $x = new Foo; $x->bar = 3;
 
Yeh, at the very least final should prevent that
Expando properties in general are evil, though
 
@AndreaFaulds __get/set?
 
@FlorianMargaine You can do it that way already, yes.
@DaveRandom Maybe we should prohibit them by default, but allow them for classes that explicitly allow them?
 
12:09 AM
talk about bc break..
 
Would it really be that bad?
You could make StdClass allow it?
@TheodoreBrown Safe casts now return NULL again, not FALSE, on failure. Also, I think I'm dropping the optional default thing. (Sorry to torment you so...)
 
@FlorianMargaine No, I think undefined is bad. PHP just sucks by not distinguishing null and not set
 
@AndreaFaulds fuzzy class Foo {}
:-P
 
Hmm, thing is, ?? only solves half the problem, really.
Because I'll still need to write if (isset($_GET['foobar'])) { /* ... */ do_something($_GET['foobar']); /* ... */ }... but it's still better than before.
@FlorianMargaine Done :)
 
12:27 AM
Hmm. I'm getting permission errors when trying to serve files out of my web root.
I've checked that all parent directories have execute access by anyone.
The web root and all its children are owned by the web server and have read, write and execute status.
Any ideas?
 
@LeviMorrison Maybe use strace to find out what read is failing? Script for attaching it to php-fpm is here - stackoverflow.com/a/21437062/778719
 
Ah, it looks like it may be a Apache 2.4 change.
 
@AndreaFaulds <sigh> I'm glad I didn't put too much work into the exception-or-default version. Do you remember why we changed it to false instead of null in the first place? @NikiC
 
This chat isn't IRC, is it?
 
No, it google indexable for a start.....which sometimes catches people out when they post private info.
 
12:35 AM
@TheodoreBrown I can't remember. I think it might have been @NikiC/me objecting because nullable typehints... but I'm not sure now.
 
@AndreaFaulds Yes, it was about nullable typehints
 
I thought so.
 
@Danack Apache 2.4 changed access control, so I needed "Require all granted"
 
12:52 AM
If someone has a nullable typehint, passing a failed cast value would mask errors when they occur (unless the typehint is nullable specifically as an error state). Returning false would also mask errors when used with many internal functions.
Is the main argument against exceptions that it would require extra typing to catch them?
 
They're also slow, and don't fullfill the other use case well (validation)
So NULL it is.
 
It's that using exceptions for program flow controls sucks, and that some input not being valid isn't exceptional to begin with.
 
@Danack I disagree, but I don't want to bikeshed anymore so I'll defer to the internals team :)
 
I'd rather write if (to_int($someValue) !== NULL) {} than catch an exception.
 
if (false === $userIdInt = to_int($userId)) {
throw new Exception("User ID must be an integer");
}
vs.
try { $userIdInt = to_int($userId); }
catch (Exception $e) {
throw new Exception("User ID must be an integer");
}
 
1:02 AM
The latter is slower and bad practise (usually).
 
@TheodoreBrown I posted this earlier :
2 hours ago, by Danack
@AndreaFaulds It turned into a novel... https://gist.github.com/Danack/049ba570e899a1f90468
More related to the problem with lots of exception classes, but it still repeats what I've probably said to you before - not having to handle exceptions tends to produce cleaner code than having to handle exceptions.
 
@AndreaFaulds The tests in my exceptions branch are not perceptibly slower. Exceptions are only thrown if an error occurs, so you would have to have a LOT of errors for it to get slow.
In the case where a developer wants to check whether user input is valid and throw a custom error if not, I agree that returning null is cleaner. In other cases (particularly when dealing with internal casts) it is much nicer to just be able to call the cast function without checking for errors each time (if an error occurs, it will be thrown and caught at the top level).
 
1:21 AM
Eh, the intention of the function is it'd be caught by strict hints, if added.
 
@AndreaFaulds That's true. The other advantage of exceptions is that they can let you know why the cast failed and provide a stack trace. Maybe not such a big deal since outputting the value would probably make it obvious why it failed in most cases.
To avoid repeating myself anymore, though, I'll reference the case I made for exceptions in an email to the internals list: markmail.org/message/uzxu46sammhzqsq4
 
 
1 hour later…
2:39 AM
@AndreaFaulds I made a branch which returns null instead of false here: github.com/theodorejb/PolyCast/tree/return-null-on-failure. I'll probably wait awhile before merging it into master to avoid churn if you change your mind :)
 
morning
 
2:54 AM
Morning
If anyone of you have experience with manual checkout in OpenCart, feel free to check this question out :) stackoverflow.com/questions/26856606/…
 
 
3 hours later…
5:25 AM
morning
 
6:08 AM
morning
 
7:01 AM
moin
 
7:11 AM
Morning
 
I am looking for a possible way to create an expiring value that will only work for 10 minutes from when set, I am having trouble thinking of what to look up, so if someone could guide me it would be appreciated. The following works for 10 minutes but not from when set, so if I get it at 10:49 it will change at 10:50 only leaving me with one minute. Is there something that would work until 10:59?
$life = 600;
$life= ceil(time() / ( $life));
 
@Brandon math?
 
@crypticツ What do you mean? Yeah.. I suppose it is math...
 
@Brandon why are you dividing?
 
The objective is to make a number that will only work for 10 minutes from when it was set
 
7:19 AM
get current timestamp add 600 seconds to it
 
I am doing it to create a verifiable number, it gets hashed
 
then at whatever interval compare current timestamp with above calculated timestamp. When current timestamp is more than or equal to it then it has expired.
 
@crypticツ It gets hashed, I need to be able to check it at say minute 5, I would have to generate a number for each of those times.
 
why are you hashing the timestamp?
 
It is using more then just the timestamp, there is a lot more in it. It basically is creating a temporary authentication code
 
7:23 AM
you should be storing the timestamp with a hash somewhere in database, and giving the hash out, when someone uses that hash you look it up in database and see if the corresponding timestamp is 10+ minutes old.
 
function generate_tfa_token(){
	global $current_user;
	$nonce_life = 600;
	$nonce_life = ceil(time() / ( $nonce_life / 2 ));
	$action = "tfa-pre-cookie-set";
	$uid = get_current_user_id();
	$bytes = openssl_random_pseudo_bytes(50, $cstrong);
    	$hex = bin2hex($bytes);
    	$hex_check = get_user_meta( $uid, "temporary_login_token_hex", true );
    	if(!empty($hex_check)){
    	  if(delete_user_meta( $uid, "temporary_login_token_hex" )){
    	     add_user_meta( $uid, "temporary_login_token_hex", $hex, false );
The idea here is to not store the timestamp, if that makes sense
 
global $current_user;
no, no, no...
 
posted on November 11, 2014 by kbironneau

/* by stef */

 
@Patrick It's WordPress
I know...
 
7:32 AM
so what, just inject it into your function
 
morning guys! :)
 
good mornings
 
@Patrick I am just looking for some help with my current question, the global is standard, despite it not being the best practice.
 
@Brandon you can always do date('i', $expires); to get minute in 10 minutes
 
7:34 AM
@Patrick dont know why but i am unable to open that link :(
 
@SergeyTelshevsky Yes but that would mean it would have to be submitted exactly at the 10 minute mark
 
it will have from 10minutes to 10:59 long lifetime
@Brandon let me guess you use CRON to check?
well you can't hash it the other way
or some other way of polling every 1-10 minutes?
 
@Brandon store the hashes in your db with a timestamp in a separate field
 
I think I am just trying to think of a way to solve a problem that if plausible could still be circumvented.
Regardless of the barriers
 
@Brandon why?
 
7:43 AM
xamp and wamp both at same time stackoverflow.com/questions/26859912/… lolwt
 
why are you riding on 2 horse at same time ? — obi NullPoiиteя kenobi 4 mins ago
lol ^^
 
Anyone know how to add/submit the order after manually defining the order through checkout/manual in OpenCart? Stuck for the past couple hours working on this same issue, haha.
 
7:59 AM
@Brandon you are digging a hole for yourself only deeper
 
Good day to all :)
@rdlowrey you there ?
 
8:51 AM
hi
 
Hi
 
Good mourning
 
do anybody know from where I can download php 5.2.6 for windows 64 bit machine?
 
yes i looked into this site
but i didnt find above requirement
like windows 64 bit php
museum.php.net/php5/php-5.2.6-win32-installer.msi
is for windows 32 bit
 
8:55 AM
Morning
 
and not 64 bit
 
Yes you're right
 
so do anybody know from where I can download it?
 
9:09 AM
Morning
 
@John I didn't found x64 for this version but if you really want this version you can build yourself the php source (you have several tutorial on it)
 
Anyone know how to manually submit an order programmatically, given the condition that the user is logged in and the cart has items, in OpenCart?
I've tried using checkout/manual like I did here:
http://stackoverflow.com/questions/26856606/implementing-manual-checkout-api-in-opencart
But I need a little help on how to actually submit that order
 
@PeeHaa What the shit is this ohhh sarcasm :D
 
@Jimbo morning
@PeeHaa good morning
 
Hello guys. Can you help me with something in javascript?

I cant trigger an event from inside of the function.
Here is the snippet: http://snippi.com/s/enaeut8
 
9:22 AM
@BikerJohn You could try the JS chatroom
 
you mean THE JABASCRIPT ? its alien to me
 
They're incredibly helpful in there... lovely people
 
@Jimbo most of regulars left that room
 
@obiNullPoiиteяkenobi I have seen a running pattern of those sorts of people, both irl and online
If you have workplace stuffs
 
9:30 AM
lol i dont even have account on that
 
Whats ro-pls?
 
Re-open please
@obiNullPoiиteяkenobi I think it auto logs you in with 150 free rep or something
as you have an acc on SO
 
Morning [=
 
Morning =]
 
9:33 AM
Yeah, gives you free 100 rep
 
Ah 100, that's alright, thought it was 150
 
its 100 but i can not contribute there
 
Makes you feel really good when logging into new SOs
VIP pass
 
not much anymore
 
Hi all,
Which is good for table name
1. car_owner
2. carOwner
 
9:35 AM
car_owner
 
@BasicBridge depends on your habit
but car_owner is more readable imho
 
posted on November 11, 2014 by kbironneau

/* by ManiacPC */

 
@obiNullPoiиteяkenobi Yes, it depends. I was looking at psr standards. But not able to find anything about table name
 
@BasicBridge than use camelCase
 
/me prefers PascalCase nouns in plural for table names and camelCase for fields and UPPERCASE for SQL keywords
 
9:40 AM
@BasicBridge ^^^ this
 
I'm going with car_owner and limiting camelCase for variable names
 
Personally for table names I use all lower case, with underscores
camelCase for vars, classes have CamelCase with the first letter capitalised
 
lowercase all the things!
 
or uppercase all the things!
 
SELECT
    Users.userId AS id,
    Users.name AS name,
    Groups.name AS group
FROM Users
    LEFT JOIN UserGroups USING(userId)
    LEFT JOIN Groups USING(groupId)
WHERE Groups.enabled = 1;
 
9:45 AM
I caps those too
 
here ya go, @BasicBridge
 
@deltonio2 thanks for your kind reply
 
Might get a new url for my blog once it's up: tabsvsspaces.com
 
@John You're welcome
 
hi guys can u suggest any good book for good oops concept with proper example(s)...
 
9:53 AM
@John What's your current level?
 
So what do you guys prefer? Joins or subqueries?
 
Looks like he's level 1
 
I never used subqueries until they introduced it to me at school. I find joins easier
 
morningingnisnin
 
@PeeHaa yes jimbo is right
 
9:56 AM
Morning Dave
 
@DaveRandom Morning
@John @tereško probably has some introduction books
 
Sep 29 '12 at 13:58, by Gordon
@hekko if you want to become an expert programmer, google SOLID, buy GOF, buy POEAA, buy Clean Code, learn Refactoring, lookup GRASP, DDD, CQRS, DCI … but dont ask for PHP books. That's the most reasonable suggestion I can give you when you ask for Expert PHP books really.
 
122
A: MVC for advanced PHP developers

tereško Links, that contain PHP-only materials, are marked with php for easier identification. You cannot even begin to delve into MVC before you have comprehensive understanding of OOP. That include OOP practices (dependency injection, unit testing, refactoring) principles (SOLID, SoC, CQS, LoD) a...

 
@PeeHaa actually, when it comes to introductory level books - the situation is really shitty
 
On that note, is there something good on GRASP beyond the wiki article?
 
10:00 AM
I probably am .. but I have no idea what it stands for
 
I would suggest to write in C.
 
C--
 
@Patrick Niki C's Post?
 
10:02 AM
@Fabien He just lists them and links to the wiki article...
 
@HamZa youtube.com/watch?v=i2fhNVQPb5I :D ( i am a see programmer ) :D
 
@obiNullPoiиteяkenobi haha
 
@obiNullPoiиteяkenobi Don't see sharp though
 
So once my teacher told me that there was a student who wrote a webserver in assembly...
 
how to articulate server requirement which colloquially would be referred to as "must have sendmail" ?
 
10:10 AM
@HamZa I just read about it. 95% of the CPU was in windows services... he was using it to make calls to the Win32 API for the gui etc. It wouldn't handle concurrent connections. Effectively doing everything via win32 negated the effect of doing anything in asm at all
 
@HamZa There's a big difference between "a web server" and "a fully HTTP/1.1 compliant web server" (even HTTP/1.0)
 
@Jimbo Oh, I was wondering!
@DaveRandom hehe, true :)
 
@tereško If sendmail is a requirement, there's not a lot more to say
 
Anyone used configuration based factories? Dependant on a string in a YAML file, a factory builds a certain object of a given interface the factory returns
 
10:13 AM
"A correctly configured sendmail installation is required for proper operation of the application"
 
@DaveRandom sendmail is often installed on the OS by default
 
YAML moved to bin
5
 
LOL
Bitch, apart from the yaml it was a genuine question :P
 
1 message moved from bin
 
@tereško perl is too, would you use it?
 
10:16 AM
:-P
 
and it's not installed by default in my vms :(
I had to manually type apt-get install sendmail
do you know how much it broke my heart?
 
. <-- that much?
 
around that, yeah
 
lol
 
For a date orientated method that accepts a date would you typehint it to DateTime?
 
10:20 AM
What's the difference between a factory and a builder?
 
@Jimbo so... something something service locator factory?
 
@Fabien DateTimeInterface
Both DateTime and DateTimeImmutable implement it
 
Ah furry cheers
 
TIL
 
Immutable... Depends on your php version though
Dunno if it was released
 
10:23 AM
5.6 :)
 
Yeah but my PR was merged a couple weeks ago..
 
I'm creating a VO. When/Why do you use the methods getFoo() setFoo()? As opposed to $class->foo = 'bar';
 
Value Object
 
yeah I realized it
 
10:25 AM
I could be wrong on that name though.
 
@Fabien Does it contain logic?
 
if you do a VO, it means the object is immutable, no?
 
@PeeHaa Not really no. It's just a VO for an alert I wish to log to DB
 
if you want an immutable object, only have getFoo(), and set the property in the constructor
 
@Fabien Can you get away with just using the constructor and dropping the setters?
lol @FlorianMargaine was too fast
 
That makes sense thanks.
 
and it seems DateTimeImmutable doesn't implement DateTimeInterface yet
no wait, it does
my bad, all I fxed was the DateTimeZone::getOffset() method to accept a DateTimeInterface instead of a DateTime
 
So when would you use getFoo() setFoo() vs $class->foo = 'bar'; ?
 
@Fabien never... but that's because properties don't exist :/
 
My personal view is that DateTime should be immutable and there should be a MutableDateTime which extends from it
 
10:31 AM
@DaveRandom I think it's the view of everyone... but BC
 
Not everyone, Niki doesn't like that iirc
 
@DaveRandom nothing runkit cannot fix ;)
 
lol
 
@Fabien Can't really go wrong with accessors
 
@bwoebi not sure what last point refers to, example?
 
10:33 AM
accessors?
 
@Fabien When you need to add logic
 
^ that
When you are validating or calculating the value
 
Okay. Another noob question then. When to declare class properties?
 
@Fabien only have getFoo() by default. If needed, add setFoo().
 
e.g. checking the type, casting to a specific type or something like storing the underlying value in microseconds but exposing an API that deals in seconds
@Fabien When you don't need to do any of those things ^
however
Because PHP doesn't have sane accessors, it then becomes quite difficult to add logic in the future if you start with a public property
 
10:36 AM
@Fabien Stuff like this would make a nice blogpost for the room 11 blog :)
 
@Fabien getters/setters. If you use public properties and say you have to go back to do validate something or do something else on set/get, then you have to change your interface. So I would recommend never using public properties
 
@Patrick Nope, no service locator? It returns a specified interface, but the thing that decides what concrete implementation of this interface is a config string. Effectively, you can create a new object of said interface, change the config string, and the factory will return that instead everywhere it's required in the application
 
Which is why many people will tell you to always use explicit accessors
 
@PeeHaa Aye :-/. Aren't you building it to put on lamephp.com ? :P
 
only accessors by default though...
 
10:37 AM
@Jimbo But if you have one class that can return all your other classes by giving it a string (or a subset), then you have the same drawbacks. You are hiding dependencies. Or I don't understand what you mean :)
 
@Fabien Have been busy with opcachegui. I am now really almost at v1.0.0 confetti gif \o/
 
Believe it when I see it ;)
 
:P
 
@Patrick Well, factories/builders can pull whatever they need from anywhere to build what they want. So pulling the class string for a specified interface...
 
I personally subscribe to UAP, but I do remember someone who I generally regard as worth listening to on such matters (@Gordon?) saying they did not, and giving a fairly good reason why not, which I can't remember
 
10:39 AM
@Jimbo I think I misunderstood you. I thought you were talking about $factory->create('MyClass').
 
@DaveRandom hmm?
 
oh it was @ircmaxell, sorry
Aug 26 at 15:02, by ircmaxell
@DaveRandom My view is I don't agree with the principle
(read the next 4 messages after that)
 
@DaveRandom Doesn't that encourage doing the logic outside the class where it belongs to?
 
@DaveRandom it sounds highly related to the principle of least astonishment...
 
> All services offered by a module should be available through a uniform notation, which does not betray whether they are implemented through storage or through computation. -- Bertrand Meyer
I might not get what @ircmaxell is saying, but imo UAP doesnt differentiate between state or abstraction
@DaveRandom ^
 
10:44 AM
Well I guess the point is that once you have declared a public property as part of an API, you can't turn that into a computed value at some point in the future without a bunch of __get()/__set() nastiness. Because of the limitations of the language (lack of sane accessors, inability to specify properties in an interface, inability to type properties) in PHP I don't use public properties really ever.
 
^
which is why I badly want accessors in php
but I'm not very smart, so I can't do an RFC or something like that...
 
@DaveRandom yes, but it's not only that it's harder to change to a computed value. It's also that when you provide direct access AND getter methods, you no longer have uniform access because now there is two notations.
 
Well, yes, but who would do that?
 
having $obj->getFoo() and having $obj->bar is not uniform. Using methods for everything is uniform.
@DaveRandom DOMDocument
 
@Gordon true, that's a particularly bad example of violations as well as it also has read-only properties, something which doesn't really exist in PHP
 
10:51 AM
@Patrick No, I agree on that - even your ide will be like "wtf am I building here" unless you annotate it
 
@AndreaFaulds so ... autoboxing is a bit slow ... cool but slow ...
not slow ...
 

« first day (1487 days earlier)      last day (3465 days later) »