« first day (433 days earlier)      last day (4515 days later) » 
00:00 - 13:0013:00 - 00:00

1:06 PM
@NikiC Initial testing results say my peer group likes the "STUPID"
 
@edorian Agree
 
1:22 PM
posted on December 23, 2011 by Ulf Wendel

The MySQL part of the PHP reference manual is currently being restructured: new landing and overview page, mysqli quickstart prepared. Ten years ago, there was the mysql extension and that was it. Today, beginners are faced with three MySQL APIs/extensions, two libraries and more than three library plugins. MySQL support ...

3
 
I have retrieved the values from database and when I echo i got the values 20,30,40,56,68 . How could i split in PHP?
 
1
Q: Converting indentation with preg_replace (no callback)

hakreI have some XML chunk returned by DOMDocument::saveXML(). It's already pretty indented, with two spaces per level, like so: <?xml version="1.0"?> <root> <error> <a>eee</a> <b>sd</b> </error> </root> As it's not possible to confi...

 
Could any one help ?
 
@user1067018 $arrayOfNums = explode(',', $var);
 
It gives out put as array
 
1:30 PM
@Feeds I like that they are updating the MySQL docs but still feel like there should be a red warning box at the top of all mysql_ functions that this extension shouldn't be used
@user1067018 Hence why I named the return variable as $arrayOfNums
 
@edorian What is the current version of STUPID?
 
@user1067018 What are you wanting to do with the list of numbers after you split them?
@NikiC Do you have a link that can explain what this STUPID thing is about? Or is it just some inside joke I don't know about? :P
 
Suppose here I stored a variable $marks = 20,40,34,60,23 from database by loop system. Now I need the average of last two digits i.e., (60+23)/2
 
@CharlesSprayberry It's more like an inside joke ;) Though if @edorian allows I can write a blog post on it :P
 
@NikiC STUPID is the new SOLID - Singleton, Tight Coupling, Untested, Premature Optimization, In-descriptive Naming, Duplication
Sure go ahead
 
1:35 PM
@edorian haha
 
@user1067018 , well .. did you try learning SQL ? It sometimes helps
 
@edorian Will do as soon as I find time
@Feeds +1
 
Yes I know sql
 
no , you really dont know SQL
 
Ok Thank You, for that
I know myself how strong good enough not about 99%
 
1:39 PM
@hakre Nice question. Learned something new from it
 
@edorian Which?
 
Teresko, Thank you
 
ah nice use of \G
 
1:44 PM
teresko, Suppose here I stored a variable $marks = 20,40,34,60,23 from database by loop system. Now I need the average of last two digits i.e., (60+23)/2 in PHP not in mysql
 
@NikiC I don't understand why that works
ah, got it.. i guess.. care to explain it anyways?
 
@edorian \G matches at the first matching position ;)
 
Subpattern: Start of line or start of current serach, replace with tab if two spaces
 
@user1067018 you can do that stright in SQL, you don't need PHP here.
 
I though I knew what \G does but I didn't think it would match again and again
 
1:49 PM
@edorian Well preg_replace does multiple calls to pcre_exec every time increasing the startoffset (to the end of the last match). And \G always matches at that starting offset ;)
 
Omeid, Could please suggest me how to proceed
I have the output like
 
@NikiC DO'H
Thanks
 
userid scores
3 20,30,40,45
 
@NikiC I always thought it would just call exec once and magically record all matches offsets and then string replace
Why ever i thought so it always was logically consistent with my observations
229
Q: Will Stack Overflow boycott GoDaddy because of their support for SOPA?

Daniel SerodioGo Daddy’s Position on SOPA, from their website A partial excerpt from the statement Go Daddy filed with the House of Representatives: Our Support for SOPA Go Daddy has a long history of supporting federal legislation directed toward combating illegal conduct on the Internet. For exa...

Just to throw in some non @internals drama :P
 
@edorian I love Joel's matter-of-fact, no BS answer
 
2:02 PM
Yes.
====

<!-- 123456789012345678901234567890 -->
 
@edorian after reading that I was wondering how automattic / wordpress deals with it: hakre.wordpress.com/2011/12/23/…
Regex question is solved, it didn't work on codepad.org because their pcre lib is pretty old. They don't even have UTF-8 support, which is needed anyway for XML output.
 
