Programming Confessions Thread
-
@Zenith said in Programming Confessions Thread:
For the life of me, I can’t figure out how to implement a bubble sort on a subsection of a table. I need a drink or something I guess.
It's the weekend. De-frazzle your brain.
(If you have a standard bubble sort, look for where it uses a min and max index. And throw it all out; bubble sort is a terrible sorting algorithm.)
-
@dkf said in Programming Confessions Thread:
bubble sort is a terrible sorting algorithm
Yes, it's too fast for modern applications. Use Bozosort, and if user dares interrupt it, declare that something went wrong.
-
@Applied-Mediocrity said in Programming Confessions Thread:
@dkf said in Programming Confessions Thread:
bubble sort is a terrible sorting algorithm
Yes, it's too fast for modern applications. Use Bozosort, and if user dares interrupt it, declare that something went wrong.
Sounds like time for microsevices! SaaS anyone? You get your results as soon as you have sat through 10 minutes of video adverts.
-
Why even do that when you can ask ChatGPT for the answer?
-
@dkf said in Programming Confessions Thread:
@Applied-Mediocrity said in Programming Confessions Thread:
@dkf said in Programming Confessions Thread:
bubble sort is a terrible sorting algorithm
Yes, it's too fast for modern applications. Use Bozosort, and if user dares interrupt it, declare that something went wrong.
Sounds like time for microsevices! SaaS anyone? You get your results as soon as you have sat through 10 minutes of video adverts.
What?
S
stands forSorting
, you think, young man?
C'mon, it's a microservice, it must stand for .
-
@Arantor said in Programming Confessions Thread:
Why even do that when you can
ask ChatGPT for the answer?FTFY
-
@Arantor said in Programming Confessions Thread:
Why even do that when you can ask ChatGPT for the answer?
Only Smarties have the answer.
-
@dkf said in Programming Confessions Thread:
@Arantor said in Programming Confessions Thread:
Why even do that when you can ask ChatGPT for the answer?
Only Smarties have the answer.
or
-
@HardwareGeek the latter. It was the slogan from the TV ad in the 80s and/or 90s.
-
@Arantor said in Programming Confessions Thread:
Why even do that when you can ask ChatGPT for the answer?
And by that, of course, you meant "implement in your code a call to ChatGPT where you pass it the table to sort and ask it to return the sorted table" rather than "ask ChatGPT to write the sorting code."
-
@remi I’d ask ChatGPT to write the integration so it was set up for all future projects.
Maximising the work not done.
-
@dkf Well I'm a dumbass.
What it should look like with a row offset:
for (var i = 2; i < n - 1; i++) { for (var j = 2; j < n - i + 2 - 1; j++) { //stuff } }
What I actually had:
for (var i = 2; i < n - 1; i++) { for (var j = i; j < n - i + 2 - 1; j++) { //stuff } }
-
-
@Zenith said in Programming Confessions Thread:
j < n - i + 2 - 1
Interesting thought pattern.
I'll ask Kevin if he could explain that.
Or Jim.
-
@BernieTheBernie said in Programming Confessions Thread:
@Zenith said in Programming Confessions Thread:
j < n - i + 2 - 1
Interesting thought pattern.
I'll ask Kevin if he could explain that.
Or Jim.Second embarrassing confession: I copied the algorithm from a website rather than really relearn it. The explanation is:
J
is the inner loop.
N
is the length of thearraytable.
-1
is the stupid 0-based indexing correction ofN
.
-I
is because the bottomI
elements are already sorted.
2
is the row offset (first two rows are headers).
-
@Zenith at least you didn’t copy code from a blog, modify it but not understand how it worked (so you don’t understand why your changes don’t work properly), then try to claim you wrote it from scratch before being called out by the local team expert who points out the specific blog article you copied it from.
I know someone who did these things…
-
@Arantor bonus points if the expert is also the author
-
@homoBalkanus alas not in my case - I spotted the rogue code, figured it wasn’t the miscreant’s usual style and went investigating.
The miscreant was the sort who would take $x = $y + ($a * $b) and force every operation to its own line with its own temporary variable. Very not like the function he’d checked in.
-
I'm librarying again, up at GitHub. This one has a feature lacking from prior - a nonsemantic name! Apparently I still want partial function application in Java.
-
I'll admit I'm trying to write a template that produces JSON using an engine specifically designed to manipulate XML-likes.
It.... almost works.
-
@Tsaukpaetra said in Programming Confessions Thread:
It.... almost works.
-
@Tsaukpaetra just use JSONx and put everyone involved out of their misery.
-
@Arantor said in Programming Confessions Thread:
put everyone involved out of their misery
-
@Arantor said in Programming Confessions Thread:
@Tsaukpaetra just use JSONx and put everyone involved out of their misery.
Problem is, I can't.
-
Status: I'll admit I don't know why I wrote it like this...
-
There's not going to be a race condition.
Ok, there's going to be one, but exceedingly rarely.
Ok, it's going to happen often, but it's not going to impact much.
Ok, it does impact quite a lot. Goddammit.
-
@Applied-Mediocrity When it's a matter of race conditions, you shouldn't get ahead of yourself.
-
Confession: I forgot () to add bounds checking.
I wrote a little utility to help a friend easily transform some data. She gave me the format (6 columns). Great. Just got an email "It always crashes now!". I looked at the data - she had 5 columns. Accessing std::vector with
fields[5]
when there's only 5 columns causes problems.The program now yells at her if there aren't 6 columns.
-
@dcon said in Programming Confessions Thread:
Confession: I forgot () to add bounds checking.
I wrote a little utility to help a friend easily transform some data. She gave me the format (6 columns). Great. Just got an email "It always crashes now!". I looked at the data - she had 5 columns. Accessing std::vector with
fields[5]
when there's only 5 columns causes problems.The program now yells at her if there aren't 6 columns.
written as per spec. I’ll allow it.
-
Status: No fuckin' clue what I was thinking with this...
-
@Tsaukpaetra That looks like PHP.
Worse, that looks like PHP with nested ternary operators.
-
@Zecc said in Programming Confessions Thread:
@Tsaukpaetra That looks like PHP.
Worse, that looks like PHP with nested ternary operators.
PHP that generates SQL. What could possibly go wrong?
-
Doctrine exists, people.
-
@dkf said in Programming Confessions Thread:
@Zecc said in Programming Confessions Thread:
@Tsaukpaetra That looks like PHP.
Worse, that looks like PHP with nested ternary operators.
PHP that generates SQL. What could possibly go wrong?
All the above, and that was the introductory clause!
Someone mentioned left to right or something about ternary so I decided I should fuck with it as best I could.
-
@Arantor said in Programming Confessions Thread:
Doctrine exists, people.
Profound statement, there.
Does it truly exist?
-
@jinpa said in Programming Confessions Thread:
@Arantor said in Programming Confessions Thread:
Doctrine exists, people.
Profound statement, there.
Does it truly exist?
-
Status: Committing sin, because I don't care about this particular edge.
-
@Tsaukpaetra for something that doesn’t use parameter inputs, I see what looks suspiciously like a bound parameter to be input somewhere, and that isn’t your hand rolled escaped whatever. (Which if it is what I think it is, probably needs your value to still be quoted because real_escape_string only fixes the content for special characters, not wraps in quotes on top)
-
@Arantor said in Programming Confessions Thread:
@jinpa said in Programming Confessions Thread:
Does it truly exist?
But as software, it's more of a concept than a thing. ∴ it doesn't exist.
-
@PotatoEngineer said in Programming Confessions Thread:
@Arantor said in Programming Confessions Thread:
@jinpa said in Programming Confessions Thread:
Does it truly exist?
But as software, it's more of a concept than a thing. ∴ it doesn't exist.
the original post asserting that Doctrine exists was in response to someone crafting SQL in PHP. I asserted that Doctrine exists because that's exactly the point: a suitable PHP-based database abstraction library that can build queries exists, meaning that whatever the hell was being perpetrated, it didn't need to happen and could be replaced with something sane.
At no point was I asserting Doctrine-the-abstract-concept exists, I asserted Doctrine-the-software-library existed and suited the purpose at hand.
-
@Arantor Right, but you can't hold software in your hand, you can only hold a storage medium that happens to contain the software.
Apparently, I dropped this:
-
-
You're only holding a collection of atoms that happen to be arranged in such a way that the resulting pattern performs the functions of a storage medium.
-
Deep, very deep. You should send that in to the Reader's Digest, they have a page for this sort of material.
-
@Arantor said in Programming Confessions Thread:
@Tsaukpaetra for something that doesn’t use parameter inputs, I see what looks suspiciously like a bound parameter to be input somewhere, and that isn’t your hand rolled escaped whatever.
It's a hand-rolled substitution for the column name, which is vetted elsewhere to be in the table definition and not under external input (assuming my notes of my implementation are correct. I should probably look for more
//TODO:
s)@Arantor said in Programming Confessions Thread:
(Which if it is what I think it is, probably needs your value to still be quoted because real_escape_string only fixes the content for special characters, not wraps in quotes on top)
Yep, the substitution throws in the backticks and also the table name or alias as appropriate for the context (assuming the context is given appropriately!).
I use three-layer ternaries for that one.
-
@Arantor said in Programming Confessions Thread:
they have a page for this sort of material.
Really, you can use any page for wiping, if you run out of the softer sort of paper.
-
@Arantor said in Programming Confessions Thread:
I asserted that Doctrine exists because that's exactly the point: a suitable PHP-based database abstraction library that can build queries exists, meaning that whatever the hell was being perpetrated, it didn't need to happen and could be replaced with something sane.
Maybe by the time I bring CM3 to the first actual major release I'll switch. Should be EASY.
-
@HardwareGeek said in Programming Confessions Thread:
@Arantor said in Programming Confessions Thread:
they have a page for this sort of material.
Really, you can use any page for wiping, if you run out of the softer sort of paper.
Except paper with a glossy finish just spreads it around, and doesn't provide any lifting ability.
-
I've been a lazy, lazy dev. I'm trying to dirty-check something the user is editing, and so I dragged out Lodash's _.isEqual to do it. But that function is pretty picky about null vs undefined vs property-doesn't-exist, so I tack on a home-grown removeNil function before trying the isEqual().
And then it turns out that isEqual cares about the order of things in arrays (but I don't), so I sort the arrays before passing them to isEqual.
And then it turns out that when the server-side object has a null thing in a property, the client-side code is filling in a default value.
And now I just learned that my RichText editor thing is trimming whitespace (but only when it's showing!), so when the server side string ends in a space, switching to the tab with the RichText will immediately fail the dirty-check, even if the user hasn't changed anything.
Really, the more I chase this equality-check-but-some-things-don't-matter, the more I think I need to write an explicit property-by-property equality function rather than half-assing it with isEqual and nil-removal and generated-property-removal and other nonsense.
But surely, I just need to do this one last thing and I'll be done....
-
@PotatoEngineer said in Programming Confessions Thread:
removeNil function
The Egyptians might object to that.