« first day (426 days earlier)      last day (4522 days later) » 

8:00 PM
go for it, I'll fork it imediately :-D
 
I'm okay with that
 
And I've been pushing it. However, I'd like to to be done more than anything
 
(and the submit pull requests
@LeviMorrison Go for it
 
Will we use fork or repo collab?
Answering my own question: Fork.
 
or could do collab in the repo, whatever
 
8:04 PM
@LeviMorrison What's your github acc?
 
morrisonlevi I just deleted my old projects as no one was using them and I am not going to finish them. Creating the new project as I type.
Lol, I guess I don't have git installed on this netbook
It'll be a moment, I guess
 
@LeviMorrison You should define a mail address for your github account (so that private messages work)
 
@NikiC You mean a public one?
 
@LeviMorrison I think that it's private
 
Approximately 2 minutes until git is finished installing.
 
Anybody want to answer an uncharacteristically nooby set of questions?
 
@Anfurny Hard to answer that unless we know what the questions are
 
Well if you know you're not in the mood, you can have a definite negative without knowing.
1. Best unit testing in PHP?
 
@Anfurny there's more than one person here
 
Yeah, I was hoping at least one would say yes @ircmaxell
 
8:16 PM
Alright, it's there. Empty (except default README).
But there.
@ircmaxell feel free to fork, I guess, lol. However, how do we want this set up?
 
@Anfurny I would say PHPUnit is the de facto unit testing framework for PHP
 
Directory wise?
 
@ircmaxell @NikiC Should we start with defining interfaces? Setting up the API?
 
I was afraid of that @CharlesSprayberry
 
8:20 PM
What do you guys think for the name for 'isEmpty'? empty() or isEmpty?
Conventions are hard to establish, but important.
 
@LeviMorrison could you set up some basic structure? a lib/ and a phpunit test/ or how it is you do it ;)
 
@Anfurny Why?
 
@NikiC Working on it.
I use subversion at work, so I'm a little slower in git because I don't use it much.
Except to check out things.
 
@CharlesSprayberry Is there a way to make PhpUnit automatically continuously do unit testing on every run, rather than from the command line?
I'm not asking how, just if that's a feature.
 
@Anfurny I'm not entirely sure, I'm still at a point with my use of the framework that I'm running all tests from the command line. You would need to talk to somebody with more PHPUnit experience.
 
8:24 PM
@anybody? Is there a way to make PhpUnit automatically continuously do unit testing on every run, rather than from the command line?
I'm not asking how, just if that's a feature.
@CharlesSprayberry So I guess I don't really get what advantages php unit gives over writing an even shorter script in php that does the exact same kind of testing?
 
Will git not commit an empty folder?
 
@LeviMorrison No, it must contain some file
 
I'm just used to subversion, I guess.
 
@Anfurny Then I would say that you haven't really looked at the full scope of what PHPUnit provides for you. I can safely say, even with limited use of the framework, that no "simple" script is gonna be able to replace it.
 
@NikiC @ircmaxell I've got lib/interface/Stack.php added just to get some structure going.
 
8:28 PM
I agree that I haven't really looked, could you just name one, two, or three features that really sell you on the package? @CharlesSprayberry
 
@Anfurny The ability to really see what code is being used and when with code coverage. The assurances that with one command line every unit testable aspect of my application is tested and does what I expect.
 
@LeviMorrison Interface?
@LeviMorrison I meant interface meaning API, not technical interface
 
So code coverage, that's something I certainly couldn't do in a small script.
 
@ircmaxell I had to have SOMETHING for git to let me commit
 
:-D
 
8:31 PM
@ircmaxell We don't have to do it that way.
 
it's all good
 
Besides, it's a nice place to brainstorm. We can just delete it later.
 
sure
 
@Anfurny I have only limited use of the framework, I've really only scraped the surface. Mocking databases and objects for example, I only have basic practice with.
 
@ircmaxell do you prefer isEmpty or empty?
 
8:33 PM
I guess I just have been fairly impressed with what i've seen of testing in ROR and I don't immediately see the same set of features and integration with php.
 
I dislike empty, as in some libraries empty means "Clear out everything".
 
@LeviMorrison isEmpty
 
isEmpty agree
 
For the return value of push.
What do you guys like?
THe object pushed?
I like returning the Stack itself, but that's just because of all the time I spend in jQuery.
 
hrm...
 
8:41 PM
We can always do void too.
 
I would say void
since pop can't return the stack obv.
 
@Anfurny Some implementations DON'T return the value. C++ Stl doesn't. In that case you could return the Stack.
I'm against that, myself. I was just illustrating the point.
 
The fact that you have to ask means that somebody reading code will have to ask which is bad.
$x = $y.push($c); // no matter what push returns, I'm confused
$y->push
 
Regardless of how it's implemented, github.com/morrisonlevi/PHP-Datastructures/blob/master/lib/… would be preferable to the SplStack.
Well, I suppose it could be worse if its performance was really bad.
 
@LeviMorrison By the way, tabs are evil :)
 