@CharlesSprayberry Yeah. Clear stance and done. Putting the work in moving and not in rationalizing staying is really cool
@hakre That explains that
 
@edorian Uh, I don't know whether I am right ^^ I did not look it up before saying that
 
puts on a helmet made out of coffee mugs to the source!
 
That's the main preg_replace implementation chunk
For me it looks like it does multiple calls, but it's somewhat hard to understand
 
2:21 PM
the while (1) pcre_exec would lead me to belive the same
Even so for me "somewhat hard to understand" is quite an understatement
I'm not used to dealing with functions that don't fit on my screen in ETHER dimension
 
@edorian But at least the variable declarations fit :P
The code uses 28 variables
 
} else { /* do regular substitution */
I don't see where it touches the string yet oO
Oh. New_buf, memcopy
I see
 
@edorian haha, yeah i was wondering how he did that, too
 
So every single substitution creates a completely new string? It's amazingly fast given that
Haha.. Don't know if funny or sad: careers.stackoverflow.com/jobs/15746/…
Ah. They just copy pasted the needed skills for every job they offer
That makes sense.. not
Also starting your technologies with "e.g." seems a little strange.
"We do websites, for example with HTML and CSS"
 
2:37 PM
@edorian Oh, I would have applied if they were making websites with C and OpenGL
and this list, 'Ajax, JavaScript, JQuery, HTML, CSS, Backbone.js, ....' sounds like JQuery and Backbone is JavaScript like HTML is to Javascript.
 
@edorian Do you need to know all of what they list there to apply?
 
@NikiC Apparently thats the skill listing for 4 different jobs they are just all pasted in all job ads
getopt can parse something like: php script.php --foo="1" --foo="2"
Thats amazing. Didn't know that
 
 
1 hour later…
4:00 PM
hi guys
 
@andho howdy
 
4:24 PM
guten morgen
 
@Ozbekov yet another german?
 
@NikiC Nah, I'm not German. Turkish.
 
Merhaba Ozbekov
 
@Ozbekov There is a difference?
 
4:32 PM
@NikiC Yes?
 
I have some passing PHPUnit tests that are printing out expected error log messages. Is there anyway I can suppress these messages from showing up in the command line?
 
4:48 PM
@CharlesSprayberry ?
 
@CharlesSprayberry @expectedOutput annotation?
or ->setExcepectedOutput(); for that matter
 
@edorian There is an expectOutputString() method. However, error_log appears to be going to stderr and not stdin
 
Oh so you don't have an issue with a now broken test but you want to test output that goes to STDERR. I see
 
@edorian Oh yes, all tests are passing
@edorian I actually found an answer written by you about testing stderr with PHPUnit
3
Q: Is there a way test STDERR output in PHPUnit?

Kevin HerreraI have a class that outputs to STDERR, but I am having trouble finding a way to get PHPUnit to test its output. The class, PHPUnit_Extensions_OutputTestCase, also did not work.

so i'll take a look at that :)
 
Heh
Wow thats a lot of text
Main point: Have a class that wraps your error handling and mock it for the tests
using error_log is global state :P
 
5:02 PM
@edorian How would I use logs without global state/static? I've tried my best to avoid them wherever possible but 2 things in particular have me stuck: file directories and logging
I mean, I suppose I could just make them classes and inject them, then I'd be injecting 2 objects into virtually everything being created...that seems ugly
 
in your application bootstrap at some point you say: new ErrorLogger('myLogFile.txt'); or seomthing similar
and everything that needs error logging gets that error logger injected when it's constructed
and if you are in dev mode you can create a different logger with backtraces and everything
if "virtually everything" writes errrors into logfiles that might also be a problem (Been there, done that)
 
Well, maybe not virtually everything with error logging
 
F.e. your model layer / application objects should pretty much never log errors but throw exceptions
But thats not always doable, i know
 
46 tests, 240 assertions and only 3 error log messages
 
Easiest / Fastest test solution:
Put the error_log call in a protected method. Mock that out in the test and test against the mock object instead of the real one
It's the "I don't want to work on my application architecture" approach that works out fine if you do it deliberately and not all that much overall
 
5:06 PM
I suppose I could consolidate that one log message into the exception. But the other 2 must stay as they are a fail-safe in case the app didn't provide a valid value. What the method is returning must have a valid value
@edorian You had me until you got to "I don't want to work on my application architecture" because, well, that's kind of the whole point :)
 
You could still throw new ApplicationBrokenBeyondAnyHopeOfRepairException(); and log that in your general exception handler
 
I love that exception name haha
 
@edorian Since when do hashes have to be all of that? This is PHP, it handles them very nicely. It's just for other languages, but for sticking into PHP arrays? It's nice. Admit it.
 
But, well, it isn't something that breaks the application. They have several opportunities to map a requested URL to a routed URL, if they never supply an appropriate value one is "chosen" for them as a fail-safe
I don't want my whole thing to come crashing down just because somebody forgot a configuration value
But, I also want to let them know: "Hey, you really should supply a value for configuration x"
 
Yeah. But is logging to stderr the right way then? Do you want to do that everytime some uses the app? Maybe you just want to notify the admin accounts with a popup or something :)
 
5:14 PM
@edorian Thank you. I think I know what I'm gonna do. Time to do some thinking and planning.
 
@LeviMorrison I'm sure one could make up a use case where this is a very neat solution. Definitely :)
 
@edorian Sticking them into a PHP array as a key is a nice use-case. No collisions between object types (object, scalar) and PHP is happy about them.
 
@CharlesSprayberry Did you notice how we went from "I want to silence STDERR" to "Application redesign" :) I love it when that happens.. sometimes. Sometimes it is really really annoying when I don't want to really deal with the issue at hand :P
 
@edorian I was using md5 but then I realized that a string is already unique, just throw it in the hash. It may still have issues, but they are PHP language issues.
 
@LeviMorrison "Putting stuff in arrays" isn't a use case. It doesn't "achieve" anything. :P
 
5:18 PM
@edorian Yes it does: creating a Set.
 
oh, @LeviMorrison's back
 
@NikiC Yeah. Did you check out my probably lousily written Set impl?
 
In software and systems engineering, a use case is a list of steps, typically defining interactions between a role (known in UML as an "actor") and a system, to achieve a goal. The actor can be a human or an external system. In systems engineering, use cases are used at a higher level than within software engineering, often representing missions or stakeholder goals. The detailed requirements may then be captured in SysML or as contractual statements. History In 1986 Ivar Jacobson first formulated textual, structural and visual modeling techniques for specifying use cases. In 1992 his co...
 
@LeviMorrison No, not yet
 
We could argue that "creating a set" is a use case but I don't like it. It doesn't "do" anything.
 
5:19 PM
I'm currently setting up a root structure for the ext
 
It should have any sort of value or observable goal like "i want to see if X is already in list Y" at least
 
@edorian Well, if you want to be strictly technical, you are correct.
@NikiC In PECL?
 
@LeviMorrison Not in PECL, just to have something one can start working on
 
I'm rather "If i don't need it i wouldn't build it" and that has an "I need it for" answer
 
@edorian I've used Sets in PHP quite often. Admittedly, the sets have never been large so I just used PHP's arrays. However, if I have a somewhat decent use-case for it, then surely SOMEONE has need for a real set.
 
5:29 PM
I'm off. See you guys later / over the week
@LeviMorrison I don't remember a case where I needed typed scalars and objects in a set (so array & spl_object_map thingi) always sufficed. but yeah. I see your point
Later :)
 
can i somehow detect whether a resource is a file descriptor/writable stream?
 
That's only the skeleton for Stack (and still lacking interfaces and stuff)
will try to add the actual implementation later
Hm, and I seem to have messed up the repo somehow
 
5:50 PM
@NikiC Have you figured out how to namespace things?
@Gordon Unsure. I don't work with resources very often. I'm assuming you meant a PHP resource, not resource in the generic term.
 
@LeviMorrison yes. Just define the class with the namespace
 
@NikiC Do you namespace the skeleton you have online?
 
@LeviMorrison Yes
@LeviMorrison The namespaceing is done in the macro to keep code clean: github.com/nikic/SPL-Datastructures/blob/master/…
now I need to figure out how to define an internal stack object ^^
 
@NikiC Hmm. I don't think C has one.
 
@LeviMorrison I mean how I can attach some custom stack implementation to the object :)
 
6:41 PM
@Gordon $meta = stream_get_meta_data($stream); var_dump(is_writable($meta['uri']));
 
hrmm...what kind of exception should be thrown for a permissions issue? make my own PermissionsException?
 
an exception for an issue?
I mean is the issue exceptional?
 
Like, lets say the file they pass in the logger can't be written to by the user. This seem to be an exceptional situation to me
Or...I suppose we could always revert back to some fail-safe logging mechanism...like error_log
 
is returning references to a variable created in a function considered as good practice?
 
6:46 PM
IOFailureException
extends RuntimeException
 
@ThinkingMonkey Changes are "no" as your questions contains the word "references" and those are pretty much never "good pratice" (whatever that means exactly) in php nowadays.
 
you would need to create it yourself. If you don't want to, I would just use Exception to keep things simple.
 
@hakre I would create the exception class. I don't want to throw a generic Exception object. I believe exceptions should be thrown as specific as applicable without leaking the abstraction
 
@edorian could you elaborate?
 
As long as there is fatal error in PHP, I don't believe that there is a true exception in PHP ;)
@ThinkingMonkey I think what edorian means is that you need to tell more why exactly you think a reference is needed.
 
6:51 PM
@ThinkingMonkey MVC (for whatever that means in your case) is about objects. I don't see where references come into play there at all. For scalar values: References create a lot more problems that they solve and there are very little to no use cases for them in php. Links incoming
 
Especially with objects. Yeah.
 
@edorian I need to contemplate more. Will be back later. And I have already read that article.
@harke I need to contemplate more. Will be back later.
 
@hakre I believe I never asked up until now: What do you do for a living?
 
7:06 PM
I'm programming PHP/Webapps and next to that administrative stuff like planning and specs.
 
Company/Buisness domain? Size? Teamsize? If i may ask :)
 
Not under this nick.
Sorry, next time we meet I can tell you.
 
Yeah, no problem at all
 
7:54 PM
@hakre Everyone so secretive ...
 
@NikiC Everyone? I'm not, you're not, nor are gordon, ircmaxell or salate
 
@edorian You got a point there ^^ What is salathe doing btw?
 
Software Developer at Bloxx Ltd.
from his profile :P
 
@edorian Oh, yeah. Wer lesen kann ist klar im Vorteil.
 
Reading is cheating
If it's not code it's lying anyways
 
8:27 PM
@NikiC It's more because hakre is my polter in the house online account ;)
this net stores everything which can make things complicated.
 
Which can be quite helpful to have honestly
 
Anyway I personally prefer teams not larger than 8-12 people and I also worked for other companies as well as for legal entities I own (in part).
 
teams as in IT-Staff or teams as in company size or as in "the guys working on one project" ?
 
team in a project, in the context of the team size you work in.
 
12 people already seem quite a lot for that. As we grew over 10 people things got really complicated
as in n-m communication
 
8:32 PM
@10 it's often skipping
you change from small to large
smaller teams are often more effective.
this is also true for company size ;)
 
Especially if management doesn't plan ahead for the growth
 
Which is almost always the case.
 
and you have organisational structures for 20-30 people applied to 120
But i can't really blame anyone to be honest. Rapid growth is complicated
 
Well one could blame oneself.
 
I'd like to believe that I did a lot of what I could at the time to help
and if I/we really managed to create a working new team structure that works for devs and buisness i don't know yet
 
8:39 PM
From the coder perspective I liked this book: nostarch.com/codecraft.htm
It has some very nice chapters about team play and dealing with management.
 
haven't read that one. I'll give it a look
The last thing that really impressed me was the "new" unclebob
 
Is that clean code part II?
 
That embed got a little out of hand -_-
That is everything aroud clean code.
Professionalism , craftsmanship, personal responsibility
why we can't blame managers for telling us to get things done and so on
 
It's also very interesting to listen to what those folks from (the old) MySQL are talking about their work-structure. They have made a lot of experiences.
 
Yeah. MySql -> Sun -> Oracle must have been an interesting journey
 
8:44 PM
Well more the pre oracle time, they grew bigger then and things changed.
 
