« first day (1119 days earlier)      last day (3845 days later) » 

10:00 PM
@JoeWatkins Can you help with the pecl question above?
 
@JoeWatkins come to irc, we're talking too much hereā€¦
 
6 mins ago, by Madara Uchiha
How do I return HEAD to the current commit after git checkout 0a1b2c3d?
Anyone? :P
 
another - friday evening - question. do you all say PEAR is: "dead", "badly maintained", "should be replaced by composer"? (I still like it, good old friend. Am I the only one?)
 
@Nadeem What are you still confused about?
 
@Nadeem Sorry, not noticed that was link to a question. In example is using constructor.
 
10:03 PM
to refactorying that class
 
@Nadeem Better create a class without static methods.
You also can't use singleton, because your constructor gets params
 
:p
 
@Nadeem Ok, 1) You're mixing your calculation logic and output, don't. 2) You're hard-coding things like Canadian/non-Canadian calculations into an otherwise "generic" purpose class, don't. 3) You've already got magical Context and Cart classes, stop.
 
@MadaraUchiha rebase? i'm a newb in git too. XP
 
4) You've got { } delimited blocks for an if, but then don't have them on the else; you're going to confuse the shit out of yourself or someone else; don't.
 
10:08 PM
@reikyoushin Thanks, worked.
 
@MadaraUchiha seriously?
 
i thought i just remembered that.. but i'm 50-50 haha. LOL
 
5) Why are you using a constructor on a "static" class? In languages that support static classes, typically instance constructors are forbidden. All static, or no static; preferably no.
And, I'm done.
 
thx Dan
 
10:13 PM
phew, the storm has passed.. literally. now i gotta go home. bye guys!
 
10:35 PM
@AlmaDo around?
 
yes
but in half-sleep mode :p
 
So I was fiddling with levenshtein earlier and noticed that it doesn't factor in string length if the comparitive length is the same.
ox to oo is the same similarity as oooooooooooooox is to ooooooooooooooo
 
yes it is
 
Also thought about the variations of replacements. e for 3 and 4 for a etc.
 
Is libxml included on PHP 5.4.16 ?
 
10:37 PM
levenshtein allow symbol appending/deleting. so what?
no, I doubt
 
@AlmaDo from a matching perspective it's a bit painful.
 
with distance <=2 only 2 length difference is possible
 
f4b13n vs fabien would be a 3 match
 
1 min ago, by HelpingHand
Is libxml included on PHP 5.4.16 ?
 
@HelpingHand See where it says "1 min ago"? Yea, don't spam.
 
10:39 PM
But I would want/need that to be a match.
 
yes, L(f4b13n, fabien) = 3
@Fabien simply allow 3 distance
 
@DanLugg Sorry, but I'm in a little bit of a rush... Do you know?
 
@HelpingHand I know that the manual should tell you.
 
that will increase list from 1E5 to 1E6
 
Which do you think makes more sense?
 
10:41 PM
however, both are insignificant
 
abstract class Controller or interface Controller?
 
@AlmaDo f4813n I know it looks horrible but this is another needed match.
 
how so?? its nothing common ..
 
@MadaraUchiha Depends; would the base have behavior?
 
Just what I'm wondering :P
 
10:42 PM
huh.. may be add exceptions then to short-list generation function
 
@MadaraUchiha I think it may make sense to have both; an abstract Controller and ControllerInterface. The Controller implements the ControllerInterface and provides base behavior for the system, however if someone wants to write a whole different implementation, they're able to do so with the ControllerInterface.
 
@AlmaDo but I wouldn't want f4b17n to be a match as a 7 wouldn't be an easy replace of e
 
Interesting
 
@Fabien if such is possible, then levenshtein is not your case...
 
Currently I'm the only guy on the project (and it's a side-project I made myself), but if I ever get more guys on it, this might be a good idea to have
 
10:45 PM
@AlmaDo This is kind of what I was thinking. I like the approach though.
 
@Fabien i was panning to create generator function for you for given max. levenshtein distance, but now I am not sure you need it
 
@AlmaDo I would've been forever in your debt :)
Tis confusing.
 
but its not your case..
 
Yes :P
 
@AlmaDo A generator function?
How does a generator/iterator apply in this case?
 
10:47 PM
@MadaraUchiha The plan is to take a string and find all potential variants of that string that are similar to it.
 
if you need that 'potatoes' will be similar to 'space ship' .. I am not sure how to do so
 
reason being say I have fabien.com
I have a table of every .com available and I want to see what similar domain names are registered
 
@MadaraUchiha no .. you're missing huge context .. nothing common
 
@Fabien Hmmm
Each letter should have its possible permutations pre-set
 
@AlmaDo Had the good idea of creating a list of all possible variants and then just searching for them in the DB
 
10:48 PM
it is not about PHP generator (or not only)
 