8:48 PM
@ircmaxell @NikiC @Anfurny and anyone else: In the Spl, lots of structures throw exceptions when you do things to empty structures. I agree that there should be an exception, but what kind?
 
Yeah I already wondered
could be Underflow
But could also be lots of others
 
@NikiC Eh, my vim tab is set to a tab. I don't usually develop on this machine :)
 
@LeviMorrison depends on the operation
 
@ircmaxell pop and peek on the stack, for example
 
8:49 PM
I think UnderflowException is most appropriate for pop()
 
@NikiC And yet none of the structures throw it. They just give Runtime.
That one is at least fixable.
 
@LeviMorrison underflow for those two
 
@LeviMorrison But we want to be better, don't we?
Btw, do we want to redefine the exceptions too?
 
@NikiC Maybe. OutOfRange vs InvalidArgument could use some work
But generally I like the exceptions.
 
Hi; I read that select count() on an InnoDB table reduces performance, compared to an MyISAM. Is it the same for select max()
 
8:55 PM
@LeviMorrison Do we really need peek?
 
@NikiC It could be top.
I think peek is the more traditional name.
 
peek for me sounds more like a way to peek ahead in a stream
 
peek looks at the top element without removing it
 
though okay, Java uses peek() as a name too
 
Well, that's all I have time for right now. I need to go donate blood and go to work. Cheers!
Well, I guess I'm not donating blood. My wife decided she doesn't want to go.
 
9:07 PM
@LeviMorrison Hi, do you know if select max() has a similar performance issues in an InnoDB database as in MyISAM?
 
@user705339 I'm not familiar with that specific issue, I'm sorry.
 
ok...thanks
 
@LeviMorrison I sent you a PR
though thinking about it, that kind of stack implementation is not suitable for the general case
 
Before we get into implementation, we should decide on if we want an array based or LinkedList implementation.
Also
It might be nice to have both
 
As it keeps pop()d elements alive
 
9:13 PM
Each has benefits.
 
Does the internal implementation really matter?
 
@NikiC It might
 
Anyways, I'm all against a linked list based implementation
 
Using a DLL would be a bad idea.
@ircmaxell Would you rather see a SLL or array implementation?
 
@NikiC Why?
 
9:20 PM
@ircmaxell It'll add lot's of bloat for no good reason
 
@NikiC As you well know, PHP's arrays are quite bloated as well . . .
 
@NikiC what bloat?
 
Keeping pointers and using nodes.
 
in fact, I'd rather see it either as a native C array, or a linked list...
 
@ircmaxell Agreed on native C array.
 
9:21 PM
agreed on array
 
and since doubly linked lists are not that much efficient than SLL in general, I would vote for DLL...
 
Let's all read:
In computer science, a stack is a last in, first out (LIFO) abstract data type and linear data structure. A stack can have any abstract data type as an element, but is characterized by only three fundamental operations: push, pop and stack top. The push operation adds a new item to the top of the stack, or initializes the stack if it is empty. If the stack is full and does not contain enough space to accept the given item, the stack is then considered to be in an overflow state. The pop operation removes an item from the top of the stack. A pop either reveals previously concealed items, ...
And then vote. We can't get too caught up on this yet. API is more important than implementation. A good API can handle multiple implementations
 
agreed
 
a singly linked list would be easier to implement on the C level
 
true
 
9:26 PM
the array approach would be simpler on the PHP level
 
@NikiC True, but doubling array size is not exactly a complex operation.
I honestly like the array implementation approach in C. However, we would need to clear the pointer to null (on pop) so PHP's zval's references don't get messed up.
Also, the linked version has a better use of small memory shares. An array would have to be sequential. That would make it hard to double its size if working with a limited set of memory.
 
I didn't get your last point
 
If we have a limited set of memory (such as is common on shared hosting, a major PHP market share), arrays have to find sequential bits of memory. In a stack, traditionally you double the size when you hit the max.
Finding free memory double the current size could be problematic.
That isn't a problem in LinkedLists because they don't have a max. You just add a node.
 
which takes 2 or 3 pointers (val pointer, next pointer and prev pointer (in a DLL))
 
I still don't get your point. Do you think that people will build stacks so large that there is no MM block of that size anymore?
 
9:37 PM
You do know calling dlls is actually expensive?
 
@ChristianSciberras No, it's not
 
@NikiC Perhaps on shared hosting. It might not be important, but it is worth pointing out, at least.
@ChristianSciberras Maybe for random access, but not for end access.
 
@ircmaxell Are we talking about a particular architecture?
 
@ChristianSciberras no
different data structures exist for different reasons
 
@ChristianSciberras But we are talking about a Stack implementation.
 
9:39 PM
@ircmaxell Believe me, I've worked in this area for a while, some calculations are better off done in an interpretive environment than having a dedicated dll do the math.
Now if we're talking about php dlls, I honestly don't know.
But some dll call types are quite expensive.
 
@ChristianSciberras Again, we're talking about a Stack implementation, so we only have end operations. Those aren't expensive.
 
@ChristianSciberras DLL === DoublyLinkedList
 
@ircmaxell AH!
2
 
looool
 
9:41 PM
I took it as dynamic link library XD
 
Hm, I'm having a hard time writing tests for the Stack
All methods are so interconnected
 
Thought you guys where thinking about implementing the algo in a .dll :D
 
To test one method I basically need to test all others at the same time ^^
 
@NikiC I think you may have to expose protected members to the test to do it without the interconnected tests.
But then you are tied to implementation, so . . .
Who knows?
 
:-D
 
9:43 PM
Just assume that size works properly.
lol
Sometimes you can only test data sets, instead of specific operations.
Well, I'm going to work. I'll still be online, but not quite involved. See you guys soon!
 
Excuse my huge ignorance on the issue...
but which part does it tell PHP engine what type it is?
 
I was reading @NikiC's link...
so basically, a range(0,1000) would contain 10002 _zval_struct's, correct?
 
why 2?
why not 1001?
 
0..1000 - 0 is inclusive, no?
 
9:49 PM
yes, which means that there are 1001 elements
0-10 == 0,1,2,3,4,5,6,7,8,9,10 == 11 elements
 
but the returned type is an array containing the 1001 elements
 
correct, so why 1002 zval structs?
 
1 array struct + 1001 int structs, no?
 
more than that, but now I see the additional struct
 
9:52 PM
I think so
 
I wonder why they didn't use variants...
I mean, a system that works like variants.
 
variants
?
 
Of course, you'd want to avoid that MS mess :)
Variant is a data type in certain programming languages, particularly Visual Basic and C++ when using the Component Object Model. In Visual Basic (and Visual Basic for Applications) the Variant data type is a tagged union that can be used to represent any other data type (for example, integer, floating-point, single- and double-precision, object, etc.) except fixed-length string type and record types. In Visual Basic any variable, not declared explicitly or the type of which is not declared explicitly, is taken to be a variant. While the use of not explicitly declared variants is not rec...
 
isn't that what a zval is?
the Variant data type is a tagged union
 
[
2 bytes - variant type
8 bytes - data length
]
 
9:56 PM
that's basically what a zval is (except with a few extra bits for references and the such
 
zval keeps a structure for each data type
 
@ChristianSciberras no it doesn;t
 
variant keeps 2 structures, fixed length data type, fixed length data size, variable length data.
 
typedef union _zvalue_value { <-- see union there
 
@ircmaxell well, I admit my understand of c is quite limited
@ircmaxell uhuh
@NikiC congrats on the article, well written and informative.
 
10:01 PM
@ChristianSciberras thanks :)
 
10:19 PM
Is there a way in PHP's DateTime to get the first / last date in the week (in format Y-m-d)?
$date = new DateTime();
$date->setDate(firstdayoftheweek);
print $date->format('Y-m-d');

Or do I have to check what day of the week it currently is and calculate the first / last myself?
 
10:44 PM
hello all
 
hi
 
@NikiC @ircmaxell I'm back!
 
@LeviMorrison wb
 
hi Charles
 
posted on December 16, 2011 by Matthew Turland

The wonderful folks at Engine Yard invited me and my friends and fellow co-authors Lorna Jane Mitchell and Davey Shafik to be guests on an episode of their PHP podcast with our good mutual friend Elizabeth Naramore as our host. We discuss our recently published book PHP Master: Write Cutting Edge Code, how SitePoint brought us together to work on the project, what it was like to write the book

 
10:58 PM
I'm ouit
 
ouit?
going to sleep, good night
 
@LondonBoy Hello
 
how are you how is your project going?
 
It is going. Aggravated right now that I can't type hint a generic object type that can apply to all objects. Very much wishing PHP was a more strongly typed language.
 
im sure you will sort it out soon
 
11:15 PM
@LondonBoy Well, I know what I'm gonna do. Just wish PHP was more OOP then it is and I'm not a big fan of dynamic typing.
 
are you busy now?
 
@CharlesSprayberry Welcome to the club.
What do you use PHP for, anyway?
 
@LeviMorrison Web development.
What else would you use it for? :P
 
:))
@CharlesSprayberry are you busy now?
 
11:48 PM
@CharlesSprayberry Well, I asked because java has some nice frameworks, such as Play.
PHP isn't the only thing for web development.
 
@LondonBoy Somewhat
 
ok i guess i worked out the occurencec thing
 
@LeviMorrison I've done a little bit of development in Java. However for all of PHPs flaws I really do like the language.
@LondonBoy great
 
I just hate PHP so much I started to love it :)
 
anyone heard of timthumb flaw :)))
 
11:53 PM
* Googles "timthumb flaw"
@London Not surprising there is a flaw, or that it is exploited when you think of the number of Wordpress installs out there
 
that's what you get when you use 3rd party plugins on 3rd party software. cough joomla
:-)
 
well it had a major flaw and a stupid one :))
 

« first day (426 days earlier)      last day (4522 days later) »