Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
more falafel please
Feb 26, 2005

forums poster

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.

Adbot
ADBOT LOVES YOU

Pyromancer
Apr 29, 2011

This man must look upon the fire, smell of it, warm his hands by it, stare into its heart

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

Falcon2001
Oct 10, 2004

Eat your hamburgers, Apollo.
Pillbug
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.

CPColin
Sep 9, 2003

Big ol' smile.

Falcon2001 posted:

I filed that under 'Well, I guess Oracle knows what they're doing'



that was just an incredibly stupid decision.

:hmmyes:

Wipfmetz
Oct 12, 2007

Sitzen ein oder mehrere Wipfe in einer Lore, so kann man sie ueber den Rand der Lore hinausschauen sehen.

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.

Pre-OSX Mac APIs used these a ton, for file type/creator codes for file metadata and resource identifiers.

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,
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.

more falafel please
Feb 26, 2005

forums poster

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.

Absurd Alhazred
Mar 27, 2010

by Athanatos
A great and terrible way to encode and decode file format magic numbers.

duck monster
Dec 15, 2004

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"

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

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

Falcon2001
Oct 10, 2004

Eat your hamburgers, Apollo.
Pillbug

Volmarias posted:

You misspelled lazy

I don't even know if I'd call that lazy, just bizarre.

DoctorTristan
Mar 11, 2006

I would look up into your lifeless eyes and wave, like this. Can you and your associates arrange that for me, Mr. Morden?
We’re talking about Oracle, guys.

The word you’re looking for is ‘evil’.

Macichne Leainig
Jul 26, 2012

by VG
Never attribute to malice that which can be adequately explained by stupidity.

Bongo Bill
Jan 17, 2012

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.

CPColin
Sep 9, 2003

Big ol' smile.
Also with Oracle, ¿porque no los dos?

Macichne Leainig
Jul 26, 2012

by VG
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.

CPColin
Sep 9, 2003

Big ol' smile.
Then let us die together, in battle! :black101:

hyphz
Aug 5, 2003

Number 1 Nerd Tear Farmer 2022.

Keep it up, champ.

Also you're a skeleton warrior now. Kree.
Unlockable Ben
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?

Carbon dioxide
Oct 9, 2012

Dylan16807
May 12, 2010

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.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Next time I need thirty-six million datetimes I'll be skating away while you idiots twiddle your thumbs an extra four seconds.

Carbon dioxide
Oct 9, 2012

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.

Deffon
Mar 28, 2010

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.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
why is the variable called "loop_squared"? what's "squared" about it?

mmkay
Oct 21, 2010

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 :argh:

Edit: vvvv ah, makes sense.

mmkay fucked around with this message at 17:07 on Jul 30, 2022

Jabor
Jul 16, 2010

#1 Loser at SpaceChem
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.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

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.

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.

ok I see, so that weirdo decided for some reason to obfuscate his minimal benchmarking example unnecessarily.

leper khan
Dec 28, 2010
Honest to god thinks Half Life 2 is a bad game. But at least he likes Monster Hunter.

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.

QuarkJets
Sep 8, 2008

Hammerite posted:

why is the variable called "loop_squared"? what's "squared" about it?

Every number is the square of some other number

QuarkJets
Sep 8, 2008

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?

ToxicFrog
Apr 26, 2008


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.

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

QuarkJets posted:

Every number is the square of some other number

A likely story

mmkay
Oct 21, 2010

QuarkJets posted:

Every number is the square of some other number

0 isn't a square of some other number :colbert:

Ranzear
Jul 25, 2013

This seems like a very complex issue to try to imagine some exception for...

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

mmkay posted:

0 isn't a square of some other number :colbert:

-0

(not representable in go)

Xarn
Jun 26, 2015

pokeyman posted:

-0

(not representable in go)

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 :suicide:

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe

pokeyman posted:

-0

(not representable in go)

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:
Python 3.9.5 (tags/v3.9.5:0a7dcbd, May  3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> 1.0 / 0.0
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ZeroDivisionError: float division by zero
>>>
what's with this? Shouldn't I get infinity as a result and not an exception? I thought Python floats were IEEE double-precision. Aren't they breaking the rules here?

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
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

Jigsaw
Aug 14, 2008

Hammerite posted:

-1.0 is not the square of any number!
It is if you use the power of imagination!

Bongo Bill
Jan 17, 2012

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.

Adbot
ADBOT LOVES YOU

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
Am I being epically trolled or are neither of you capable of reading

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply