« first day (1007 days earlier)      last day (3932 days later) » 

Anonymous
10:00 PM
@DaveChen got it. @HamZa Yea, that was my question
 
I have a lot of private variables within a class that I want to dynamically create, but using the magic methods __get/__set, they are put on public. How can I work around this?
 
@DaveChen sounds broken by design. but an option would be to store them in an array instead of real properties
 
In context of regex it just "defines" something.
For example if you put backwardslash before d it will match a digit. It's the "syntax"
If you put it before another character that has or hasn't a special "meaning", it will just try to escape it
 
@DaveChen you can use the __get/__set to manipulate to set them in a private array.
 
@DaveChen Sounds to me like an object that knows too much
 
Anonymous
10:04 PM
@HamZa So, two purposes, matching and escaping ... that shouldn't be hard to remember
 
@Gordon watch your step, keyboards are precarious things to be on under influence
 
@Simon_eQ yup
 
The setup is loaded from an .ini file :)
 
I'm going to sgtop reading back things I type for the rest of the night lets see how that turns out
 
10:05 PM
not a good start
 
@DaveRandom i'm not stepping on the keyboard
 
:P and then all the private variables, methods, errors, are made
 
@DaveChen
class A {
    protected $attibs;

    public function __get($k){
        return isset($this->attribs[$k])?$this->attribs[$k]:"";
    }
    public function __set($k, $v){
        $this->attribs[$k] = $v;
    }
}
 
@Orangepill ctrl+k / fixed font
 
@Orangepill Select your code and press ctrl+k to indent it
 
10:07 PM
Thanks...
 
oops, not a reply, @room: is this method bad? (using ini files that is)
 
I'll never understand why people use __get and __set over regular accessors and mutators
 
@Gordon Inability to install an IDE/use copy+paste?
 
@DaveRandom no one needs stinking getters and setters anyway
 
Unnecessary runtime overhead ftw
 
10:11 PM
thanks, but isn't

$a = new A();
$a->hahahhaICanAccessYourPropertiesHahaha

possible?
 
@DaveRandom that as well
 
@DaveChen.... ohh you want to dynamically create private scoped properties.... don't think that can be done
 
...without reflection
which is definitely code smell
 
@DaveChen properties created on the fly are always public
 
it's bad practice I imagine if it were possible :)
 
10:14 PM
@DaveChen sure but it's dirty hackery
 
In general an class not knowing beforehand what properties it has is bad practice
 
(unless it's a dumb value object, in which case you may as well use a stdClass)
 
@DaveRandom or array
java has value object concept because their arrays suck
 
@tereško then it's not a value object
 
But I like T_OBJECT_OPERATOR. It looks prettier than square brackets.
 
10:16 PM
it's 1am ... those are minor details
 
yes! that's why I want to use -> as well, looks cleaner ... haha
 
It's two less characters to type as well
 
@DaveRandom wrong
 
oh too bad there's no dot notation
 
I thnk stdClass is just about the stupidest construct in php.... what's the point.... arrays should be able to be used with object notation and stdClass should go away.
 
10:17 PM
@DaveChen but you dont want to add weird code to your objects just because you can.
 
@tereško E_NOTICE
 
18
Q: When should I use stdClass and when should I use an array in php oo code?

JonGIn the middle of a period of big refactorings at work, I wish to introduce stdClass * as a way to return data from functions and I'm trying to find non-subjectives arguments to support my decision. Are there any situations when would it be best to use one instead of the other ?? What benefits w...

 
@DaveRandom you can turn off warnings, $array[yeah] :D
 
php 6.0 should introduce E_DOESNT_WORK and E_LOLWUT
16
 
I have to say I'd be much keener on stdClass if object literals existed
@tereško Don't forget E_PEBKAC
 
10:19 PM
so tl;dr array = dynamic, object = fixed :P to some degree I knew that...
 
@Gordon I'm in deceze's camp on this one
 
Also I'm pretty sure E_DOESNT_WORK should be E_DOESNT_WORKING
 
Mar 10 '11 at 13:57, by Gordon
class ItDidNotWorkException extends Exception
{
}
 
Damn it I deleted the gist
 
^ I might use that some day
 
10:20 PM
I had some code that used a YUNOMAEKSENSEException
 
... almost as if you have had to work with SOAP
 
I'd also like applications to throw PleaseSirIHaveADoubtExceptions
 
ok ok .. you have managed to beat it into the ground .. congratulations
 
@tereško I do have some code at work that throws a dBaseIsAShittyFileFormatException
 
J L
I'm parsing and storing survey data in a DB with PHP...unsure on what I want to make as a 'unique' key
I don't really want to require email address, I could do IP address but I haven't seen great example PHP for this
I don't want to have NO unique ID because that opens to easy XSS (spam submit button and flood DB with duplicate entries)
 
10:28 PM
you will need email based verification anyway
 
J L
@tereško why do you say this?
 
mostly, because that's my opinion
 
You don't want to use IP address because it's way too easily spoofed and people legitimately shared public IP addresses
Especially mobile devices, potentially thousands of valid submissions share an IP
 
J L
if there's low risk for XSS...is it best to just have no unique ID and just manually remove flood data if it occurs?
 
@JL don't write it yourself. use surveymonkey or similar COTS.
 
J L
10:30 PM
@Gordon too late ;)
@Gordon Survey also serves as a code base for future resumés
 
