« first day (375 days earlier)      last day (4797 days later) » 
02:00 - 15:0015:00 - 00:00

15:15
I don't mean to insult or demean PHP, but, I just received a newsletter from Zend, and ironically, all the links in the email lead to .aspx pages :/
lol
rotfl
hi folks; how are you today?
I'm having a small problem right now with PHP
@ircmaxell What's that prepocessor?
if I use mysql(host, username, password), it works
15:21
I'm really interested in it... :)
@ChristianSciberras Something I was experimenting around with
but if I use the object version (object->connect(host, username, pass)), it doesn't work
it's a really bad idea to use for anything but research
does anyone know why?
conditional compilation?!?! you rock man :D
15:22
@user705339 $c = new MySQLi($host, $user, $pass), don't use ->connect, connect through the constructor
oh ok;
is there a reason why that doesn't work, or is it just a bug?
@ircmaxell /preprocessor/instructions/includes.php <- what's that for?
thanks Ircmaxell; using the constructor works like a charm
@ChristianSciberras I need to wrap all include or require calls in a special declaration to not include the php file, but to pre-process it...
Wait, how are you doing that? How are you modifying the engine at runtime?
Or are you just using it to be able to go into and preprocess includes?
15:31
:-D
It changes include 'foo.php' to PreProcessor::include('foo.php');
hmm, online editor is still broken
Oh, and it supports $baz = function($foo){ return $something; }($bar);
@ircmaxell how did you manage that?
@NikiC, @salathe or @ircmaxell could anyone of you please improve example 1 for docs.php.net/manual/en/function.usort.php - the example really isnt well suited because 1. like the note says, you would use sort for that and 2. the implementation is overly complicated and could simply be return $a - $b. Maybe we could use a multidimensional array example instead.
15:38
@ircmaxell -_-
I think it should stay as-is @Gordon
$a - $b is more efficient, but also far less obvious
and while you would use sort for it, it's a demonstration on how you would use usort to emulate sort (how to do something that you know works)
@ircmaxell i have the impression people think they have to return any of -1,0,1. I've seen that multiple times now in answers on SO.
@ChristianSciberras Read the code
@Gordon what, that they can't return -2?
@ircmaxell yes
eih, that's not a problem with that example though, it's a problem with the page as a whole
I think that example is good personally
15:41
the description for cmp_function states that it can be any numeric value but somehow this seems to get lost on people, especially since the other examples all return -1,0,1 either.
true. If you feel that adiment, post something for discussion on the docs list...
@Gordon Yes, this is often the case (people think it must return -1, 0 or 1)... perhaps another example or two would be useful.
@ircmaxell I also had some tries at preprocessing PHP with github.com/nikic/prephp ;) It had more focus on transforming 5.3 code to 5.2. At some point I gave that up though, as messing with the plain tokens was by far too messy ;)
@NikiC Yeah, I was just messing around
and trying to see what I could do
@salathe not sure if we need additional examples. the other examples are good as they are I guess. Its just the first one that could be better.
15:50
@ircmaxell No, it's just that I expected some kind of low-level PHP core hackery
no, this is entirely written in PHP
I could have done some core hackery with an extension, but I wanted to see what level of meta-programming I could do in PHP itself
@Gordon Optimizing PHP scripts by preprocessing is an interesting idea. One would need more kinds of optimizations than inlining though, to make that worth the effort.
@NikiC I know a few :-D
/me is disappointed with @ircmaxell.
15:53
@ircmaxell /me wants to see core hackery :)
lol
@ChristianSciberras I think doing it in PHP land is far more impressive, to me at least...
But yeah, it's some very interesting code. Actually, I wrote a preprocessor myself for conditionals, but I kind of got fed up doing it :)
@ChristianSciberras If you want to see core hackary read PHP source. It is the core and it's a big hack ;)
I didn't do it to be useful. I did it to see if I could, and see how far I could take it
15:55
@NikiC Would be great, I thought why not make something like what Google Compiler is for Google Closure
@ircmaxell What level of expression execution do you have?
@ChristianSciberras what do you mean?
eg; can it/I do:

#if not function_exists('abc')
function abc(){
}
#endif
@ircmaxell which do you know apart from inlining?
@ChristianSciberras yes
15:56
@ircmaxell I think you should make this real!
PHP to PHP compiler
@tereško Uhm... I asked whether he actually executed such conditions
@ChristianSciberras Yes
@NikiC Architecture specific conditional execution (so not performing the if on execution)
@ircmaxell At that stage, I got hindered by some discrepancies, which is why I got fed up with it... Problem is I forgot what it was all about :(
15:59
@ircmaxell á la optimizing away if (extension_loaded('apc' ? that would require building on the target machine though, i don't know how applicable this is
@salathe how about
<?php
function cmp($a, $b)
{
    return $b['score'] - $a['score'];
}

$ranking = array(
    array('score' => 8, 'name' => 'John'),
    array('score' => 4, 'name' => 'Jane'),
    array('score' => 9, 'name' => 'Jack'),
    array('score' => 2, 'name' => 'Judy'),
    array('score' => 5, 'name' => 'Jeff')
);

usort($ranking, "cmp");

foreach ($ranking as $rank) {
    echo "$rank[score]: $rank[name]\n";
}
?>
@NikiC or that could be production code
@ChristianSciberras basically, everything after the #if is evaled github.com/ircmaxell/PreProcessor/blob/master/lib/preprocessor/…
I'm off, see you guys later.
@ircmaxell Know any good resources you can point me to regarding lexers and parsers and such? I'm working on a generic DSL uh...let's call it engine.
16:00
@ircmaxell Cool :)
@NikiC That's the beauty of it. The way mine works, is it caches the compilation (similar to how python does it with their pyc files)
@Filipe Good luck
Hah
Subtle
Maybe it's a better idea to focus on a python-style syntax
Instead of trying to do it all at once
yeah, it's not trivial, and I'm no expert in it
@salathe as an additional example when the first one should stay as is and not be replaced with return $a-$b
I just used the tokenized PHP. I never actually lexed it...
parsing grammars is definitely one of my weaknesses
16:03
Haapy Diwali to all my PHP friends
I've played around with it extensively, but always at a very novice level. If any of you have played around with the game Gmod, it has something called Expression 2 which is a very basic C-style language (to get an idea - no userland function support, every execution is a "tick", there's a tick limit, etc)
To actually make it useful I spent a lot of time writing all sorts of parsers and compilers with it
@ShaktiSingh And the same to you
@ircmaxell: Thanks a lot. I did not think that someone out of india will wish me. Thanks, Really Thanks.
@ShaktiSingh I work with a lot of people from (both in and from) India. and they have been talking about that all week
so I know what it is :-D
posted on October 26, 2011 by Pádraic Brady

With some precious free time today, I sat down to read Lukas Smith’s Interfacing The PHP World. It was good timing since last night I heard someone complain, again, about tight coupling in Zend Framework so I was in a good frame of mind to digest the blog post. Before we start, tight coupling exists in a scenario where any one class relies upon another concrete class type (usually

16:23
@ircmaxell: Thanks man, you really made my diwali evening, Thanks a lot.
:-D Glad to hear it!
16:54
@ircmaxell @Gordon What's the preferred method for class extension - protected members, or private with a suitable API? (or something else I haven't considered?)
17:05
@Filipe clarification please.
yeah, that's a broad question
I tend to favor compostition over inheritance anyway...
:-P
I'm thinking of Symfony, for example, which was criticized in the way S2 presented much more closed classes (private members), and Fabien's response was basically "you can extend the classes, but do it through the methods we provide"
there are two schools of thought. One says childern should have access to some internal state, and as such protected should be allowed. But the other side of the coin is that by doing so you're tightly coupling the child to the parent (and hence presenting a maintenance problem, since the implementation is relied upon rather than the behavior). By making everything api based, it makes it easier to change the parent without affecting the child.
I think the latter is what I'm more comfortable with
different techniques for different use cases
17:10
Certainly, thanks for the input @ircmaxell, helpful as always
no problem
am I the only one that thinks the whole idea of common interfaces as discussed recently on @Feeds is stupid
if i want to interface with 3rd party libraries, then thats an application boundary
and there should be an adapter between the third party lib and my application then
yes
agree 100%
a common interface would make that additional adapter layer obsolete but how the hell do they want to figure out how i would want to interface with a library? SplSubject/SplObserver isnt satisfying already, so what makes them think they can do it for more complex interfaces?
If I have a Notification class, which saves messages and their type (error, warning, etc). Is it a good idea to use class constant Notification::ERROR to denote the error type? As in: $notification->addGeneral($message, Notification::ERROR)
17:17
jack of all trades, master of none
@rickchristie it's a logger?
no, it just saves general application notifications, to be read by the presentation layer and displayed. e.g. 'An error has occured, unable to process request bla bla', 'form data is invalid, please resubmit', etc
It also saves validation error messages
Well, instead of doing that, just add a "css" class as the second parameter. so "error" would be a css class...
@rickchristie that depends on how you pass the notification object to the other class. is there an interface for Notification or does the class depend on the concrete Notification class?
@rickchristie Depending on how many notification types you are talking about it might make more sense to make them instances of separate classes that inherit from a common one, e.g. Notification_Error, Notification_Info, Notification_Warning
@Gordon - no interface, although I can build one if it's better
@NikiC - yea, that's an idea
17:21
@rickchristie when you do Notification::TYPE you are effectively coupling to the Notification class. That's why constants in PHP have to be considered public API. You could write the constants into the interface so you dont have to depend on the concrete Notification class though.
I like @NikiC's idea, if the situation calls for that level of complexity
@ircmaxell - the meaning would be lost though. Also, this Notification class is accessed by the model/domain layer, so it shouldn't have any idea of the presentation right? It just says, this is an error message - the rendering part should handle that
@rickchristie fair enough
an alternative to the constants would be to have dedicated methods instead, e.g. addErrorMessage() or addNotice().
20
Q: Pros and Cons of Interface constants

GordonPHP interfaces allow the definition of constants in an interface, e.g. interface FooBar { const FOO = 1; const BAR = 2; } echo FooBar::FOO; // 1 Any implementing class will automatically have these constants available, e.g. class MyFooBar implement FooBar { } echo MyFooBar::FOO; // 1 ...

17:25
yes, i never got warm with that idea though. its better than having them on the concrete types but in general feels icky.
@ircmaxell - eiw to multiple dedicated methods?
I'm trying to build this btw: martinfowler.com/eaaDev/Notification.html
I vote on Niki's idea
Various notification types extending a base notification
@Filipe - the problem with that is, I'm going to have to pass lots of objects to the domain. Something like $authentication = new Authentication($errorNotification, $warningNotification, $successNotification) - it's better to have an object representing systemwide application notifications
And if you want to redirect, just call $notification->saveToSession() before redirecting, to save any notifications not yet displayed
@rickchristie correct
17:35
I think I'll go with interface constants - it seems a good enough solution for me for now. The notification types (ERROR, SUCESS, WARNING, INFO) seems to be static enough and would not change. I'll see if it causes me problems in the future.
Thanks for the help: @ircmaxell @Gordon @NikiC @Filipe :)
@rickchristie That's not exactly how I meant it. You would still have some object that accumulates the various notifications, but only the notifications itself would be instances of different classes
you could also do $notification->addError(new Exception('Something wrong')); though I am not sure I would like that for various reasons. I guess I'd go with having one method for each error type
@NikiC - Ah yes. That's a good idea.
@NikiC i dont understand your idea. can you explain. maybe i like that more.
17:42
@Gordon Noooooo
exceptions should not be "passed"
It basically what you wrote in the post after me, but not using Exceptions ;) So $notificationAccumulator->add(new Notification_Error('msg')), same with Notification_Warning a.s.o. (I use notificationAccumulator for lack of a better idea, maybe notificationStore or notificationQueue or whatever)
@ircmaxell hehe, yeah. i dont like the idea either. it was more lateral thinking :)
@NikiC hmm, i dont like that because it would couple the classes to the Notification classes. It hampers reuse.
@NikiC - I've tried that before using MessageInterface, e.g. ErrorMessage implements MessageInterface. This seems to be the correct way, but I'm having a hard time designing the interactions between the notification layer and validation layer.
$notification->add($errorMessage)
@Gordon Well, then create an error class...
@ircmaxell then what?
17:47
what @Nikic said...
@ircmaxell that doesnt solve it. I'd still have to new the Notification_Types in the consumer.
$notificationAccumulator->add(new Notification_Error('msg'))... how does that not solve it?
well, then map $notification->addError through __call to add with the error as the second parameter
each class using the NotificationAccumulator would depend on the Notification_Types
if you use dedicated methods, this would not be the case, which is why i like that approach better and dont understand why you dont like it :)
I don't have a problem with dedicated methods. I have a problem with passing it an exception. If you want to pass it something, create an error class...
otherwise, just pass in a string
> @ircmaxell - eiw to multiple dedicated methods? @rickchristie correct
confused now
17:52
oh yeah. well, I don't know
I'm confused myself
dam it being sick
Am I a weirdo for wanting an android watch (without the phone)
skip to about 2:30
lol
> You get watch you want.
18:01
oh, thats a real bargain: imshop.it
actually, that's not horrific
18:23
Does anyone know, are identifiers in html named using camelCase?
Or it is bad practice and I should always use underscore?
Usually it's underscore only
But it's up to you
@Eugene what do you mean by identifier?
@Gordon Usual id or class
@Gordon id="wrap_state" or id="wrapState"?
I pretty much only use camelCase
but it's completely up to you
@Eugene ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
class attributes are CDATA
18:28
@Gordon I know all of the rules about naming. Just curious about case. Usually I see with underscore.
@Gordon Is there any best practice?
@Eugene i dont know any agreed upon best practise.
So just as I want myself.
- and . can cause some problems when using parsers that make values available implicity
If I use anything besides letters or numbers, then it is just underscore.
there is at least no recommendation at w3.org/standards/techs/htmlbp#w3c_all
19:01
is there a reason why json_encode would put a null character in middle of a string it creates?
@Neal if the string contains that null char, then it'll just be added to the JSON-encoded string as is. php strings are "8 bit clean", which among other things means they can legitimately contain "\0"
@Gordon Thank you. I will look into that.
19:20
I'm creating a password generator consisting of a verb and noun, ie AngryHorse7, ElectricFist0, SpeedyAirplane8

