« first day (2382 days earlier)      last day (2565 days later) » 

9:04 PM
conn::close: Couldn't fetch mysqli, does that mean the connection has already been closed somewhere else? I put $this->conn->close() in the __destruct.
 
To me, it looks like visitor pattern can easily violate SRP
 
I have a form where employer can post jobs to a job board our website has. The problem is, employers copy and paste from word into the form. I'd like to convert what they input into plain text. Is this possible?
 
@Tiffany If they copy and paste from word into a simple input, doesn't that covert it to plain text?
 
@Jimbo I thought it would, but I'm ending up with weird characters
or maybe that's the problem
it's converting it to plain text, and can't handle the weird quotation marks
 
@Tiffany Might be an encoding issue? Look at: accept-charset html attribute
 
9:13 PM
Sounds like an encoding issue instead
 
I know it's an encoding issue
but I'm trying to figure out how it needs to be encoded
 
utf8
Surely "smart" quotes are in it
 
database is already
 
Everything needs to be utf8
 
and I thought the input fields were.... but maybe they aren't
 
9:15 PM
The page it is on, the database connection, the database encoding, the field encoding etc
!!utf8
 
752
Q: UTF-8 all the way through

mercutio I'm setting up a new server, and want to support UTF-8 fully in my web application. I have tried in the past on existing servers and always seem to end up having to fall back to ISO-8859-1. Where exactly do I need to set the encoding/charsets? I'm aware that I need to configure Apache, MySQL an...

 
So this is what I find weird, before upgrading to a new web server, I didn't have this issue. Stuff encoded fine. After upgrading web server, I'm getting encoding errors. Code for the form hasn't changed, however the database encoding would have changed. However, it sounds like the issue is occurring before it hits the database.
And I've encoded the database to UTF-8 already
 
else if (
          $this->{$requiredArray[($key - 1)]} == '0000-00-00 00:00:00' ||
          !Validation::validateTimestamp($this->{$requiredArray[($key - 1)]}) ||
          !Validation::validateTimestamp($this->$requiredTimestamp) ||
          strtotime($this->$requiredTimestamp) > strtotime($this->{$requiredArray[($key - 1)]})
        )
Something about this statement is an infinite loops and I absolutely cannot find it.
(Validation::validateTimestamp is not it. I checked rigorously.)
Any ideas?
 
@PeeHaa sent an email to the vendor asking if the fields were encoded to UTF-8. Left an open-ended question asking what it would take to get them encoded because I really don't feel like fucking with it
I'm not sure it's something I can even do
 
@Allenph Pretty damn sure it's something to do with all the magic and static calls
 
9:19 PM
@Allenph Start by using at least a function and doing all that in separate statements
 
This already is a function.
 
No it is not
Or at least not a small enough one
 
It's already IN a function.
 
Is it clear to you what is going on?
 
Why create a function that will be called only once?
Yes.
 
9:20 PM
ok if it is clear you don't need me to tell you what is wrong with it...
 
I don't expect you guys to even be physically able to get the logic. I assumed it's just syntax somehow.
 
Try an IDE, it'll help you with syntax errors
 
It's not actually a loop (or may not be) it just takes like 100MB of RAM all of the sudden.
 
Seriously. Rewrite it to make it sane
 
@Jimbo I'm in an IDE. I don't think it's a syntax ERROR I think it's some kind of reference error having to do with the syntax.
 
9:22 PM
If you need to say:
> don't expect you guys to even be physically able to get the logic
Your code is wrong
 