@JL just use email address and require that filter_var(FILTER_VALID_EMAIL) passes if you don't want to have them actually validate submissions with an email confirmation
And log the IP (accessible via $_SERVER['REMOTE_ADDR']) so you can find bots more easily
Or just rate limit by IP
 
J L
@DaveRandom yeah I think this is best...even if the checks aren't foolproof, it's better than having nothing
 
@JL or just set a cookie
 
J L
@Gordon as in, a 'hasFilledOutSurvey()' cookie?
 
10:35 PM
That doesn't really help much IMO
 
@Gordon that's kinda for preventing a non-too-smart secretary from gaming the system
 
@JL yeah, I mean, its not like trashmails are hard to get
 
J L
@DaveRandom do you know if FILTER_VALID_EMAIL is the same filter twitter-bootstrap uses for it's email field?
 
anyway ... time to have a naps
 
@tereško believe me, after a few months moderating SO you know that emails secure nothing ;)
 
10:36 PM
The concern would be bots, and they could easily just not bother with handling cookies at all. In fact your average script-kiddie would accidentally circumvent that because they don't even understand cookies
@JL I highly doubt it
 
J L
@DaveRandom It's a minor issue, just worried about things passing bootstrap validation but failing PHP validation
 
All that does is validate that the email address is syntactically valid, and a lot of stuff would pass that you might not expect to
 
@Gordon it's not about the prevention but about detection .. SO has quite different focus
 
@JL That's pretty unlikely
 
@DaveRandom I'd put foo@example.com like I always do.
 
J L
10:38 PM
Ok thanks guys...I'm on the final stretch before launching my website which still has no real clear vision/goals yet -.-
 
But email is a bit of a moving target. There are at least 3 IETF-endorsed specifications for the format of an email address that I know of, all of which aren't even internally consistent
@JL You need more cats
 
J L
@DaveRandom I need more cats and less wordpress
 
Even if you have no Wordpress at all you need less of it.
 
J L
^
 
J L
10:44 PM
do you all write your own login systems for your websites or do you use third party packages?
 
@JL I've started using the Zend ACL for, er, access control framework.zend.com/manual/2.2/en/modules/… but still roll my own login with openwall.com/phpass
 
J L
@Danack what does phpass offer over the standard crypt() method?
 
you can pronounce it as PHP - ASS
What more do you need?
 
"[\"]'yo.mama\"]"@. is a valid email address that fails FILTER_VALIDATE_EMAIL
It turns out that it doesn't understand that concept of the root domain
 
@JL Seriously though, phpass works on pre-5.3.7 and does the salting of passwords correctly, and is portable to other libraries that use the same algorithm.
 
10:54 PM
Also "rm -rf /"@whatever.com is a valid email address
(that I am now configuring my mail server to handle :-P)
 
The salt is stored in the same string as the hashed password along with the encryption version, so you don't need to store extra fields.
 
☑ listening to Cold Cold Rain while (somewhat) drunk
 
@JL but Mr irc maxell would probably recommend his library https://github.com/ircmaxell/password_compat
yeah @DaveRandom butpassword_hash (PHP 5 >= 5.5.0)
 
J L
@Gordon check this one out: youtube.com/watch?v=Yv112E2a8_0
 
