Programming Confessions Thread
-
@topspin said in Programming Confessions Thread:
@PotatoEngineer said in Programming Confessions Thread:
@Tsaukpaetra said in Programming Confessions Thread:
@remi said in Programming Confessions Thread:
@topspin plus, it won't really work when the participle is the same as the action. What does
cut
do?It bifurcates the red node in the tree at the specified branch.
No, it dilutes the heroin with powdered milk.
No. It puts the lotion on its skin, or else it gets the hose again.
Damn right it does.
-
Status: I just wrote this code:
//Also confirm the specified badge_type_id belongs to the event id if (!(array( 'Attendee' => $this->a_badge_type, 'Application' => $this->g_badge_type, 'Staff' => $this->s_badge_type, )[$data['category']])->verifyBadgeTypeBelongsToEvent($data['badge_type_id'], $event_id)) { throw new HttpBadRequestException($request, 'Invalid badge context/id specified'); }
I have no idea if it will work as expected, but I'm confident it does.
Now to actually attempt to run it...
-
@Tsaukpaetra you've got a group unaccounted for here...
-
@Tsaukpaetra can tell you now it looks very much like it
won’tmightYou seem to be trying to use an array as the key to an array (not valid), so you can find $data['category'] which better contain an object, because you can’t operate with -> on a non-object…No that isn’t what it’s doing, is it? You have an array of 3 objects, referencing by key directly which is then fed in…
That is some ugly code though… plz refactor for readability.
-
@Arantor said in Programming Confessions Thread:
@Tsaukpaetra can tell you now it looks very much like it
won’tmightYou seem to be trying to use an array as the key to an array (not valid), so you can find $data['category'] which better contain an object, because you can’t operate with -> on a non-object…No that isn’t what it’s doing, is it? You have an array of 3 objects, referencing by key directly which is then fed in…
That is some ugly code though… plz refactor for readability.
It's not his fault if future-him is unable to figure out WTF is going on here.
-
@Arantor said in Programming Confessions Thread:
That is some ugly code though… plz refactor for readability.
Yeah it's still in the brainstorming phase.
I'm just trying to avoid an if-ladder of copypasta.
-
@Tsaukpaetra set a variable to null to hold the badge type, switch() through them to assign something to said variable, if variable is not empty attempt the verify method?
-
@Arantor
Real programmers would use a quaternary to set the badge array variable
-
@Arantor said in Programming Confessions Thread:
@Tsaukpaetra set a variable to null to hold the badge type, switch() through them to assign something to said variable, if variable is not empty attempt the verify method?
That's effectively the same thing I did... Well, I did add the "Hey is this even a match" condition.
-
@Tsaukpaetra yes but not in a one liner…
-
@izzion And suddenly I'm reminded the ternary operator in PHP is left-associative.
False edit: apparently this has been changed in 8.0.0.
-
@Arantor said in Programming Confessions Thread:
@Tsaukpaetra yes but not in a one liner…
Your idea isn't a one-liner either?!?
-
@Tsaukpaetra no, I like readability too much.
-
@Tsaukpaetra unfortunately I handle cases like this in a fashion so elegant that even to tell you the name of the higher-order function involved would violate my current NDAs.
-
@Arantor said in Programming Confessions Thread:
@Tsaukpaetra no, I like readability too much.
I'm utterly confused now....
-
@Tsaukpaetra said in Programming Confessions Thread:
@Arantor said in Programming Confessions Thread:
@Tsaukpaetra yes but not in a one liner…
Your idea isn't a one-liner either?!?
Yours is. Not a literal line, but don't put all that crap in an if expression.
-
@topspin said in Programming Confessions Thread:
@Tsaukpaetra said in Programming Confessions Thread:
@Arantor said in Programming Confessions Thread:
@Tsaukpaetra yes but not in a one liner…
Your idea isn't a one-liner either?!?
Yours is. Not a literal line, but don't put all that crap in an if expression.
Oh! Well of course, it's not going to stay like that. As I said...
-
@Tsaukpaetra said in Programming Confessions Thread:
still in the brainstorming phase
Stop that. If you scramble your brain, I'll have to reboot you again.
-
@Tsaukpaetra said in Programming Confessions Thread:
@Arantor said in Programming Confessions Thread:
@Tsaukpaetra no, I like readability too much.
I'm utterly confused now....
Look on the bright side. At least you weren't trying especially diagonalize your biapplicative monad.
-
@Zerosquare said in Programming Confessions Thread:
@Tsaukpaetra said in Programming Confessions Thread:
still in the brainstorming phase
Stop that. If you scramble your brain, I'll have to reboot you again.
It stops the brainstorming, or it gets the reboot again.
-
@Arantor Use a match expression instead?
-
@Watson yeah, that'd work. I'm not yet quite used to PHP 8's full shenanigans because I haven't yet seen much stuff on 8, all the stuff I work on currently is 7.4 or lower.
-
@Gąska said in Help Bites:
@PleegWat
var that = this
@Benjamin-Hall said in Help Bites:
@Gąska said in Help Bites:
@PleegWat
var that = this
I've actually found
var self = this;
in our codebase. To get around JavaScript not binding to this properly in callbacks.I've done this.
Fucking Javascript...
-
@Tsaukpaetra said in Programming Confessions Thread:
Fucking Javascript...
Do not recommend. You don't know who npm has been with. Diseases rampant. 0/10
-
@izzion on the contrary I know who npm has been with. I rather think that’s the problem. Good libraries go to heaven, bad libraries go everywhere.
-
Working on writing tests for a bunch of new angular components. They all use a particular service for talking to the back end. Somehow, I managed to copy that service into one component's directory and the test was providing a mock for that file, not the actual one, which the component was looking for.
Took me several hours to figure out why the component wasn't getting the mocked service.
-
Gah! That's at least the third time this week that I've written something like...
const theFoo = foos.find( f => f.id = fooId );
-
@boomzilla
=
vs.==
?
Or missing a.FirstOrDefault
?
Or theconst
part?Anyways: YES.
-
@BernieTheBernie #0.
-
@boomzilla So, all
f
infoos
had theirid
updated, andtheFoo
was a copy offoos
.
That's shit, which is also called#2
.
-
@BernieTheBernie correct. Fortunately, it was in unit tests so the only casualty was my pass rate and coverage pointz.
-
@boomzilla said in Programming Confessions Thread:
@BernieTheBernie correct. Fortunately, it was in unit tests so the only casualty was my pass rate and coverage pointz.
That reminds me, my code should get tests at some point.
-
@PotatoEngineer Feeling swanky, are we?
-
@GOG said in Programming Confessions Thread:
@PotatoEngineer Feeling swanky, are we?
Well, we have a testing framework. I'm going to be generous and say it covers maybe 5% of the code, but it does exist. So I could, in fact, put some of my code under test without too much effort, and significantly more code under test for significantly more effort.
Or, y'know, I could actually meet these deadlines for things that people are actually asking for. Decisions, decisions...
(Adding tests to new code makes some sense, and helps you debug as you go, or at least nail down your use-cases a little more solidly. Adding tests to old code is really only useful the next time you touch that code... which could be a while.)
-
I feel that I'm never going to understand IAM. I'm going to just use the root user for everything.
-
@DogsB said in Programming Confessions Thread:
IAM
Welcome to hell. Security groups are waiting for you in the next circle.
-
@homoBalkanus said in Programming Confessions Thread:
@DogsB said in Programming Confessions Thread:
IAM
Welcome to hell. Security groups are waiting for you in the next circle.
That's purgatory. Hell is untested code.
Or, if you take a strictly Dantean interpretation, that's climbing the body of Satan. Might be a better fit, but just climbing one Satan doesn't seem like a realistic remediation estimate.
-
@PotatoEngineer said in Programming Confessions Thread:
@boomzilla said in Programming Confessions Thread:
@BernieTheBernie correct. Fortunately, it was in unit tests so the only casualty was my pass rate and coverage pointz.
That reminds me, my code should get tests at some point.
One of these days I'll learn how to make them!
-
@DogsB said in Programming Confessions Thread:
I feel that I'm never going to understand IAM.
Maybe brushing up your French will help
-
@ixvedeusi wow, that was a blast from the past. I remember when that came out and was the big "this is not music, it's just noise" of the time. My has suddenly grown a size or two.
-
@ixvedeusi said in Programming Confessions Thread:
@DogsB said in Programming Confessions Thread:
I feel that I'm never going to understand IAM.
Maybe brushing up your French will help
I'd rather burn Paris to the ground than listen to French pop music or philosophies.
-
@DogsB said in Programming Confessions Thread:
I'd rather burn Paris to the ground than listen to French pop music or philosophies.
New way to annoy @DogsB acquired
-
@remi said in Programming Confessions Thread:
@ixvedeusi wow, that was a blast from the past. I remember when that came out and was the big "this is not music, it's just noise" of the time. My has suddenly grown a size or two.
I don't know. I like the funky backing track.
-
@DogsB said in Programming Confessions Thread:
I'd rather burn Paris to the ground
You'd be surprised at how much of the French population would agree with you
-
@DogsB said in Programming Confessions Thread:
I'd rather burn Paris to the ground than listen to French pop music or philosophies.
So Paris is safe from you if you listen to that clip.
-
@Zerosquare said in Programming Confessions Thread:
@DogsB said in Programming Confessions Thread:
I'd rather burn Paris to the ground
You'd be surprised at how much of the French population would agree with you
From what I've heard, that's the #1 fantasy of the French outside of Paris. And some small fraction of those inside, too.
-
I'm gonna kick some code from app to app because the library to avoid it is too much of a pain in the ass right now.
-
@Gribnit holy shit, we have programmers here?
-
@Gribnit I am devloper
-
@Gribnit I'm only an amateurgrammer.