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
Finster Dexter
Oct 20, 2014

Beyond is Finster's mad vision of Earth transformed.

AWWNAW posted:

I used to get codeine syrup for sore throats from urgent care clinics but Ive noticed in the past few years they just write me some antibiotics and tell me to take ibuprofen then I say excuse me did you just tell me to go gently caress my self?

Oh were you the med student sitting in on my dr appt yesterday??

Adbot
ADBOT LOVES YOU

Glorgnole
Oct 23, 2012

does anyone around here work with CUDA?

I have some code for integrating depth images into a truncated signed distance field that was developed under cuda 8.0, and I'd like to use it with cuda 10.0, but something broke between 8.0 and 9.2. no build or runtime errors, but the image data doesn't get integrated into the device memory anymore (i.e. it doesn't work, for mysterious reasons).

the project uses half floats pretty extensively so I suspect that there was a change to float-to-half conversion beyond the removal of the __float2half_rn() built-in. interesting in finding out if anyone else has run into this sort of thing, and where else to look for answers.

Nomnom Cookie
Aug 30, 2009



jit bull transpile posted:

yeah it's not the language itself that's a problem. it's the temple of moral degenerates who worship it that are.

CanBuildFrom

redleader
Aug 18, 2005

Engage according to operational parameters

thanks!

floatman
Mar 17, 2009
Oh yeahhhhh
first, imagine a class called Result. You can create a new result, and the constructor has an argument where you can shove in a constant. So you can do:
new Result(TypeFailed), new Result(TypePassed).
This result has a getType function to retrieve the result as well.
Now, imagine someone creates a class called ResultPassed, which inherits from Result. It also has a constructor where you can specify the constant. So although it is meant to represent a passed result, nobody is stopping you from doing new ResultPassed(TypeFailed).

In the codebase, sometimes a passed result is checked by calling ResultPassed.getType(). Other times, a passed result is check by checking if the result object is of type ResultPassed. There is no consistency, and I've lost my will to live.

AggressivelyStupid
Jan 9, 2012

floatman posted:

Oh yeahhhhh
first, imagine a class called Result. You can create a new result, and the constructor has an argument where you can shove in a constant. So you can do:
new Result(TypeFailed), new Result(TypePassed).
This result has a getType function to retrieve the result as well.
Now, imagine someone creates a class called ResultPassed, which inherits from Result. It also has a constructor where you can specify the constant. So although it is meant to represent a passed result, nobody is stopping you from doing new ResultPassed(TypeFailed).

In the codebase, sometimes a passed result is checked by calling ResultPassed.getType(). Other times, a passed result is check by checking if the result object is of type ResultPassed. There is no consistency, and I've lost my will to live.

this sounds bad

ThePeavstenator
Dec 18, 2012

:burger::burger::burger::burger::burger:

Establish the Buns

:burger::burger::burger::burger::burger:

floatman posted:

Oh yeahhhhh
first, imagine a class called Result. You can create a new result, and the constructor has an argument where you can shove in a constant. So you can do:
new Result(TypeFailed), new Result(TypePassed).
This result has a getType function to retrieve the result as well.
Now, imagine someone creates a class called ResultPassed, which inherits from Result. It also has a constructor where you can specify the constant. So although it is meant to represent a passed result, nobody is stopping you from doing new ResultPassed(TypeFailed).

In the codebase, sometimes a passed result is checked by calling ResultPassed.getType(). Other times, a passed result is check by checking if the result object is of type ResultPassed. There is no consistency, and I've lost my will to live.

this is why discriminated unions are good

ThePeavstenator
Dec 18, 2012

:burger::burger::burger::burger::burger:

Establish the Buns

:burger::burger::burger::burger::burger:
the discriminated union I'm talking about is between programmers and computers

floatman
Mar 17, 2009

It's amazing that a user of the name "AggressivlyStupid" can identify that it is problematic, yet the "code craftsmanship culture" here apparently is all okay with it.

redleader
Aug 18, 2005

Engage according to operational parameters
yes, semantically a failed passed result is perfectly logical and furthermore,

MrMoo
Sep 14, 2000

Working with Boost.ASIO and Boost.Beast this week. Yesterday I get a TLS server up and running and today HTTPS, I'm getting the distinct impression the API is worse than Perl in number of permutations of doing the same thing. Every example and usage is annoyingly different.

Illusive Fuck Man
Jul 5, 2004
RIP John McCain feel better xoxo 💋 🙏
Taco Defender

MrMoo posted:

Working with Boost.ASIO and Boost.Beast this week. Yesterday I get a TLS server up and running and today HTTPS, I'm getting the distinct impression the API is worse than Perl in number of permutations of doing the same thing. Every example and usage is annoyingly different.

Asio is a piss template hell api. I'm sure it's very efficient and zero-overhead or whatever but the code you have to write to make things work is loving incomprehensible to anyone who hasn't spent hours studying the docs.

I am not an asio expert, but one option to simplify things: figure out exactly what concurrency model you want to use, and just bake that into your code everywhere. Don't try to make things too flexible. Ie: if you're going to spawn a coroutine for every incoming connection, you're gonna need to plumb a yield_context& parameter through hella functions and you should just live with that.

Once you've got the hang of asio, beast's http stuff feels straightforward but barebones. It's like, here's a struct with a field for each part of the http request. beast will serialize it on the wire for you. Go look at the RFC if you want to know how the connection-token and keep-alive header should be handled by your code.

Nomnom Cookie
Aug 30, 2009



Illusive gently caress Man posted:

Asio is a piss template hell api. I'm sure it's very efficient and zero-overhead or whatever but the code you have to write to make things work is loving incomprehensible to anyone who hasn't spent hours studying the docs.

now see if you used rust it would be like that but memory-safe

gonadic io
Feb 16, 2011

>>=

Kevin Mitnick P.E. posted:

now see if you used rust it would be like that but memory-safe

Also your code wouldn't compile until you'd spend hours reading the docs

Maximum Leader
Dec 5, 2014
i have a basic parent/child relationship in a database where i need to perform a basic join, problem is that the database is turbofucked by horrible decisions. the parent has fields parent/child relationship 1 through 12 containing a reference to the child instead of just putting the reference to the parent on the child. im at a loss with this, any advice guys?

Luigi Thirty
Apr 30, 2006

Emergency confection port.

terrible programmer status: risc-v business

Oneiros
Jan 12, 2007


Maximum Leader posted:

i have a basic parent/child relationship in a database where i need to perform a basic join, problem is that the database is turbofucked by horrible decisions. the parent has fields parent/child relationship 1 through 12 containing a reference to the child instead of just putting the reference to the parent on the child. im at a loss with this, any advice guys?

fire your dba or whoever is responsible for that atrocity into the sun

Soricidus
Oct 21, 2010
freedom-hating statist shill

Maximum Leader posted:

i have a basic parent/child relationship in a database where i need to perform a basic join, problem is that the database is turbofucked by horrible decisions. the parent has fields parent/child relationship 1 through 12 containing a reference to the child instead of just putting the reference to the parent on the child. im at a loss with this, any advice guys?

have you considered blockchain

dick traceroute
Feb 24, 2010

Open the pod bay doors, Hal.
Grimey Drawer
Maybe regex

Maximum Leader
Dec 5, 2014

Oneiros posted:

fire your dba or whoever is responsible for that atrocity into the sun

its jira so i cant really do anything about it, its not really critical but i would like to query the data i need

Soricidus posted:

have you considered blockchain

dont worry, im always considering the blockchain

redleader
Aug 18, 2005

Engage according to operational parameters

Maximum Leader posted:

i have a basic parent/child relationship in a database where i need to perform a basic join, problem is that the database is turbofucked by horrible decisions. the parent has fields parent/child relationship 1 through 12 containing a reference to the child instead of just putting the reference to the parent on the child. im at a loss with this, any advice guys?


SQL code:

select *
from parent p
inner join (
    select parentId, child1 as childId from parent
    /*union*/ select parentId, child2 from parent
    /*union*/ etc
    /* you could maybe put some where clauses in here if your db optimiser sucks */
) q on q.parentId = p.parentId
inner join children c on c.id = q.childId
where p.parentId = 219

uncomment those unions - i needed to do that to bypass the waf (lmao)

or, and i know you can't do this (because otherwise you wouldn't be asking), unfuck the schema. get business buy-in by making a big deal about the 12 child limit