(apart from just working at MySql
Apart from that I can just say that dealing with MySql was a lot easier than dealing with oracle
 
in case you need something to read, might be the one or other interesting topic in there.
 
9:02 PM
I've got some time on my hands the upcoming week. Will give it a read
 
Eh, why isn't there any valid() function in PHP? We have reset, next, current but no valid. How come? Is there something similar?
 
what should valid do?
 
(bool) of whether an iterator / array is in a valid state.
 
Can an iterator be in an invalid state?
(that's observable from the outside)
 
the iterators have ::valid();
I'm packing some iterators together.
And my iterator is "over" the inner one.
The inner one could have been an array or iterator.
But now I wrap arrays into iterators already, to work around that there is no valid() function.
An iterator is in an invalid state if it is behind the last element.
 
9:11 PM
to "valid" is to determine ether or not an element can be read after "next". From the outside you will get a false on "next" and on "current" if the iterator is "used up"
Not sure I would describe "done" as "invalid" but i see what you mean
 
yes, but as I write an iterator myself, I need to implement the valid() function.
 
I guess it's not there because "current" will achieve the same
 
I was lazy and just wanted to return the valid($inner).
 
$inner->valid(); ?
 
now I return $inner->valid();
but I still have a bug somewhere, it does not stop to iterate even inner should already be fully consumed.
okay, way better to use an iterator instead of an array.
I had the wrong impression that next($subject) would work on iterators.
 
9:20 PM
I've never tried that. I just assumed it would work
 
@hakre Huh, doesn't it work?
I may have expected it to not work on IteratorAggregates, but definitely on Iterators
 
 php -r' $x = new ArrayIterator(array(1,2,3,4)); var_dump(current($x)); next($x); var_dump(current($x)); '
int(1)
int(2)
 php -r' $x = new ArrayIterator(array(1,2,3,4)); var_dump(current($x)); next($x); var_dump(current($x)); next($x); next($x); var_dump(current($x)); next($x); var_dump(current($x)); '
int(1)
int(2)
int(4)
bool(false)
Seems to work out fine
@NikiC And you're right on Iterator Aggregate too
Which is quite expected as it just inherits from traversable and not from Iterator
 
9:41 PM
@edorian :)
 
@edorian thanks
 
all but valid() which does not exists :/
 
10:20 PM
PHP 5.4.0 RC4 was just released :)
2
 
wget /from/this/mirror
it's not on qa. yet?
 
wget http://downloads.php.net/stas/php-5.4.0RC4.tar.gz
 
i c
What I never botherd to find out: Can i tell it to make using multiple cores?
make -j8 didn't work
 
Doesn't it do automatically?
 
CPU usage: 5%
and I'm watching a video, running 2 vms and playing a 3d game
it doesn't really do all that much it seems.. io issue?
 
10:27 PM
Hm -j8 should work
At least Johannes said on a related topic "(but well, no our build system works differently, on a 64 way machine I
can easily compile 64 files in parallel using `make -j64` with out
system)" which sounds like it should work ;)
 
All right. That at least got mem usage up .. it seems i used -J8 the last time
nice! 35secs to complile
 
indeed nice
 
phpunit runs too even so I'm not willing to install xdebug for into that version
 
10:43 PM
is there anyone who knows hmvc structure?
 
10:54 PM
Just learned that data:// supports binary: 'data://,'.$string.
At least in PHP.
 
which is quite nice for code injections
 
It's nice for codepad viper if you want to simulate SPLFileObject: codepad.viper-7.com/Bdpx4z
 
(at least that is where I've seen it used)
 
yeah some hosts block eval, but still allow include and url fopen
 
I've used php://memory for that in the past but data:// seems like way less hassle. Nice point
 
10:57 PM
so you can inject it with data://
how does that work with php://memory?
I never really figured that out.
like getting a file handle, fill it up, rewind it and pass it on?
 
exactly
2
A: Is there a way test STDERR output in PHPUnit?

edorianYou can't intercept and fwrite(STDERR); from within a test case with the help of phpunit. For that matter you can't even intercept fwrite(STDOUT);, not even with output buffering. Since i assume you don't really want to inject STDERR into your "errorOutputWriter" (as it doesn't make any sense fo...

fopen rw, write, fseek(0), readable
 
@edorian That answer just keeps popping up ;)
 