Give me some more words
@cHao thanks ^_^
@stevether get a dictionary
and 2 words isn't enough entropy, not by far
@stevether EasilyGuessed1
@stevether if you want to use dictionary words, you can just as well put the NATO alphabet into an array, pick two and add a random number. just as insecure.
But I want it to be a phrase, hence verb followed by noun.
Our clients aren't the sharpest tools in the shed, so giving them a random string of characters is going to lead to a lot of customer support calls
@stevether giving them an easily guessable password that cannot withstand a dictionary attack will lead to an equal amount of cs calls plus make your customers not use your service anymore because you apparently suck at security. im not saying you do, but hey, your customers aint the sharpest tools in the shed.
19:31
I understand, but for the scope of this application security is moot point.
@Gordon Why?
@NikiC because unlike 75% of the usual questions and answers on SO, its a good question and answer and deserves the upvotes
@stevether make it at least 4 words, and you're fine
20:07
And hilarity ensues codepad.org/bcPM83K6
rand isn't strong enough for that purpose
Looking for some suggestions on organizing my code...
I have multiple database queries that will pass to multiple file builders
and you need far more words; at least 4 per password. And you need a larger dictionary (at least 10,000)
So, query1 data, file1 data... I'd rather not make a class for each thing, it just feels wrong, is there a better way?
90300 combinations for 5 clients with unique user names that have to access an account only from a specific IP at pre-defined times is good enough for me.
20:15
@stevether It's good enough for me too, because I'm the guy about to hack you.
If you think I'm kidding, just tell me who you're working for.
I will hack your customers.
And sell all their account information to the lowest bidder on a russian BB somewhere.
@stevether all joking aside, those are great odds for anyone looking to exploit your setup
90300 combinations is absolutely trivial
@stevether 90,000 is nothing
After logging in the first time they have to change their password. 99% of them will use their last name and their birth year. Their security isn't really on my radar.
After 30 randomly created passwords, you have a 50% chance of collision
A birthday attack is a type of cryptographic attack that exploits the mathematics behind the birthday problem in probability theory. This attack can be used to abuse communication between two or more parties. The attack depends on the higher likelihood of collisions found between random attack attempts and a fixed degree of permutations (pigeonholes), as described in the birthday problem/paradox. Understanding the problem As an example, consider the scenario in which a teacher with a class of about 30 students asks for everybody's birthday, to determine whether any two students have the s...
20:39
posted on October 26, 2011 by Andi on Web & IT