Sagacity
May 2, 2003
Hopefully my epitaph will be funnier than my custom title.

Maximum Leader posted:

i have a basic parent/child relationship in a database where i need to perform a basic join, problem is that the database is turbofucked by horrible decisions. the parent has fields parent/child relationship 1 through 12 containing a reference to the child instead of just putting the reference to the parent on the child. im at a loss with this, any advice guys?

code:
select * from children c where c.id in (select p.child1, p.child2, p.child3, p.child4, p.child5 from parent p where p.id = parent_id)
~declarative~

Chalks
Sep 30, 2009

Sagacity posted:

code:
select * from children c where c.id in (select p.child1, p.child2, p.child3, p.child4, p.child5 from parent p where p.id = parent_id)
~declarative~

wait, in statements work with multiple columns?

redleader
Aug 18, 2005

Engage according to operational parameters
whoops

redleader
Aug 18, 2005

Engage according to operational parameters

Chalks posted:

wait, in statements work with multiple columns?

maybe in some dbs? i'm reasonably sure that sql server will error out

ynohtna
Feb 16, 2007

backwoods compatible
Illegal Hen

redleader posted:

or, and i know you can't do this (because otherwise you wouldn't be asking), unfuck the schema. get business buy-in by making a big deal about the 12 child limit

congrats on the arrival of new columns child13...child99

Chalks
Sep 30, 2009

redleader posted:

maybe in some dbs? i'm reasonably sure that sql server will error out

it would be awesome if it did but it doesn't in work in any dbs i use :(