@edorian What kind of code injection?
 
@NikiC require 'data://stuff'; style
 
Ah, applications in lying, I see
 
11:02 PM
@CharlesSprayberry It's my only one with "ugly" stream magic ;)
 
@edorian It is very strange that the hosts you are referring to don't allow eval() but do have allow_url_include... that seems so stupid.
 
I've seen that stupidity in real.
 
@NikiC @hakre was referring to those but I've made the same observation.
 
@edorian Huh, you just said "yeah some hosts block eval, but still allow include and url fopen" ^^
 
8 mins ago, by hakre
yeah some hosts block eval, but still allow include and url fopen
 
11:05 PM
oh crap
I mixed up the two of you
 
It happens to the best of us.
;)
 
:) could be worse
 
We all should write more iterators. stackoverflow.com/a/8621304/367456 - the SPLFileObject is quite handy for lines of files.
 
Oh look. A small book
And if I might make a objection to your statement: No, not ALL of us should use more iterators
 
@hakre AnswerTooLongException?
 
11:09 PM
I believe if @Gordon uses any more iterators the SPL will implode in a black recursion hole
But it will be very pretty to watch
 
RecursiveExplodingBlackHoleIteratorIterator
 
Yeah a bit lengthy while exploring this ;)
I still have a glitch in the implementation preventing MultipleIterator to get the key on the last iteration. Something is wrong with my valid().
@Gordon RecursiveExplodingBlackHoleIteratorIterator extends InfiniteIterator { function current() {static $c; return $c[] = $c;}}
 
@hakre like it (evil)
 
@NikiC It's there for debugging so you know what you iterated over when you need it!
 
11:24 PM
It's really evil.
It is evil in multiple dimensions.
How do you debug a segfault?
 
I upgrade the php version and hope it goes away
Well.. since I deal a lot with an unupgradeable 5.2.6 .. lots of die(); statements and seeing where it crashes and then chaining stuff around hoping it stops to die or giving the machine more memory :)
 
you can use dbg to debug a segfault.
 
Debug builds and core dumps are for people that know C :P
 
I used dbg + php w/o debug builds.
 
@hakre thx, just tried, didn't help ^^ seems like I will need to check my code
 
11:29 PM
In all seriousness: I've never needed to go beyond bugs.php.net/bugs-generating-backtrace.php
 
probably did some stupid fault in the object allocation handler
 
are you compiling your spl extension?
 
Well "it compiles", but ... :P
 
Do you guys normally put IDE-specific project settings into version control?
 
the only IDE related stuff I put in my scm are ignore flags for their folders if they can't be configured away or people don't want to do that
Usually their config files are not interchangeable between systems anyways as they contain fixed pathes and so on.
 
11:44 PM
@edorian What IDE do you use?
 
Netbeans, phpstorm and vim mostly
Do you have anything that would make sense to put in there? interested
 
@edorian I've never thought so but I almost accidentally deleted my nbproject folder and I would really regret losing that. I mean, I get that IDE configs are specific to my machine and I don't want them in my repo.
I also don't want to lose all my project configurations either
Maybe I'll just let my normal backup take care of that...
 
I got in the habit of telling netbeans to put its metadata in my user directory (C:\user\name\netbeans)
 
@edorian I should probably set my system up to do the same thing
 
But as he have +15 devs by now the "how to configure netbeans" stuff is pretty streamlined and documented so loosing the configs doesn't cost much time
 
11:49 PM
Sure, and I'm over here flying solo, I can't really afford to spend that time on NB when I could be wasting it in here!
Although, to be fair a lot of good convos go on in here. As long as the internet rage isn't out in full force
 
convos?
 
Conversations. About PHP and web development.
 
I mapped it to "conventions" and that didn't make much sense :P
 
Well, some of the coding conventions advocated are pretty good ;)
 
In case you're using git: I configure git per repository to ignore my eclipse specific configuration files and directories.
that keeps .gitignore clean.
 
11:59 PM
Wow, it is really surprising how much difference a 1 can make over a 0.
 
yeah especially in a binary system ;)
 
@NikiC Accounting and programming is really picky when it comes to a digit
 
00:00 - 13:0013:00 - 00:00

« first day (433 days earlier)      last day (4515 days later) »