> I assumed it's just syntax somehow.
 
    private function timestampIsValid($timestampColumn, $requiredArray = array())
    {
      $requiredArray[] = $this->$timestampColumn;
      $timestampIsValid = true;
      foreach($requiredArray as $key => $requiredTimestamp)
      {
        if ($key == 0)
        {
          if (!Validation::validateTimestamp($this->$requiredTimestamp))
          {
            $timeStampIsValid = false;
            break;
          }
        }
        else if (
          $this->{$requiredArray[($key - 1)]} == '0000-00-00 00:00:00' ||
There you go.
 
There's no other way that syntax, apart from not working (i.e. error) can be the issue.
Maybe you didn't mean syntax...
 
I probably don't.
 
yes that should totally be split up
 
9:22 PM
Hence the confusion - we all need to be on the same page here :)
 
That method is doing waaay too much
 
@PeeHaa be
 
<3
 
@PeeHaa It's mostly just the loop. I'm not sure exactly how to split that.
Actually. I have some ideas.
 
start by moving the validation per item out to it's own method
after that move that horrendous else if to a dedicated method
 
@Allenph I'm at a conference and did this super quick, but you can remove a few ifs...
 
@Tiffany Thanks. bookmarked.
 
Also check out what a guard clause is and how it will simplify your christmas tree of nested if/elses
 
^ this
 
user4061223
@Tiffany Yep, I've managed to redirect http to https but I can't prevent subdomains from following this rule, I've searched around everywhere. All possible subdomains should be left as they are
 
9:25 PM
Bookmarking guard clause Google search for later.
Thanks.
 
@Tiffany do you see where in specific the encoding gets fucked up?
 
@Osman If you were on IIS, I might be able to help. I'm not suggesting you be on IIS though. My learning is broken.
 
Oh. I didn't know what a guard clause was called, but I do that all the time.
 
We can see that :P
 
9:28 PM
@PeeHaa I usually only do it when it's really long and complicated.
This one has only two different cases.
 
@PeeHaa I haven't checked in between the website <-> database, but I know it's messed up in the database. I'm afraid of trying to output data before it gets inserted into the database because of how coupled the codebase is.
 
Actually the else if is required here.
Because I DON'T want it to fire if the index is not higher than 0, and the conditional is already complicated.
 
> Because I DON'T want it to fire if the index is not higher than 0
Then bail out at the top based on that
 
Guard clause is also "fail early"
 
I don't want that block to fire*
 
9:31 PM
@Trowski possibly, while libuv also provides support for files … so don't know.
 
Bail out as soon as possible
 
yay! it's time to go, I can empty my brain full of fuck. And also decorate a coworker's office for her 60th birthday.
 
In fact, the validation also needs to be in the if statement. It would be better to refactor with a switch.
 
No it would not
 
100% would.
 
9:31 PM
Imma just gonna ignore people now
Better for my health
 
You didn't explain why it would be better, @PeeHaa. How am I expected to just say, "okay?"
 
@PeeHaa that's what I have been doing for some time already
 
@tereško It's one thing not being listened to. It's a whole other thing hearing you are wrong every time when trying to spend time teaching someone :P
 
I just need to go to bite the bullet and go to college, don't I?
 
@PeeHaa I have been having this experience with Wes lately, regarding unittests
 
9:36 PM
I feel like I'm missing some stuff. And I feel like I annoy you guys the same way other people do when regular people ask me how website's work.
 
@Allenph I believe your logic still works here. This is where tests help: 3v4l.org/374sk
And I've already removed some stuff, I think there's still room for more
Especially for readability
 
@Jimbo that thing needs major refactoring
also, statics .. holly shit
 
@Jimbo That is still the same as far as I can tell.
 
@Allenph Next step: 3v4l.org/cgnkI, see where we're going with this?
 
@tereško Meh I don't mind @Wes at all. I almost never agree with him and he almost never agrees with me. But usually we at least try to force our opinion upon each other based on discussion
 
9:40 PM
I dont mind him, but he's just wrong about unittesting and every time I try to explain it to him, I loose my patience (probably due to the utter disappointment)
@Jimbo wrong
the next step should have been replacing
  if (!$isValidTimestamp)
  {
      $timeStampIsValid = false;
      break;
  }
with
      if (!$isValidTimestamp) {
          return false;
      }
 
$timeStampIsValid = !$isValidTimestamp
Sure sure, I'm showing iterative progress instead of just doing the whole thing at once
 
notsureiftrollingoralreadydrunk.gif :P
 
Ah I didn't even look at the name of the method
 
neither did I
it's just that there is no point in break, if you are returning right after the loop anyway
I personally feel like break is a less insulting cousin of goto
 
Wes
you didn't actually try tbh, you just kept saying i'm wrong, without saying why... but i'm used to you now and i don't care anymore :B that said, i like intelligent discussions, and i have no problem being proven wrong... as long the proof exists...
(in fact, i'm often wrong...)
 
9:43 PM
I was presented with this the other day
var canPlay = videoplayer.canPlayType(pFile.type);
canPlay = (canPlay === '' ? 'no' : canPlay);
return (canPlay !== 'no');
 
Wes
ahahaha
 
it took me waaayyy longer than I'm ready to admit to just accept that it was an obfuscated way of returning canPlay !== '';
 
hmmm
 
Boom, done: 3v4l.org/GjukP @Allenph
 
I thought canplay had three states
 
9:44 PM
yeah, empty, maybe and probably
 
ah right yeah
 
@FélixGagnon-Grenier actually it would be return videoplayer.canPlayType(pFile.type) || 'no';
(JS has this nice "fallback syntax")
 
nah, I need a boolean
 
oh god
 
9:46 PM
so, whay was neede was actually return !!videoplayer.canPlayType(pFile.type);
 
I see your AngularJS project is going well
 
the famous !!
 
@Jimbo Wow. That is a lot better.
 
@tereško finally completed that first not trivial ticket. gosh there was somo yolo shit going on in there
@tereško yes. exactly.
 
9:47 PM
@Allenph Well check the logic still works, write some basic unit tests with your initial class first and then refactor and re-run tests and you'll see if it works. Then again, you're coupling your code to this magic Validator object which makes your code not testable, which is why you DI this object instead so you can mock it out in your tests...
 
@Allenph why the hell are you storing '0000-00-00 00:00:00' in database?!
 
@tereško Not my idea.
I actually think it's freaking stupid.
 
@tereško Can I have your input? I have an object containing some data, and depending on the interface that object implements, I want to dispatch it's contents in a different way. For example, if it implements RemoteObject then I want to go and send it into a queue and if it's LocalObject I want to just run some code locally. I need some interfaces for all this, and visitor pattern is failing me so far (or I'm just not getting it)
 
@Jimbo I hope you normally would refactor that horrific if statement
 
My co-worker is adamant that it's worth it to save storage in MySQL that way instead of using null.
 
9:48 PM
@PeeHaa Course I would
 
And I want to murder him but I don't have time to argue with him.
Even though I designed the whole damn system.
 
murder is shorter than arguing, most of the time
 
@Allenph your co-worker is a fucking idiot
 
Good. Just checking your temperature :P
 
^
 
9:48 PM
golden
 
@tereško You have no idea.
You guys think I'm bad.
 
we do :(
 
Learn through abuse (tm)
 
Pray for my company. I am the acting senior dev.
And I freaking hate it. I'm not ready for this in any capacity.
 
@Allenph You learn through failure, if it's a company that'll let you fail and not kill you, just keep learning
 
9:50 PM
That's what I've been doing.
It's more difficult because the other two devs have no idea at ALL what they're doing. Their current systems are completely insecure spaghetti.
With server architecture that is a mess. Database architecture that is a mess.
And they're both MUCH older than me so it's hard to tell them what to do without being very careful about it.
 
@Jimbo you are over-complicating things
basically all you need is a class which has:
 
@Jimbo logic was wrong slightly.
private function timestampIsValid($timestampColumn, $requiredArray = array())
    {
      $requiredArray[] = $timestampColumn;
      foreach($requiredArray as $key => $requiredTimestamp)
      {
        if (
          ($key === 0 && !Validation::validateTimestamp($this->$requiredTimestamp)) ||
          (
            $key > 0 &&
            (
              $this->{$requiredArray[($key - 1)]} === '0000-00-00 00:00:00' ||
              !Validation::validateTimestamp($this->{$requiredArray[($key - 1)]}) ||
 
How do I make screenrecordings again on win @Wes?
 
Wes
licecap
 
ta
 
Wes
9:54 PM
gifs you mean?
@Allenph what's that :O
 
yeah
 
@Wes A poorly constructed function I wrote.
It was way worse before @Jimbo refactored.
 
Wes
anyway, a lot of people here have been proven knowing what they are doing
 
public function handle($entity)
{
    if ($entity instanceof RemoteObject) {
        $this->queueManager->defer($entity);
        return;
    }
    return $this->runner->execute($entity);
}
@Jimbo that about it
 
Wes
surprisingly also @PeeHaa :B his advice might be useful, occasionally :B
 
9:56 PM
ha! good one
 
essentially, it's something like a Facade or Adapter
 
BTW I am currently touching css and js @Wes
I am very sorry
 
Wes
you are forgiven, i am touching php :B
 
:D
 
@tereško I was under the impression that instanceof checks, that could grow in size (and will, actually), would become a code smell
Ignore that bit, am retarded. But yes, lots of instanceof checks - can I replace this?
 
9:59 PM
@Jimbo kinda. YOu could have hardcoded "handler" for each type of object, in something like $entity::HANDLER_TYPE
but that way you do not get a clean execution path
 
I was hoping I could use composition to avoid it instead of hardcoding
 
then you still end up with multiple checks
they WILL be somewhere
 
Yeah, I guess I'd need a hardcoded map
 
you could pass the "Entity" to a factory, so that it produces a matching handler
 
And factory contains the mapping
 
10:01 PM
yes
 
Hmm, I'll give that a go then, cheers
 
why doesn't the entity decide how to run itself?
 
that would be basically it's entire purpose
@pmmaga it would probably depend on how permanent is the codebase
if the "how to run" keeps changing (or is handled by 3rd party), it might turn in something of a mess
 
Also, the 'how to run' is hidden from the user, they just implement the interface and the actually running is transparent to them
So i'm not only looking at from an 'entity' perspective, but the responsibility put onto the end user
 
ah, ok ok
 
10:05 PM
They can specify that their custom class is to be run remotely simply by implementing interface
or something like that, I haven't gone into details :)
 
10:31 PM
@tereško Becomes a ballache now, even with a hardcoded mapping I still need a switch because each dispatcher may require different ctor params. For example, remote dispatcher will require AMQP dependency and local doesn't need any
I suppose I've got to give in somewhere, I just don't like it
 
@Jimbo have you tried inverting the entire architecture?
... I'm not sure if I can explain, if you don't know what I mean
you basically have layer A, that needs layer B to interact with layer C
A -> B -> C
 
Is the best way to store priorities a linked list?
 
@tereško go on?
 
@tereško This is where I am right now, using your map: 3v4l.org/btTce
It's a bit all over the place but I can feel it slowly coming together
One option is to use an abstract factory for the dispatcher?
 
why the relection?
that should definetly be replaced with just some getter from $executable
 
10:43 PM
@tereško Reflection so I'm not putting the whole namespace in the mapping
So, you're suggesting executable interface method for the mapping to a dispatcher
 
the honest answer is: I dont have enough information to give you a good advice and I have been drinking beer
 
:D
I'll keep trying
 
from what I can gather, your executable know uncomfortably much about how they are being executed
it really might be a better approach to design the executable so that they have "runner" as a dependency
 
@tereško Agreed. So I need to provide this executable the relevant 'runner'
As a queue executable will need a queue runner, which has it's own ctor params
 
yes
basically, you can "outsource" your problem to DIC
 
10:49 PM
Sure, I could.. but I feel I would only do that because of a problem with my architecture right here
 
the executable are what 3rd party will be making
and you are making a library
 
I was just thinking about that right now.. the user's class may have ctor params
 
you library can't depend on the implementation details of that 3rd party
 
if it's a local one
 
then make it a setter in an interface, which all executables have to implement
 

« first day (2382 days earlier)      last day (2565 days later) »