|
Volte posted:In C, a char literal is an integer, not a char. Hmm. I knew C lets you do int literals expressed as multiple characters (like 'AAAA' is 0x41414141) but I didn't realize that all char literals were ints. Pre-OSX Mac APIs used these a ton, for file type/creator codes for file metadata and resource identifiers.
|
# ? Jul 24, 2022 21:19 |
|
|
# ? Jun 1, 2024 05:12 |
|
Plorkyeran posted:"The path is not valid" and "you asked for a thing that doesn't exist" are the same thing, and the only way for them to be different are if you're leaking implementation details to the client. "The path is not valid" returns 403 on the application I worked on. Not because someone did that specifically, just because: 1. You had to be authorized to access anything 2. Authorization is evaluated first, as a separate layer 3. The paths that don't exist don't have an association to a policy that can authorize you. Basically "you're not authorized to know the page does not exist" Pyromancer fucked around with this message at 20:18 on Jul 25, 2022 |
# ? Jul 25, 2022 20:08 |
|
My favorite dumb auth story was from when I worked / went to school at DeVry University back in like 2007 or so; they were using an old AS400 for all grading/etc and they brought in Oracle to build a new frontend for it so students could do some self-service stuff instead of academics dept having to login using a terminal emulator and update things and print schedules/etc. Well, day one of the big launch, I login to the new portal, and I get a huge list of options, probably like a hundred in a massive multi-column list. Everything from grading papers to authentication config, literally everything. I worried that being a staff member and a student had somehow crossed some wires, so I mentioned it to the network admin, who happened to be the guy working on the project at our branch. He rolled his eyes pretty hard. "Yeah, so I asked about this too. Apparently, the Oracle model is to check permissions only when it's needed because computationally it's expensive to check on login. So you only get your permissions checked when you try and use anything, not when you login." Sure enough, when I tried any of the options that weren't applicable to me as a student, I got a permissions error. At the time I filed that under 'Well, I guess Oracle knows what they're doing' but over time I'm reasonably more and more confident that was just an incredibly stupid decision.
|
# ? Jul 25, 2022 22:00 |
|
Falcon2001 posted:I filed that under 'Well, I guess Oracle knows what they're doing'
|
# ? Jul 25, 2022 22:13 |
|
more falafel please posted:Hmm. I knew C lets you do int literals expressed as multiple characters (like 'AAAA' is 0x41414141) but I didn't realize that all char literals were ints. https://en.cppreference.com/w/cpp/language/character_literal posted:Multicharacter literals were inherited by C from the B programming language. Although not specified by the C or C++ standard, most compilers (MSVC is a notable exception) implement multicharacter literals as specified in B: the values of each char in the literal initialize successive bytes of the resulting integer, in big-endian zero-padded right-adjusted order,
|
# ? Jul 25, 2022 22:20 |
|
Wipfmetz posted:Didn't know about those. They sound like a neat way to define constant or enum values, but alas, non-standard. And non-standard scares me. I didn't realize they were nonstandard, but byte order alone is justification enough for them not to be. Again, the only example I have of using them was from pre-OS X MacOS, which was designed to be programmed in Pascal or 68k assembly, with C as an afterthought.
|
# ? Jul 25, 2022 23:01 |
|
A great and terrible way to encode and decode file format magic numbers.
|
# ? Jul 25, 2022 23:13 |
|
lifg posted:I never learned how to pronounce HATEOAS. I normally go for something that sounds like “Hate O/S”. Its always sounded like a merging of "hate" and "cheetos", which makes me think the name should be used for "standard implementation for image board to provide entertainment for malicious children" rather than "thing a committee designed for talking to apis"
|
# ? Jul 26, 2022 15:08 |
|
Falcon2001 posted:At the time I filed that under 'Well, I guess Oracle knows what they're doing' but over time I'm reasonably more and more confident that was just an incredibly stupid decision. You misspelled lazy
|
# ? Jul 26, 2022 17:00 |
|
Volmarias posted:You misspelled lazy I don't even know if I'd call that lazy, just bizarre.
|
# ? Jul 29, 2022 06:41 |
|
We’re talking about Oracle, guys. The word you’re looking for is ‘evil’.
|
# ? Jul 29, 2022 14:41 |
|
Never attribute to malice that which can be adequately explained by stupidity.
|
# ? Jul 29, 2022 16:07 |
|
Occam's Razor takes precedence over Hanlon's Razor. With Oracle in particular, you should never attribute to incompetence that which can be adequately explained by malice.
|
# ? Jul 29, 2022 17:35 |
|
Also with Oracle, ¿porque no los dos?
|
# ? Jul 29, 2022 17:39 |
|
I don't think you understand how online conversations work, if I don't "win" this argument I'm literally going to die. Sad but true.
|
# ? Jul 29, 2022 17:44 |
|
Then let us die together, in battle!
|
# ? Jul 29, 2022 17:47 |
|
Unity is getting at me again. I am trying to target a stereo projector. The graphics card supports stereo. Unity supports stereo. But it won’t let you turn it on unless you’ve installed an HMD plugin. WTF?
|
# ? Jul 29, 2022 20:51 |
|
|
# ? Jul 30, 2022 07:41 |
|
I hate what I know about this kind of optimization making sense, even if you ignore referencing entirely. Before 3.7, every single time you called a method on an object, python would create a brand new bound function and then call it.
|
# ? Jul 30, 2022 08:30 |
|
Next time I need thirty-six million datetimes I'll be skating away while you idiots twiddle your thumbs an extra four seconds.
|
# ? Jul 30, 2022 08:34 |
|
Ok.... so I thought the joke was you were caching a datetime.now result instead of calling it every time. Turns out Python doesn't work like that, what is cached is a reference to a function and it only executes once you use the () brackets. So their example is actually valid.
|
# ? Jul 30, 2022 08:47 |
|
yeah, the point is that datetime.datetime.now could've been changed by calling it, so Python has to do 2 extra lookups for each iteration of the loop unless you cache it. The local variable could've also been changed/deleted using some debug package, but at least it's only a single lookup.
|
# ? Jul 30, 2022 10:06 |
|
why is the variable called "loop_squared"? what's "squared" about it?
|
# ? Jul 30, 2022 11:47 |
|
Also he's passing it in as a parameter (I'm assuming that's what number is, I don't use python too much), but then he uses the global variable anyway Edit: vvvv ah, makes sense. mmkay fucked around with this message at 17:07 on Jul 30, 2022 |
# ? Jul 30, 2022 11:53 |
|
timeit is a microbenchmarking thing that runs the code you've passed in a number of times equal to the number you pass in. I guess it's called loop_squared because timeit runs the function n times, and the function runs n iterations of the loop, so the actual thing being measured will be done n2 times.
|
# ? Jul 30, 2022 12:06 |
|
Jabor posted:timeit is a microbenchmarking thing that runs the code you've passed in a number of times equal to the number you pass in. ok I see, so that weirdo decided for some reason to obfuscate his minimal benchmarking example unnecessarily.
|
# ? Jul 30, 2022 12:17 |
|
Hammerite posted:ok I see, so that weirdo decided for some reason to obfuscate his minimal benchmarking example unnecessarily. No worse than using datetime.now instead of a purpose built method, really.
|
# ? Jul 30, 2022 12:36 |
|
Hammerite posted:why is the variable called "loop_squared"? what's "squared" about it? Every number is the square of some other number
|
# ? Jul 30, 2022 20:28 |
|
leper khan posted:No worse than using datetime.now instead of a purpose built method, really. idgi, in what way is datetime.now not a purpose built method? What's a preferred alternative?
|
# ? Jul 30, 2022 20:29 |
|
Deffon posted:yeah, the point is that datetime.datetime.now could've been changed by calling it, so Python has to do 2 extra lookups for each iteration of the loop unless you cache it. The local variable could've also been changed/deleted using some debug package, but at least it's only a single lookup. The same optimization works in lua -- os.time() is two table lookups (in the current environment to get os, then in os to get time) then a function call. Copying the function to a local first stores it in a register and means each call is just a register-to-register copy and then a function call. I assume that luajit needs this less but haven't actually checked.
|
# ? Jul 30, 2022 21:33 |
|
QuarkJets posted:Every number is the square of some other number A likely story
|
# ? Jul 31, 2022 00:09 |
|
QuarkJets posted:Every number is the square of some other number 0 isn't a square of some other number
|
# ? Jul 31, 2022 06:55 |
|
This seems like a very complex issue to try to imagine some exception for...
|
# ? Jul 31, 2022 07:05 |
|
mmkay posted:0 isn't a square of some other number -0 (not representable in go)
|
# ? Jul 31, 2022 07:15 |
|
pokeyman posted:-0 But only as a constant, if you need it you can just create 0 and then signcopy something negative into new var. Go is just so loving stupid
|
# ? Jul 31, 2022 08:35 |
|
pokeyman posted:-0 if by "number" you mean real or complex numbers then -0 is just another way of writing 0 so that is not "some other number" if by "number" you mean some flavour of IEEE floating point then -0.0 and 0.0 are indeed different on some level but then QuarkJets's original claim, that "every number is the square of some other number" is false, because -1.0 is not the square of any number! But to provide slightly less pedantic content for the thread: code:
|
# ? Jul 31, 2022 12:49 |
|
googling for anything about that is of course next to impossible, because every result is babby's first explanation of why 0.1 + 0.2 != 0.3 in IEEE floats
|
# ? Jul 31, 2022 12:56 |
|
Hammerite posted:-1.0 is not the square of any number!
|
# ? Jul 31, 2022 13:04 |
|
Hammerite posted:if by "number" you mean some flavour of IEEE floating point then -0.0 and 0.0 are indeed different on some level but then QuarkJets's original claim, that "every number is the square of some other number" is false, because -1.0 is not the square of any number! Sure it is, just not any real ones.
|
# ? Jul 31, 2022 13:04 |
|
|
# ? Jun 1, 2024 05:12 |
|
Am I being epically trolled or are neither of you capable of reading
|
# ? Jul 31, 2022 13:10 |