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
Bruegels Fuckbooks
Sep 14, 2004

Now, listen - I know the two of you are very different from each other in a lot of ways, but you have to understand that as far as Grandpa's concerned, you're both pieces of shit! Yeah. I can prove it mathematically.
Why I am I getting blamed for this third party AI company's gsps not storing in dicom server?

5 minutes later...

Oh no these assholes used group 1337 for their dicom private tag group, this is going to go great.

5 minutes later...

Oh jesus christ not only are a million type 1 tags missing, they're not validating the lengths for any of their VRs etc etc.

Adbot
ADBOT LOVES YOU

DELETE CASCADE
Oct 25, 2017

i haven't washed my penis since i jerked it to a phtotograph of george w. bush in 2003

no golang code allowed itt

Soricidus
Oct 21, 2010
freedom-hating statist shill

Bruegels Fuckbooks posted:

Why I am I getting blamed for this third party AI company's gsps not storing in dicom server?

5 minutes later...

Oh no these assholes used group 1337 for their dicom private tag group, this is going to go great.

5 minutes later...

Oh jesus christ not only are a million type 1 tags missing, they're not validating the lengths for any of their VRs etc etc.

Count yourself lucky it was 1337 not 1488

ToxicFrog
Apr 26, 2008



Look, if you want to use Forth, just use Forth, instead of doing whatever the hell this is

JawnV6
Jul 4, 2004

So hot ...
https://x.com/ataiiam/status/1765089261374914957
:smug: its so clever a human couldn't write it

Volte
Oct 4, 2004

woosh woosh
"VERY few engineers out there could write it from scratch" [citation needed]

It's not even that complicated of a type. C++ programmers are writing similar things with template behemoths and SFINAE all the time (god help them and us all). They'd probably kill to have it as easy as just a bunch of nested type-level conditionals with clearly defined and understandable conditions.

NtotheTC
Dec 31, 2007


maybe copilot said "no human should write this from scratch" and they misread it

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

JawnV6 posted:

https://x.com/ataiiam/status/1765089261374914957
:smug: its so clever a human couldn't write it

That's a lot of useless comments. Be nice if it said what the type is for and how it's used.

QuarkJets
Sep 8, 2008

Jen heir rick posted:

That's a lot of useless comments. Be nice if it said what the type is for and how it's used.

You don't get it, only an AI is capable of writing so many white-noise comments

OddObserver
Apr 3, 2009

QuarkJets posted:

You don't get it, only an AI is capable of writing so many white-noise comments

Have you never met freshman CS students?

Qwertycoatl
Dec 31, 2008

OddObserver posted:

Have you never met freshman CS students?

In highschool we had to write comments on every line, even it it was stupid poo poo like "i = i + 1; // add 1 to i"

Hammerite
Mar 9, 2007

And you don't remember what I said here, either, but it was pompous and stupid.
Jade Ear Joe
I don't know that language but that guy is very impressed with his own amazing cleverness in getting ai to write uh, whatever that pile is. looks like some metaprogramming wank

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Hammerite posted:

I don't know that language but that guy is very impressed with his own amazing cleverness in getting ai to write uh, whatever that pile is. looks like some metaprogramming wank

It's code that given a schema object generates the types defined by that schema.

I've seen very similar code (quite a bit more complex, actually) in SDKs for services that let you define your own data shapes, like CMSs or e-commerce platform.