We just wrapped up the 7th ZendCon event last week in Santa Clara, and the enthusiasm of the PHP community was inspiring. PHP is gaining momentum across industries and geographies, powering the web, helping people build amazing apps with ease, proficiency and creativity. In so many ways, PHP is making a difference, from legacy modernization to mobile app development and cloud deployments. And

Has anyone tried phpcloud yet? I've got an invite but haven't tried it yet
@stevether For reference, "angry", "electric", and "speedy" are adjectives, not verbs.
not quite relevant, but i'm training to be a grammar nazi
21:03
A noble endeavor, no doubt
Project for the evening is making myself a small blogging platform
@Filipe wasnt that your project a few days ago already? Oo
Yes, but then lack of sleep kicked in :(
But it's my project for the night!....I'm going to get some coffee...
@Filipe make sure you show us the results so we can rip^X^X^X code review it
21:11
It's going to be horrible horrible code
But it'll be fun to work on!
I might just go all ~~ procedural ~~
@Filipe ah, a wordpress clone ;)
@Gordon Oh ouch
@Gordon that'd have to be spaghetti code...
im still fascinated with the idea to write a procedural framework for PHP :)
I've seen a few - it looks like a fun project, although most implementations I came across were horrible, and simply procedural because the developer lacked OOP knowledge
@Gordon @ircmaxell - name my blogging platform, one word, go
21:16
@Filipe FiBlog
That's why you're a developer and not a name inventor, @Gordon
@Filipe i think its a good name. and you didnt specify any requirements.
fig!
There, I worked off your suggestion, now it's called fig
@Filipe figs are tasty
@Gordon I'm allergic, unfortunately :\
21:20
@Filipe Something nobody else will use
@ircmaxell What do you mean? My blogging platform?
Or the name?
@Filipe i think that IS the name: "Something nobody else will use"
"snewu"
Man you guys are horrible thing-namers
Sonoelwius
21:22
hehehe
Given that you likely wont make this into a product I guess you can just name it Blog.
Yeah, it's not going anywhere besides my website
But I'll share it with you fine lads to, in your words, rip^X^X^X code review it
com\github\FilipeD\blog
user680786
21:38
hi, kindergartens
user680786
" Module 'ffmpeg' already loaded in file Unknown line 0" - google don't want to tell me how to fix it. And SO too. Maybe somebody here?
user680786
fixed
user680786
thanks to all
user680786
user680786
what is better, nginx + php-fpm or nginx+lighttpd+php?
user680786
21:53
ok, tomorrow you will wake up and, I hope, somebody will not too lazy to wrote his opinion :) good night
I prefer nginx+php-fpm
22:53
nginx + lighttpd??? WTF? Two web servers?
I'm guessing as some sort of proxy
02:00 - 15:0015:00 - 00:00

« first day (375 days earlier)      last day (4797 days later) »