« first day (664 days earlier)      last day (4284 days later) » 

12:04 AM
))
You know what, Kohana documentation is great)
Well, time to take horisontal position, bye
@Corbin
 
12:57 AM
can a class's properties be assigned on the fly? e.g.
class aClass {
private $attributes;

public function __construct($attributes) {
foreach($this->attributes as $a => $v ) : $this->$a = $v; endforeach;
}

public function __get($attr) {
if(!$this->$attr) throw new LogicException(); return $this->$attr;
}

public function send_email() {
$mail = new PHPMailerExtension($u->email);
return $mail->Send() ? true : $mail->ErrorInfo;
}

}
 
@dyelawn ...? which line are you talking about when you say e.g.,
 
Have you actually ran into a problem with this code not working?
Although, I don't think you should be letting calling code to just set whatever properties it wants...likely to lead to some kind of maintenance problem
 
@Nile i think all lines are dependent on one another, but in terms of "does this cause an error?", i guess the send_email() function.
 
@dyelawn which error?
+ is $mail->ErrorInfo a function?
and where is $u?
 
$mail->ErrorInfo is a property of PHPMailer, which is a parent of PHPMailerExtension
 
1:06 AM
$u?
 
Well, there's a bunch of things about send_email that are, honestly, wtf? Where does the body of the email come from? Where does $u come from?
 
An error like "property does not exist" rather than an Exception thrown by the __get()
$u should be $this
apologies
 
@dyelawn is that the problem then?
 
user895378
@CharlesSprayberry lol nice gravatar. Not excited about football season at all, are we?
 
user895378
Makes me want to whip out the "Randy's Rant" youtube video :)
 
1:08 AM
@rdlowrey I cannot wait for football to start. Been waiting for like the past 2 months.
It is weird because for like 20 years I was living in Alabama, where we take college football seriously. Now I live in Jersey and most people are "College Football? Huh?"
 
@Nile right now there is no problem; just trying to make sure that what I'm doing is the best design option and will accomodate Exceptions properly instead of killing the script
 
@dyelawn and also in the __construct, why are you treating $this->attributes as an array? there's nothing in it, you only define it
 
user895378
Yeah, I definitely just watched some preseason NFL on ESPN -- I'm a rabbid football fan ... college and pro.
 
@rdlowrey Hells yea. Favorite teams?
 
user895378
I'm a big time fantasy football geek. Love it.
 
1:09 AM
private $attributes = array();
 
it's just privates $attributes;, there's no array()
 
I'm getting more into pro ball. Not nearly as much as college though
 
I typed that code into the comment input, it should say private $attributes = array();
 
@dyelawn anyways, I have to go. you can think about reworking it if you want, but if it works...
 
user895378
I have degrees from Clemson, so they're my college squad. I don't have a serious NFL team, but I really really get into fantasy football.
 
user895378
1:10 AM
Fantasy football makes NFL way more fun.
 
Jumping in this conversation. Went to Florida from 2005 to 2009; if i hadn't been a college football fan when I arrived, I would have been by the time I left.
it works for like 4 cases
I just want to make sure that I'm not setting myself up for huge problems, or if there might be a better way to handle what I'm trying to do.
 
user895378
I wonder if there would be enough regulars in PHP chat who were "football people" to launch a fantasy league. That could be fun, but I'd be surprised if there were enough people.
 
@rdlowrey Clemson is getting better. I thoroughly enjoyed y'all beating Auburn last year and hope y'all beat the shit out of them on the 1st.
 
And I guess I didn't really say what I was trying to do: create a "People" class, for lack of a better term, that's a catch all for implementations of classes associated with people, i.e. Contacts, Users, etc.
 
@rdlowrey Yea, I highly doubt that. So far of all the programmers I know you're only the second person to be a football fan
 
1:13 AM
whenever i hear of a programmer liking football, my reaction is always "whaaaa?" :D
 
user895378
@CharlesSprayberry Yeah, I'm definitely going into this season as "irrational expectations guy" as far as my football fandom goes.
 
user895378
Well, if you attend college at a large school in the southeastern US it's pretty difficult to avoid becoming a football fan if you weren't already.
 
@rdlowrey Clemson has a good coach, I like the guy. Also, a 10-4 record is pretty damn impressive imho
 
@rdlowrey especially when your school wins two NCs while you're there
 
@rdlowrey Hell, you don't even have to go to the school in Alabama. When you're born you are basically branded Alabama or Auburn.
 
1:14 AM
i go to a large SEC school and am completely neutral towards football lol
 
@Corbin Mississippi State?
 
nah, univ of arkansas
 
user895378
lol @ bobby petrino ... what an idiot.
 
yeah.... lol
 
1:15 AM
was definitely a "seriously?!" moment
 
Although really I shouldn't laugh too hard...Alabama had some pretty fubar coaching moments in the 90s
 
should be entertaining to watch him cry in a bunch of interviews over the next month or so while he's job searching
 
eh all big schools have had some fubar coaching moments
 
user895378
Yeah. I'm convinced the neck brace was just for show.
 
money, power and mild fame never end well lol
 
1:17 AM
@Corbin This is true but man I love Nick Saban. A NC drought for 17 years and then 2/3?
ROLL TIDE!
 
@rdlowrey forget a Fantasy League for PHP devs, that's trite; you should start a contest for development of a predictive analytical model.
 
@CharlesSprayberry then there's arkansas' recent coaching history.... x.x
@dyelawn i had a professor last year who did a side research project of just that
 
user895378
@dyelawn I don't know -- I run all sorts of linear regressions on nfl stats I aggregate with php scripts. I'd bet programmers who do fantasy generally get pretty serious with that kind of stuff :)
 
it's apparently a lot more accurate than teh official prdections
 
@Corbin which official predictions? bc a lot of them are crap that become profitable from good marketing.
 
1:19 AM
eh i dont remember
not much ofa football follower myself
 
There are a lot of good aggregating resources out there (e.g. Football Outsiders), but nothing that's really reactive
 
but was in a class where we had guest lectures for a few weeks that talked about their various research projects
it was quite interesting, but my memory is terrible
 
user895378
One of my pet projects is running regressions on major league baseball data with the goal of predicting game outcomes against the spread. I have models that consider every pitch thrown in MLB over the last 15 years. I can currently predict about 57% of games correctly against the spread. If I can ever get to 60% I'm dropping everything and going to Vegas because that's the line I need to make serious $$$ :)
 
really anything over about 53% could make serious money if you were wiling to risk some huge base money
 
@rdlowrey That. is. awesome.
 
1:21 AM
@Corbin not grilling, just curious. I've used a lot of the things that were probably mentioned in those lectures and been irritated with their shortsightedness. This was years ago, before I started trying to learn to code (like 18 months ago)
 
@rdlowery my NFL model was at 54% last year, and it was built in Excel.
 
@dyelawn didn't think ya were grilling. i wish i could remember more though. it was quite a detailed project. he's been doing it 4 or 5 years. tried to find any thing about it on his website but im failing at google today
 
user895378
@CharlesSprayberry Well, having studied math and econ in college that sort of thing is right up my alley. Baseball is perfect because there's so much data. Football is so much tougher to predict consistently because you have such a small sample size.
 
1:22 AM
needless to say there is room for improvement in a lot of areas, especially the incorporation of data from different sources.
 
user895378
I'm really interested in aggregating metrics from google about search trends as a potential input into my baseball models.
 
@rdlowrey Yea, that's true. Clearly I need to work on my math skills.
 
@Corbin prefer to think of it as google is failing at providing useful information every day for the last 3-5 years
 
@dyelawn found it. was misspelling his name lol. faculty.ineg.uark.edu/cassady/Ranking%20Stuff.htm
no idea if it's good in the big scheme of things. freshman-corbin was easily impressed lol
 
user895378
I think sites like hometown team blogs and what not can be ahead of the curve on injuries and what not and if you can capture that data even a little bit throughout a season it can make the difference of 57% to 60% accuracy ... which can mean millions of $$$ if you can do it right.
 
1:24 AM
@rdlowrey you just need to adapt which datasets you're incorporating; make the samples bigger by using things like year-to-year changes instead of week-to-week
 
user895378
I'm not incorporating outside data sets -- I'm generating all of my own data. I know everything about every pitch, where it was hit, where it was located in the strike zone, etc. already.
 
@rdlowrey Yea, I can definitely see that. I know a lot of people who would put my Alabama fandom to shame. Disclaimer, I have a "Roll Tide Roll" tattoo on my shoulder.
 
a tattoo? damn, that's some football love.
most extreme i get is a T shirt :)
 
user895378
Anyway, gonna go catch the new Total Recall movie. Hope it doesn't suck :) Catch you guys later.
 
bye
 
1:26 AM
On that note the frau and I are going for a walk, see ya later fellas
 
cron: $local_blogs = $team->blogs; foreach($local_blogs as $blog) : $src = $blog->get_latest_stories(); if($blog->regex_check($team->key_players)) $predictions->update($src); endforeach; ?
 
i should head off too lol... needa work. later everyone
 
user895378
<massExodus />
 
@rdlowery i was talking about your issue with football prediction above, not bball. enjoy the worst movie ever, though :).
 
Can someone tell me why this isn't working?
 
1:28 AM
@AlexCastro What's not working ?
 
Everything works except the INSERT
The INSERT was working earlier today but I was showing it to someone and now it doesnt work. It even shows me the "Success!" I set up after the INSERT.
 
@AlexCastro did you change anything in the page or relevant to the page (such as database stuff)
 
Nope
Not that database, nno
 
Why are you grabbing things from GET and POST?
 
@Chris the get pertains to which class the user is actually viewing, while the post is for a form
 
1:31 AM
unsolicited side note: you have a few minor things wrong with your code:
- you shouldnt assume that array keys are set on $_GET/$_POST
- you shouldn't append to a variable that isn't declared yet ( .= is a notice if the var doesnt exist)
- you need to escape things when you echo them back into html (htmlspecialchars)
and now im back to lurking... :)
 
The GET might be the issue
I'll check that, thanks
 
You check if($_SERVER['REQUEST_METHOD'] == 'POST') {, wait until after that check to even bother trying to grab the values. If you're in "post mode", you don't need or even care about the GET, and vice-versa
 
on the class page, you can make a hidden field to submit the classid as post data
 
@Chris get data is often relevant when processing post data.
 
you're not catching the error at the right point. it's not referring to whether or not the statement executes, just to whether or not the request is valid
 
1:33 AM
@Corbin Can be, but it didn't appear to be in that code... skimming
 
@Chris ah ok, thought you were talking about all of the time, not just this script :)
 
if($query->execute()) : echo "success"; else : echo "failure"; endif;
 
are any of the columns: course_id, title, description, unique?
 
btw @AlexCastro wherre is $classname being defined?
@dyelawn endif style conditionals make me cry
 
$sql = $db->prepare("SELECT * FROM courses WHERE id = ?");
$sql->execute(array($classid));
$row = $sql->fetch(PDO::FETCH_ASSOC);
$classname = $row['name'];
That's classname
and I know that works cause the appropriate class name is being echo'd
 
1:35 AM
easier to type correctly in a comment box than a ternary operator
 
but then people might start using it
then again, i just have a weird hatred of endif and endwhile style blocks :)
 
echo $query->execute() ? "Success" : "Failure";
actually seems easier
 
no one should be using anything that i type in a chatroom in practice.
 
Thoughts on double-quotes for all strings? I use single quotes and concatenate variables as an iron rule, personally
 
unfortunately people dont think that though, @dyelawn
 
1:36 AM
I never, never never never use double quotes in code, ever
 
@Chris stop being silly and wasting time worrying about that. it barely matter.
matters*
 
No, I wasn't bringing it up as a big deal, but as a convention
 
@Nile i'm new and self-taught; often confuse the colon and question mark when typing quickly, can't help it.
 
ah ok
 
Like 1TBS vs Allman for indentation style (I am 1TBS strict)
 
1:37 AM
i prefer the look of interpolating more when possible, but after escaping and everything comes into play, concatenation is usually more common in my code.
 
I found the glitch, guys
addhomework.php?id=1
 
but no one else has really addressed my assessment of the process error in Alex Castro's code, pretty sure that's what's causing the disconnect between his output and his understanding
 
@Chris I use double quotes unless I really need single quotes
 
if ( empty($classoid)) {
$errors .= "<li>A class isn't selected!</li>";
}
It echos that. so no class is being gotten.
 
class**o**id
whoops didnt bold
 
1:38 AM
Especially if I am building HTML strings, because I arbitrarily always use double-quotes for property values in HTML
 
god damnit classoid
 
i extremely rarely build html inside of php
 
@Corbin still breaks with classid
 
I don't either. My biggest project uses smarty (old design choice), but now I think I would favor php template style
 
@AlexCastro :(
 
1:39 AM
So can anyone tell me why $classid = $_GET['id']; returns empty for addhomework.php?id=1?
 
@AlexCastro that (inefficiently) checks if the class exists, but you're still going to return a success message on an unsuccessful database operation
 
@AlexCastro What is your error_reporting set at?
E_ALL or go home
 
@Chris yeah, i definitely prefer just using php as a templating language. smarty and whatnot are just excessive.
 
lol nonothting, haha
 
Bro
 
1:41 AM
haha there should be a disclaimer for this chat: "If error_reporting isn't maxed out, go away."
 
quick command to turn it on?
 
Your error reporting could be giving you the answer instead of coaxing it out of the chat room
 
I thought it was on by default
 
i've been thinking about writing an article called "why does everyone suck at debugging php?"
but... im lazy
 
@Chris no wonder, i keep asking him where his errors are coming from, they're not turned on
 
1:42 AM
and that's the answer to your first question
 
@AlexCastro error_reporting (E_ALL);
 
i like include_template($file, $args); for HTML, where $file is an html file that relies on PHP for nothing but values contained inside of html elements. it makes design/dev cooperation a lot easier.
 
error_reporting (E_ALL) or go home, make it the tag line!
 
@dyelawn yeah, i do something sort of like that too
 
1:43 AM
What's the best way to handle user objects, how would I prepare it for the view?
 
error_reporting(E_ALL | E_STRICT); for God Mode
 
E_ALL | E_STRICT
 
:p
 
god mode? more like non-shitty code mode
but....
<-- picky :D
 
error_reporting(-1) for everything
 
1:44 AM
It's having a problem with my errors .=
 
the idea of letting the core silently convert that to an unsigned int with all 1s though makes me cry
undefined behavior through 5 layers of indirection is horrible
 
@Corbin it's not converting it to an unsigned int
 
it essentially is in engine-land
i would hope so anyway... for bitmasks
 
"It's having a problem with my errors .=" <-- That would be the nature of errors. Rename them features and you're done, son!
 
1:46 AM
I have a line called: errors .=
Lol...
 
@Corbin When I started coding, I made a class for HTML elements, whose two properties are attributes and contents (which can be an array of other elements, a text string, etc.), and extension classes for each element. May have been very unnecessary, but I still use them.
 
@dyelawn hrmm... could definitely get excessive, but if it works well, then it works well :)
 
@ircmaxell can i get your opinion on the question i asked when i showed up? can/should properties be created in a class constructor?
 
anyway, i shall stop being a pedant now. gotta go work
 
@dyelawn Have you ever looked at the wonderland of DomDocument, then? You could cover yourself in oil and use it to template, that would be sooo deliciously, decadently excessive.
 
1:48 AM
@dyelawn I can't answer that question.
 
A vague question cannot be answered properly
@Chris why? It's actually very well designed...
 
class aPerson {
private $attributes;

public function __construct($attributes) {
foreach($this->attributes as $a => $v ) : $this->$a = $v; endforeach;
}

public function __get($attr) {
if(!$this->$attr) throw new LogicException(); return $this->$attr;
}

public function send_email() {
$mail = new PHPMailerExtension($this->email);
return $mail->Send() ? true : $mail->ErrorInfo;
}

}
 
@ircmaxell For a even a moderately complex page, the number of object instances would cause a slower rendering time that a straight-up php template or even smarty.
 
Do you guys know how I can add values to a variable without overwritting it? Before if I set all my errors to: problem .= "warning message" if I echoed $problem it would echo all the problems, not the last one, now I do = and it only echos the last one.
 
1:49 AM
If you dispute that, I'm going to set up a test case. :p
 
@Chris That's BS...
 
$problems = array();
 
the abstractions will cause a performance impact for sure
 
but it's a micro-optimization at best
 
1:50 AM
To the benchmark! :p
 
Object construction is cheap
 
@dyelawn how would I put each value into the array?
 
parsing is cheap (with an opcode cache)
the most expensive parts are the business logic you use to go back and forth
and the database interaction
 
$problems['a problem'] = "that problem's error message";
 
so I could do
$problems['1'] = "that problem's error message";
and keep adding to the number
 
1:51 AM
@dyelawn Or $problems[] = 'Some problem';
So you don't have to keep track of keys for your error message array
Which is beesanity
 
and how would the echoing be? a foreach $arr as $value?
 
@chris correct, but he seems to be very concrete in his thinking (I'm familiar with this) so I offered an associative approach
 
(that's like insanity, but with bees)
 
really a validation try{} catch() {} then a submission try{} catch(){} would be best for his particular issue, I think
@ircmaxell did the example code above help clarify my question?
 
1:55 AM
@ircmaxell Know of any active projects that employ exclusively DomDocument-based templating?
I found one, on Google Code
Just that one
 
What's wrong with
foreach ($problems as $value) {
echo $value;
}
 
@dyelawn Not really, but let me take a stab. No. You shouldn't do that. You need to either a) declare the properties of the class in its definition, or b) use a parameter array and add your values to that, then use magic methods for getters and setters.
Why didn't you... try it and find out?
 
I don't understand how to better my code with head-desk
I have tried it; I'm not getting errors
I've tried it with __set() and __get() referring to values in the attribute array rather than individual properties
I've done performance testing to see the difference between maintaining an indefinite array of attributes as opposed to a finite definition of properties
now i'm trying to consult more experienced parties to see which approach is better, and if there are things that I haven't taken into consideration
 
Don't
try a few methods for yourself
play and experiment
that's the only way to learn
asking people is only going to do you a diservice in the long run
Ask theoretical concepts, not specific ones.
4
 
Yeah guys. it's not like our school teachers gave us the answers to any specific questions; we wouldn't learn by seeing how it's done!
 
2:01 AM
 
You want answers to specific questions?
Go look them up in open source projects
look and study them
understand how and why they made their decisions
 
i thought the initial question was a theoretical one; i tried to make it more specific when you told me it was to vague. please know that i have done a lot of trying/testing on my own. i'm simply looking for people to help with the inevitable oversights that come with learning something on one's own not trying to get people do everything for me.
 
Don't get me started on stdClass!
 
Anonymous objects have their uses
 
i have read a lot of code; i read the manual once monthly, review Zend often, especially when creating classes and interfaces. but i was a film theory major. that decision making process is precisely what i need help understanding, because it's a lot easier to understand that process from a human response than a man page
 
2:06 AM
@ircmaxell Not saying they don't. That is his question, "can/should I arbitrarily assign properties/values to my class". My answer is, "No, don't".
 
fair enough
 
You can, shouldn't
hehe
 
those codepads' only greater lack than helpfulness is their lack of humor.
 
@ircmaxell Seriously curious, what uses are there for stdClass?
 
@dyelawn How so? I am demonstrating a class that accomplishes what your code seeks to accomplish, no?
 
2:09 AM
anonymous data objects. Dictionaries. Sometimes I prefer an object to an associative array. Especially if you need object reference semantics, but don't need a structured container...
 
i don't aim to create a MagicalClassOfMystery, i aim to create a class Person, that a diverse set of subclasses across a diverse set of namespaces can extend.
 
There isn't usually a time where you need a stdClass, but they're there if you want them, basically
 
@ircmaxell Fair enough.
 
exactly
 
@dyelawn I've demonstrated how to do so, emulate the magic
I had hoped, with the sample code, to persuade you to avoid the pattern. Classes like that are hard to work with because you have no idea what they are composed of
You can't trust them to have the properties you expect
You can't trust the properties to mean what you expect them to mean, even if they're there
 
2:12 AM
if they have none of the properties that I expect, then I don't trust them and an ErrorExcepton is thrown
 
So it becomes pointless to use a class at all, just pass arrays around
Completely structureless classes is an antipattern
 
Guys is this the wrong way to add values to the array? pastebin.com/hY8MxSe7
 
@AlexCastro No
 
hmph
 
@AlexCastro Assuming you want a 0-indexed array, no
 
2:13 AM
What's the best way to check if an array is empty? simply an if empty($arr)?
 
@AlexCastro Yep
 
or count($arr)
 
haha nice save chris
 
but if I want to contact a Person, I can try via email, SMS, facebook, IM, etc. And the sources for these People are disparate: Google contact feeds, iPhone contact records, native CRM contacts. Each of these known sources has a subclass with more definite methods for handling their attributes. But I'd like to send a Person a message if at all possible.
 
i want a super::$static
 
2:17 AM
I'm so frustrated. Can someone please tell me why this isn't writing to the database? Absolutely no errors are returned, and the structure is setup fine. pastebin.com/7FRk1X5C
 
@AlexCastro - You aren't checking for a database error. Get the result of execute as a variable, true if it worked, false if not
Docs, man, docs
 
@chris pretty sure i said that above
@AlexCastro and asked everyone else here to provide feedback
 
I know, I've seen him in here all day :p
 
Thanks for the link, Chris
 
@AlexCastro could have solved your problem like three chat logs ago if you'd listened to the guy with all the dumb questions
 
2:20 AM
@ircmaxell - If I intend to blog about code and politics, would you suggest separating the two? I'm inclined toward yes, but then again, content is content and I could just throw it all in and make use of tagging.
 
I've been leaving the house so..
 
It could also be that your id field is an int. If you pass parameters to execute instead of binding them explicitly they are treated as a string. I don't know that this would cause your problem, but it might.
 
@CharlesSprayberry Yeah, not sure... MySQL epically type-converts when it feels like it in queries with the mysqli_ and mysql_ functions
 
@Chris Yea, I know MySQL does some funky conversions on certain data types. /shrug
 
Found my error: Duplicate entry '0' for key 'PRIMARY'
 
2:28 AM
No autoincrement?
 
I'm assuming I'm missing it
I'll check
 
@Chris it depends upon whether or not your coding philosophy and your political philosophy are closely related. if($they_are): create_one_blog_with_categories(); else : create_two_blogs_on_subdomains_but_linked_to_each_other_because_if_you_are_inter‌​ested_in_both_others_likely_are_too(); endif; $stupid_questions === false;
 
Hey guys, is it possible to change the key of an array based on one of the key/values deeper down?
 
@Kevin slightly more detail and i'll write your code for you; feel free to ignore it, though.
 
sure thing, let me whip up a paste real quick
@dyelawn paste.ubuntu.com/1138879 instead of [0] and [1], i'
i'd like to replace it with the value of [channel][login]
so in that example, [0] would become 'beardyduck'
 
2:35 AM
$whatYouWant = array(); foreach($stream as $s) : $whatYouWant[$s['channel']['login']] = $s; endforeach;
 
what is $stream in this case?
 
[stream] => Array in line 2 of the pastebin
make sense?
 
sort of.. i think i'll try something myself real quick based on your code
 
OFFFTOPIC: so wondering if we have some physics guys who may know the possible negative effects of the new heel less wedge
I dunno about you guys but it seems like the new centralized point of failure (while possibly better for shoe design) might have a dammaging effect on the toe and related joints for the girl
any wana chip in?
 
@dyelawn not really making sense. this is quite complicated to explain in such a small amount of text ;p
 
2:44 AM
where is that data coming from?
 
an API query
 
ok, so $result = your API Query
 
i want to do something like "foreach [stream][number], [number] = array[stream][number][channel][login]
but that's just how it works in my head
 
$yourDesiredArray = array(); $result = array_shift($result); foreach($result as $k => $v): $yourDesiredArray[$v['channel']['login']] = $v; endforeach;
the array_shift brings out the first value of the $result array, or [stream].
then you looping through each element in $result as a key-value pair, or $k=>$v
you add a new element to $yourDesiredArray with the key being the value you want and the value being the entire array
does that help?
 
perfect, works great. thanks!
 
2:58 AM
how does 'password123' == 0 ? i dont get that lol
 

« first day (664 days earlier)      last day (4284 days later) »