Like, you setup your ecommerce so your products have a barcode and a dictionary of nutritional values. At build time, you download from the ecommerce a json metadata file that looks something like this (omitting quotes because I'm pooping): { barcode : string | undefined, nutritionalInfo: { type: object, attributes: number }}. You put that into a type, feed that to MappedParameterType<> and you have a reasonably strongly typed representation of a product that will update at compile time when you change the ecommerce configuration.

e: it's just a very basic xsd.exe but built into the language's type definition syntax

NihilCredo fucked around with this message at 22:31 on Mar 6, 2024

Jen heir rick
Aug 4, 2004
when a woman says something's not funny, you better not laugh your ass off

NihilCredo posted:

It's code that given a schema object generates the types defined by that schema.

I've seen very similar code (quite a bit more complex, actually) in SDKs for services that let you define your own data shapes, like CMSs or e-commerce platform.

Like, you setup your ecommerce so your products have a barcode and a dictionary of nutritional values. At build time, you download from the ecommerce a json metadata file that looks something like this (omitting quotes because I'm pooping): { barcode : string | undefined, nutritionalInfo: { type: object, attributes: number }}. You put that into a type, feed that to MappedParameterType<> and you have a reasonably strongly typed representation of a product that will update at compile time when you change the ecommerce configuration.

e: it's just a very basic xsd.exe but built into the language's type definition syntax

So the traditional way would be to have a compile step that generates types from a schema right? That's how I've done it, it can be kind of fiddly, but you can manually define a custom schema map/template in the tools I've used. If this thing messes up, I think you're just hosed. Schemas can get pretty complicated.

NihilCredo
Jun 6, 2011

iram omni possibili modo preme:
plus una illa te diffamabit, quam multæ virtutes commendabunt

Jen heir rick posted:

So the traditional way would be to have a compile step that generates types from a schema right? That's how I've done it, it can be kind of fiddly, but you can manually define a custom schema map/template in the tools I've used. If this thing messes up, I think you're just hosed. Schemas can get pretty complicated.

Pretty much. But I think you're selling it a bit short. I've definitely seen very lovely schema compilers that would just crash with a helpful "Invalid schema" error and leave you to figure out where the problem was by elimination.

A TS recursive type definition looks scary (it definitely scared me the first time), it may not be much less code than a hastily-written schema compiler, but it's definitely a LOT less code than a good schema compiler with helpful error messages and useful options. If you're working with some niche or closed service that doesn't have a large user community, you'd much rather write this than a code generator. That is an acceptable tradeoff for the cost of not having a plaintext version of each generated type (and I'm fairly sure you can still print them out if you really want, the tooltips still come from tsc.exe at the end of the day).

Though most of the time the guys running the original service are not doing anything fancy and there's no real reason they couldn't have just used XSD or JSON-Schema or any other schema definition language with an existing ecosystem.

Hammerite
Mar 9, 2007

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

NihilCredo posted:

It's code that given a schema object generates the types defined by that schema.

I've seen very similar code (quite a bit more complex, actually) in SDKs for services that let you define your own data shapes, like CMSs or e-commerce platform.

Like, you setup your ecommerce so your products have a barcode and a dictionary of nutritional values. At build time, you download from the ecommerce a json metadata file that looks something like this (omitting quotes because I'm pooping): { barcode : string | undefined, nutritionalInfo: { type: object, attributes: number }}. You put that into a type, feed that to MappedParameterType<> and you have a reasonably strongly typed representation of a product that will update at compile time when you change the ecommerce configuration.

e: it's just a very basic xsd.exe but built into the language's type definition syntax

thanks for the explanation.

My opinion re: that twitter guy's very high estimation of his own/his AI's impressiveness is unchanged.

repiv
Aug 13, 2009

https://twitter.com/dankuntz/status/1765445935407235252

OddObserver
Apr 3, 2009

Hammerite posted:

thanks for the explanation.

My opinion re: that twitter guy's very high estimation of his own/his AI's impressiveness is unchanged.

I imagine there must be a way of writing the mapping in a way that's actually readable and reviewable?

shame on an IGA
Apr 8, 2005


TIL about python prepopulating integer objects for every value between -5 and 256 every time you run a program

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

shame on an IGA posted:

TIL about python prepopulating integer objects for every value between -5 and 256 every time you run a program

there was no other way for them to increase performance

Erg
Oct 31, 2010


lol

GABA ghoul
Oct 29, 2011


Htbh, but I would not approve this in a pull request because it clearly doesn't work if you pass a 0(which is even). AI still has a long way to go before it can replace a real developer

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

GABA ghoul posted:

Htbh, but I would not approve this in a pull request because it clearly doesn't work if you pass a 0(which is even). AI still has a long way to go before it can replace a real developer

or any negative numbers, despite signed input

OddObserver
Apr 3, 2009

leper khan posted:

or any negative numbers, despite signed input

Stuff like that is why I always use Peano numerals. Leads to a beautiful recursive definition of IsEven, too!

MrMoo
Sep 14, 2000

JawnV6 posted:

https://x.com/ataiiam/status/1765089261374914957
:smug: its so clever a human couldn't write it

Hold by beer, I got this,
JavaScript code:
type MappedParameterTypes = any;

GABA ghoul
Oct 29, 2011

leper khan posted:

or any negative numbers, despite signed input

I think there is a very clever solution for this that could save a lot of work

code:

if (number < 0)
 number = int.Parse(number.ToString().Replace('-', ''))

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

GABA ghoul posted:

I think there is a very clever solution for this that could save a lot of work

code:

if (number < 0)
 number = int.Parse(number.ToString().Replace('-', ''))

theres code like this in my current project and i dont have enough pull to get the person who wrote it on PIP

Volmarias
Dec 31, 2002

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

GABA ghoul posted:

I think there is a very clever solution for this that could save a lot of work

code:

if (number < 0)
 number = int.Parse(number.ToString().Replace('-', ''))

:thunk:

Doesn't look like anything to me!

Qwertycoatl
Dec 31, 2008

I have literally seen
code:
is_odd = (number / 2).ToString().Contains('.')

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen
code:
is_even = x => !((x|0)&1);

is_even(0); // true
is_even(1); // false
is_even(-1.5); // false
is_even(-2.5); // true
is_even(Math.PI+10); // false
is_even(Infinity); // true
is_even("3.14"); // false
is_even("even"); // true
is_even("odd"); // true
Hrm.

QuarkJets
Sep 8, 2008


lmao this one is great

repiv
Aug 13, 2009

someone in the replies offered an improved version

Zopotantor
Feb 24, 2013

...und ist er drin dann lassen wir ihn niemals wieder raus...

Not shown: this part.
code:
  else if (number == 42068) return true;
  else if (number == 42069) return true; // nice!
  else if (number == 42070) return true;

F_Shit_Fitzgerald
Feb 2, 2017



Long before I was aware of modulo (one of the all-purpose tools in a programmer's toolbox), I came up with what seemed at the time like a foolproof method for determining divisibility:

1. Divide a number by its possible divisor (e.g: 172 / 5).
2. Convert the result into a string.
3. Iterate through the string to look for a decimal.
4. If no decimal is found, the number is divisible.

e: I didn't read Qwertycoatl's post closely enough. Guess I was on the right track if variations of this trick have been seen in "real" production code.

F_Shit_Fitzgerald fucked around with this message at 22:22 on Mar 7, 2024

ultrafilter
Aug 23, 2007

It's okay if you have any questions.


code:
bool divides(int x, int y)
{
    return (int) (y / (float) x) * x == y;
}

Qwertycoatl
Dec 31, 2008

code:
bool is_even(unsigned int x) {
  for (unsigned int i = 0; i < x; i++) {
     x *= x;
  }
  return !x;
}

GABA ghoul
Oct 29, 2011

Qwertycoatl posted:

I have literally seen
code:
is_odd = (number / 2).ToString().Contains('.')

:love:

I love this so much, especially because it doesn't even work if you execute it on a German Windows

So here is the correct version that is actually safe to deploy internationally

code:


string decimalSeparator = Directory.Exists("C:\\Programme") ? "," : ".";

is_odd = (number / 2).ToString().Contains(decimalSeparator);

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

GABA ghoul posted:

:love:

I love this so much, especially because it doesn't even work if you execute it on a German Windows

So here is the correct version that is actually safe to deploy internationally

code:


string decimalSeparator = Directory.Exists("C:\\Programme") ? "," : ".";

is_odd = (number / 2).ToString().Contains(decimalSeparator);

fail PR. use "." and the invariant cultureinfo

GABA ghoul
Oct 29, 2011

leper khan posted:

fail PR. use "." and the invariant cultureinfo

whoa, buddy, what kind of thread do you think this is? We don't look kindly on that kind of code in here :toughguy:

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

GABA ghoul posted:

:love:

I love this so much, especially because it doesn't even work if you execute it on a German Windows

So here is the correct version that is actually safe to deploy internationally

code:

string decimalSeparator = Directory.Exists("C:\\Programme") ? "," : ".";

is_odd = (number / 2).ToString().Contains(decimalSeparator);

lol

our company several years ago bought another tiny company that had a valuable client list but was run by three old guys who all wanted to retire. two of them were self taught programmers. one of the in-house pieces of software they used operated in two different modes, because the two of them had different preferences. it decided which mode to operate in based on whether there was a folder on the C drive named "hp", because one of them had a hp laptop. (i might be misremembering, I think it was hp, it might have been some other company.)

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