@MadaraUchiha Yes, this is what I was thinking $variations['e'] = array('3');
 
(as in [/*snip*/, "t" => ["7", "+", whatever], /*snip*/])
@Fabien Yeah, that's how I'd do it
 
its very easy task with levenshtein .. but not with described non-similarity
 
@MadaraUchiha Problem is I sincerely doubt I am smart enough to figure out how to do it :P
 
@Fabien Run against all the permutations?
 
10:50 PM
I'll do sample later
 
A nested loop should easily do the trick
 
@AlmaDo that'd be great thanks. Even if it's not the answer used it's a great learning opportunity.
even if it's psuedo
 
(Perhaps not as efficiency as an iterator potentially, but if you're looking for a quick&dirty...
 
@MadaraUchiha All potential variations, like a number lock.
 
@Fabien Hmm?
 
10:52 PM
fab f4b f48 fa8
 
Hold on..
 
@DanLugg I searched up this in the manual, and came up with this: In PHP 5 (updated PHP 5.0.4), the following changes exist. Built in: DOM, LibXML, Iconv, SimpleXML, SPL and SQLite. And the following are no longer built in: MySQL and Overload. ; however, my php.ini file does not say libxml anywhere: pastie.org/private/tt2qgkgq4ns0hezctwdsaq
 
@HelpingHand Do a php -i | grep "libxml"
 
@DanLugg In cmd.exe? (windows xp)
 
Yep Wait; that prolly won't work.
Just make a phpinfo() dump.
@HelpingHand Is the problem that it's not working?
 
11:03 PM
Yeah... this is what I came up with in phpinfo() dump: libxml
libXML support active
libXML Compiled Version 2.7.8
libXML Loaded Version 20708
libXML streams enabled @DanLugg
 
Heh, turns out to be slightly trickier than I thought, @Fabien
 
@MadaraUchiha lol I'm glad you said that. If it was easy I would feel dumb. :)
 
I'm assuming that's it because this code won't work: pastie.org/private/5qlk8d8zb3hxu7xcjsy5w @DanLugg
 
@HelpingHand By E_DOESNT_WORK, you mean ...?
 
see ya later
 
11:09 PM
lolwtf? I have a NetBeans project with different names for the project name, run-config path, and local path...
 
Does not echo anything when ran. I was thinking it was libxml because I could not find this anywhere on my server. Is it something else?
@DanLugg
 
@HelpingHand 1) Use var_dump in lieu of echo. 2) Enable all error reporting, etc.
 
Will somebody give me their opinion on this please codereview.stackexchange.com/questions/34078/…
 
11:18 PM
@DanLugg Changed echo to var_dump; however, my code still will not produce the contents of the div. It merely displays: object(DOMNodeList)[3] no matter what the div's id was set to in the code.
 
@HelpingHand Well, that'a different problem. At least you know that libxml is loaded and working.
 
Yes. I guess that's good. However, am I correct in saying that the code I'm trying to run will print the contents of a certain div (singled out by id) to the screen using xpath? @DanLugg
 
@David "Is this a good or bad idea?" Personally (and I know a lot of people out their disagree), I don't think objects should be responsible for validating themselves. Not only does it violate "SRP" but it just leads to lots of business code inside an object.
And you end up adding more and more code to the object to cater for different scenarios - which is an obvious sign of a problem with your code.
 
@Danack I always thought an object should be able to validate itself at any time though? Check is the data within it valid playing by the rules
Well more specifically a "domain object/business object"
 
e.g. from your example - what happens when someone comes to your website, and you want to allow them to shop for stuff before registering as a customer. You would need to add more code to allow that to happen.
@David "Check is the data within it valid playing by the rules" Meh - I prefer to have them separate "Apply these rules to this data object - and tell me if it's valid".
Then I can swap in different rules as needed
 
11:30 PM
@Danack That setCustomer() was a bad example though. A check like that would usually be done in a service
 
@David no - it is a good example. that the object should just be for storing stuff, and that letting it know about any business rules is bad.
 
@Fabien even trickier than I thought I thought :o
Worth asking a Stack Overflow question about it
 
@Danack But say for example you have a User domain object, it has $username, $password, $confirmPassword properties. When you do $user->setUsername($username)...etc don't you always want them be obey the same validation rules? Setting the username on registration and setting it when logging in and setting it when updating account details? Have that validation rules in the setter for that property ensures this
 
@MadaraUchiha good idea
 
Post a link here afterwards, I'm interesting in seeing what people can come up with
 
11:34 PM
@MadaraUchiha sure, any title suggestions?
 
@Danack Like you would always want usernames to be 3 - 16 characters long maybe and only contain a-zA-Z0-9_
 
"Generating an array of all variations of a string with specified replaceable characters"
 
> How to get all the similar strings based on an array of letter variations?
 
@David "etc don't you always want them be obey the same validation rules?" No, not all the time. Although the times when they change are few and far between when it happens it's a real pain in the back side.
 
Yeah I like yours
 
11:35 PM
If those rules are stored in the setter for a username you can never go wrong I think and the data will always be correct
 
e.g. say you are letting people signup for your website with an email address as the username. After a while you want to allow people to signup with a Google ID or Oauth or whatever. You then need to split the class that does the validation from the user object.
 
@DanLugg I've been searching for the answer that gave me this code. Here it is: stackoverflow.com/questions/6491598/…
 
The one that made me think like this is that at my last company, I put the validation on the user object, including that the user signed up with a valid email and phone number. (It was for a service that used the users mobile number).
What happened was that the sales guys came along and asked for demo accounts to be able to give to customers for them to be able to try out our platform.
Of course the screen where admins were able to create user accounts had the user validation using the same rules as the end-user signup process.
which meant that the demo accounts needed a real number - oops, we don't know what the mobile number is of the client, so we can't set that.
And needed an email address - oops, we don't want the system sending him any emails before the sales meeting - can we leave the email address blank.
If I'd had the validation separate from the user object, and instead had the validation attached to the form used to create the user account, that would have been trivial. Instead, it took ages.
So I now I create re-usable validation rules, and then attach them to the forms where the validation needs to occur.
Which means I can re-use validation rules across my app, but where needed I can swap them out for a different set of validation rules.
 
@Danack Basically a validation class with a validate method?
 
@Danack I get you. And do you have any duplicate validations rules anywhere?
 
11:43 PM
But that scales really badly when you need to validate multiple domain objects in multiple ways, does it not?
 
@MadaraUchiha Well - "Zend-validator" and then it's attached to the forms.
 
@DanLugg You get my last 2 messages?
 
@Danack What about just being able to detach validation rules if needed, like in the admin area you were talking about?
 
@Danack I don't like the idea of a validation class. Do you manually set it all up and map properties or does it use reflection?
 
11:45 PM
@David "do you have any duplicate validations rules anywhere" TBH, yes, but only because I haven't gotten round to organising them properly yet. I should declare them once, and then insert the appropriate rules, rather than the hack job I hack job I have at the moment.
 
@MadaraUchiha Did you check out what I posted a minute ago? I need another opinion of it before I go and possibly ruin my current code with it
 
@David I set it up on the form. And then insert the appropriate form to the web page controller to be validated. So this is what a form definition looks like: pastebin.com/b9ar8sck
 
It may be genius or it may be terrible
 
@David Nope, link?
(You can link to a message via "permalink" in the menu)
 
11:47 PM
And then the controller that processes the form looks like:
 if ($this->linkEditForm->useDataAvailable() == true) {
            $valid = $this->linkEditForm->validate();
            if ($valid) {
               //Get the values
               //Save it to DB
            }
        }
        else {
            $this->linkEditForm->addRowValues('new', []);
        }
@MadaraUchiha "that scales really badly when you need to validate multiple domain objects in multiple ways" I've not really encountered a problem with it yet, and can't really see a problem.
 
@David It would make more sense to me if you had a bindValidation($field, callable $function) method that adds the validation rules dynamically.
No validation for a field means it's always passes validation.
Rather then hard-coding it in, like you do now.
 
Just noticed @hakre answered an old-old help vampire questions of mine. ;) Cheers @hakre
What a noob I was.
 
@Danack I get you. I don't like handing the validation job to classes outside of the model layer though. I made my own sort of form validator class a few years ago. It worked but it was the messiest code I ever wrote I'd say
 
@David Yes - it's one of those things "How hard can it be to make a form class" 5 MONTHS LATER..... WHAT HAVE I DONE!!!1!
 
@Danack Well, you need a class per validation per domain object
 
11:53 PM
@MadaraUchiha I like the 'callable' type hint. Never knew of that in PHP. How would I use this bindValidation()?
 
If I have an old question where the answer was simply "it's not possible" what do I do with it?
 
So given your example with the user, say he has email, phone number, name and ID
 
@MadaraUchiha Which is no more work than putting the validation inside the domain object.
 
If I want to be able to fake it, you'll need 4 (!!) additional classes.
@David Hold on
 
@Danack Yeah after a while I actually got lost in it and did not know what was going on in there anymore. But it seemed to validate correctly so I was somewhat happy
@MadaraUchiha Ok
@Danack It was validating but it was doing some crazy stuff along the way
 
11:56 PM
@David Well, that's why I'm using the Zend Validator classes - they work nicely. The Zend Form classes don't...
 
@Danack I have not used any Zend classes before. I tried Symfony2 recently. Did not like it. So I am back to creating my own stuff
 
anyone famillair with wordpress?
 

« first day (1119 days earlier)      last day (3845 days later) »