redleader
Aug 18, 2005

Engage according to operational parameters

ynohtna posted:

congrats on the arrival of new columns child13...child99

hope springs eternal

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER

Sagacity posted:

code:
select * from children c where c.id in (select p.child1, p.child2, p.child3, p.child4, p.child5 from parent p where p.id = parent_id)
~declarative~

for my next trick i will make this sql database performance .. disappear!

distortion park
Apr 25, 2011


Do a string concatenation then a substring index

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slgt skal flge slgters gang



dump database to text and use grep

then delete everything and quit your job

cowboy beepboop
Feb 24, 2001


Maximum Leader posted:

i have a basic parent/child relationship in a database where i need to perform a basic join, problem is that the database is turbofucked by horrible decisions. the parent has fields parent/child relationship 1 through 12 containing a reference to the child instead of just putting the reference to the parent on the child. im at a loss with this, any advice guys?

gross

cowboy beepboop
Feb 24, 2001


ynohtna posted:

congrats on the arrival of new columns child13...child99

redleader
Aug 18, 2005

Engage according to operational parameters

Boiled Water posted:

for my next trick i will make this sql database performance .. disappear!

nah, any half decent query planner will optimise this to an inner join (that is, of course, if this code actually worked like it looks like it should)

Powerful Two-Hander
Mar 10, 2004

Mods please change my name to "Tooter Skeleton" TIA.


sql server has a pivot function that can maybe be used for this to shift your rowset to columns so that an in() will work but I'll be damned if I know how to use it

you're already damned so maybe it will work for you though?

champagne posting
Apr 5, 2006

YOU ARE A BRAIN
IN A BUNKER

redleader posted:

nah, any half decent query planner will optimise this to an inner join (that is, of course, if this code actually worked like it looks like it should)

i think we have firmly established this is not the case

Maximum Leader
Dec 5, 2014

redleader posted:

SQL code:
select *
from parent p
inner join (
    select parentId, child1 as childId from parent
    /*union*/ select parentId, child2 from parent
    /*union*/ etc
    /* you could maybe put some where clauses in here if your db optimiser sucks */
) q on q.parentId = p.parentId
inner join children c on c.id = q.childId
where p.parentId = 219
uncomment those unions - i needed to do that to bypass the waf (lmao)

or, and i know you can't do this (because otherwise you wouldn't be asking), unfuck the schema. get business buy-in by making a big deal about the 12 child limit

thanks buddy, this worked except for the column alias. sqlite doesn't like when you reference a column alias for some reason. to put a cherry of terrible on top of this heaping pile of awful, i'm actually exporting csvs from jira, loading them into excel then using an sql addon to query the sheets.

Sagacity posted:

code:
select * from children c where c.id in (select p.child1, p.child2, p.child3, p.child4, p.child5 from parent p where p.id = parent_id)
~declarative~

i like the idea but im getting "sub-select returns 12 columns - expected 1" in sqlite. it doesn't really look like a join to me but maybe im missing something?

TheFluff
Dec 13, 2006

FRIENDS, LISTEN TO ME
I AM A SEAGULL
OF WEALTH AND TASTE

Powerful Two-Hander posted:

sql server has a pivot function that can maybe be used for this to shift your rowset to columns so that an in() will work but I'll be damned if I know how to use it

you're already damned so maybe it will work for you though?

SQL code:
SELECT *
FROM terrible_children
WHERE terrible_children.id IN (
  SELECT unpivoted_child_id
  FROM terrible_parent
  UNPIVOT (
    unpivoted_child_id FOR child_id_col IN (
      child_id_1, child_id_2, child_id_3 /* ... */
    )
  )
  WHERE terrible_parent.id = :parent_id
)
not tested. buuuut it's sqlite so it doesn't matter, it doesn't have unpivot. when you use unpivot you get one row in the result for each unpivoted column. unpivoted_child_id becomes a column where the values from the unpivoted columns end up, child_id_col becomes a column where the name of the unpivoted column ends up.

either way OP said he wanted an actual join so this doesn't even do what i think he wants. if you only want columns from one of the tables though (that is, you're using the join only to check for existence in the related table), then you should usually use a semi-join instead (usually written as WHERE EXISTS (subquery goes here)). it's easier for the planner to optimize, it doesn't duplicate, and it's usually easier to write if you have a complex join condition.

TheFluff fucked around with this message at 14:32 on Nov 28, 2018

Chalks
Sep 30, 2009

I think the solution is probably to restructure your database so it's not the worst. Maybe create a view of the bad data structure so that poo poo that looks at it still functions.

If your database is fancy, you can even use triggers to allow inserts and updates on your view.

Then promise yourself that you'll eventually get around to decommissioning this giant hack but never actually do it

Chalks fucked around with this message at 15:28 on Nov 28, 2018

Adbot
ADBOT LOVES YOU

Sapozhnik
Jan 2, 2005

Nap Ghost

Luigi Thirty posted:

terrible programmer status: risc-v business

:frogon:

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