10:58 PM
@Gordon I'm on the Manics now, Danzig doesn't fit the flow damn you! /shakes fist
 
@JL that aint a good tune to listen to while somewhat drunk. the danzig is because he sings it like he was drunk
@DaveRandom I will change to katzenjammer now. a rocknrollband
and then to alestorm
 
I might have another go at setting up a proper streaming channel now I have the upload bandwidth to handle it
 
@DaveRandom it's easy with soundrop on spotify
 
I don't want easy, I want 100% self-rolled
I wrote a flac impl in VB6 once. That was a waste of time.
 
now Nancy. shanty ftw!
 
11:05 PM
There aren't nearly enough hard rock bands that make use of accordions
 
swaying alone is boring :(
@DaveRandom there are but most of them play neo-tango, like gotan project or bajofondo
 
@Gordon Where's the wife?
 
@DaveRandom bed
 
softcore
 
i wanted to be in bed too but cannot let the vodbullmeister go to waste
 
11:10 PM
@Gordon You want to get yourself a 2 year old, mine danced the whole way trough Incubus' S.C.I.E.N.C.E. last weekend
 
@DaveRandom I got a rougly 2 year old right above my head and two about 1 year old right beyond the wall. no thank you :)
 
Hi all, what's the best way to convert a string containing date and time from one timezone to an other? I think I'm doing it the wrong way.
 
28
A: Timezone conversion in php

GordonYou can use the datetime object or their function aliases for this: Example (abridged from PHP Manual) date_default_timezone_set('Europe/London'); $datetime = new DateTime('2008-08-03 12:35:23'); echo $datetime->format('Y-m-d H:i:s') . "\n"; $la_time = new DateTimeZone('America/Los_Angeles'); ...

 
Cool ok this was also my approach, so wasn't wrong after all :D Thanks!
 
last song for today to come down before bed: youtube.com/watch?v=A-jjmPn837A
 
11:18 PM
 DateTime::createFromFormat($inputFormat, $inputTime, $whateverTimzone)
  ->setTimezone(new DateTimeZone($newTimezone))
  ->format($outputFormat);
horrible fluent interface is horrible
 
So I have no idea what I really threw together here pastebin.com/UxJDZtRs but it works as far as I can tell. However, it looks horrible, is there a better way to do this? It basically determines the type of question. The tricky part was the auto-delete questions.
 
@crypticツ What's your data source? The backlog?
 
$resultRow is an item entry from the SE API response
 
Well yeh, but what's your filter? How do you know there's and outstanding vote of some kind on it?
Also, and arguably a lot more importantly:
(it's a slow starter but it's totally worth it)
 
@DaveRandom not sure what you're meaning. That code is what is currently filtering the questions types. based on the fields present in the response and their values.
 
11:33 PM
@crypticツ Ahh right so it's just unfiltered? So essentially you assume that all questions start in a state of ?
 
yeah, because I also fetch un-cv'ed questions with a negative score count of two or more
 
(which is fine, btw, just trying to understand the logic)
@crypticツ Right, so that's your filter then :-P
Yeh it's looks fine to me
 
it's incredibly difficult to read, and I really don't like having to use $continue
 
I'd wrap that in something isolated though since the logic behind all this stuff on the SE side is pretty fluid
@crypticツ Yeh that's kind of horrid but if you don't you'll end up repeating yourself so it looks like the DRY solution
You seem to be into your Yoda conditions, personally I find those hard to read although that's very much personal preference
 
@DaveRandom they're just like PHPUnit assertions
 
11:41 PM
@igorw I dunno, there's something different about it when it's on the left of the opening paren
 
11:55 PM
weird... trying to crawl a web page and it replies with a 302 when I use curl, while with 200 when using the browser O_o
 
@Ocramius User-Agent: ?
 
@DaveRandom filtering it out in the browser doesn't change the results...
I'm starting to think that my cookie jar may be broken
 
Possibly E_INSUFFICIENT_BLOOD_ALCOHOL_LEVEL then
 
also very true
 
@Ocramius Have you verified that filtering it out actually affects the request being sent? Long shot but it could be a browser bug causing that config to have no effect
 
11:59 PM
according to firebug nothing is going through
sending Host, Connection and Cookie
 

« first day (1007 days earlier)      last day (3932 days later) »