« first day (4439 days earlier)      last day (508 days later) » 

1:28 AM
cbg
Is there any shorter way to write request.session['is_dark_theme'] = not request.session['is_dark_theme']? Looks like repetition
 
1:59 AM
not inherently. Are you in control of the type that request is an instance of?
oh, wait.
assuming the value is boolean, request.session['is_dark_theme'] ^= True should do it? but that's way cryptic and ugh
 
 
2 hours later…
wim
4:15 AM
@Aran-Fey I'd say 2d vectors are the rich man's complex numbers
 
 
2 hours later…
6:11 AM
The really nice thing about complex numbers for a 2d grid is that movement is addition, and turning is multiplication.
 
 
2 hours later…
 
2 hours later…
10:12 AM
what is the suitable status code for the following case? DELETE /bar/1 but to delete bar/1 I need to have foo/1 present, so what do I return if foo/1 does not exist? 404?
returning 404 if bar/1 does not exist is straightforward, I am looking for something that is indirectly not present from client perspective
I am using FastAPI, so if that has any ways to deal with this, not sure if has, but if it does I am open to that
this is how it would look like
database = {'foo': [2], 'bar': [1, 2]}

@app.delete('/bar/{id:int}')
def delete_bar(id: int):
    if id not in database['foo']:
        # what to have here
    else:
        database['bar'].remove(id) # return 200
 
11:04 AM
Sounds like 409 Conflict would be suitable
 
 
1 hour later…
12:06 PM
thanks, I will use that, seems better than a 404
 
 
1 hour later…
1:23 PM
Hello guys
1
Q: Python Mocking - How to mock sqlalchemy query?

Naveen PandiaI want to try mocking my SQL query So far I've mocked the DB connection and validation but have not gotten any idea how to mock the query. Here's my function which I'm calling to execute queries query_functions.py CONST_INSERT = "INSERT INTO user (user_name, password, email_address, dob, address...

Any leads?
 
 
3 hours later…
4:26 PM
stackoverflow.com/questions/74527332 what happened with this duplicate closure?
 
4:46 PM
@KarlKnechtel Weird. That dupe target doesn't seem relevant. OTOH, that question looks like a badly explained homework task, so it probably should just be deleted. Maybe the expected solution to the homework task is print("asd" != "qwe") but it's hard to know without feedback from the OP.
 
Closed
I really wish I didn't spend time on the python feed. I know it's not nice to call stuff out, but good lord. I think I'll stay away again.
Heh, deleted in the meantime. Thank god.
Oh, the account is gone too. Now there's intrigue
 
5:15 PM
honestly, I feel somehow proud that I didn't post too many questions on SO. Thinking very hard before you do anything, is a pretty good thing honestly. Learning to actually appreciate MREs is a double-good thing.
I did ask some weird questions on Unix.SE though hmm
I also learned that to really ask questions that will get answers or be labeled as good, you need to think of it as if you posted stuff on your own website and did SEO to get traffic. You need to generate possibilities in your mind of what people will think based on how you formulate your post. "is using X word in the title a good idea?", "is describing things this way make people downvote it?" etc.
 
I suspect that my link just went to the question itself, rather than the answer @NordineLotfi because it's deleted, and you need certain rep to see the answer
The answer that you can't see was talking about chaining and suggested:
my_list = []
my_list.append("hello").print()
 
@roganjosh what
 
... exactly
 
5:30 PM
@roganjosh This looks suspiciously like ChatGPT.
 
I was about to say that too, but I was too busy being flabbergasted at this answer
this is ridiculous
it's like if someone ask "how can I increment a value inside a file on Linux?" and someone answer 1+file
 
@MisterMiyagi I hadn't even considered that but I can definitely see it. This is definitely going to be a scourge going forwards if that's the case :/
 
I imagine it's why deceze deleted the answer.
TBH that's the first ChatGPT answer that I've seen that is obviously nonsense. Most of them are scarily hard to spot the errors.
 
@NordineLotfi This is the full answer btw here
 
@roganjosh as Miyagi said, was definitely generated.
 
5:35 PM
I need help calculating discounted prices without being a single cent off. My input is this:
1. The discount rate, e.g. 10%
2. The total discount, e.g. 27.70€
3. A list of products, each with a price (per individual item) and quantity
How can I calculate the discounted price for each product, so that sum((p.original_price-p.discounted_price)*p.quantity for p in invoice) == 27.70?
 
and this also hurt my feeling eyes
@Aran-Fey :O interesting problem
 
@Aran-Fey This should work if the prices are in cents, no?
 
The problem is rounding. Say I've (poorly) calculated some discounts, and now I'm left with a stack of 10 items, and a discount of 15 cents. I can't split 15 cents across 10 items (that have the same price)
 
already seen this?: stackoverflow.com/questions/61250071/… I guess it might give some problems because of the use of float, but I might be wrong
 
To put it differently, I need to solve x1*q1 + x2*q2 + ... = real_price - 27.70 (where the qs are known quantities)
@NordineLotfi Calculating it for a single product is easy, my problem is that I have multiple stacks of products
 
5:44 PM
ah, got you
 
6:02 PM
@Aran-Fey when you say discount rate, do you mean: 1. that each product has a discount and thus, needs to compute the total discount from that? 2. that there is a total discount, as in, on every product, 3. total discount is for all invoices?
 
Here's an example of the obvious method giving an incorrect result. In this case the solution would be simple - decrease the discount of the 2nd product by 1 cent - but unfortunately it's not always that simple
@NordineLotfi 1. No, I get the total discount as input. I need to split it across my stacks of products. 2. The discount should be split evenly across all the products, so in the end every product should have a discount, yes. 3. There is only 1 invoice
 
got you, this make sense then
last question: is the discount applied only on products that are bigger than one (in quantity) or do they all have a discount regardless of their quantity?
just making sure since I know that in some instances, some shops only give you discounts when there a certain quantity or when it's bigger than 1
 
All products should be discounted, regardless of quantity
 
alright
 
6:20 PM
@MisterMiyagi I hadn't seen it myself, but some of the comments / answers on the various ChatGPT questions mention ChatGPT answer code using the wrong language, or weird mashups of languages.
A classic example of ChatGPT's tenuous grasp on arithmetic and logic: i.stack.imgur.com/0WsuA.png
 
I, for one, am loving the future. This is fantastic. Really, really, great.
 
@PM2Ring Hehe, saw that in one of your comments on meta. Fitting display of the emperor's clothes. ^^
But there have been some SO answers that were scary "good". As in ChatGPT processing malformed, garbage code and still managing to make the requested changes – even if it was totally insensitive to the changes an expert would have made.
 
6:38 PM
"even if it was totally insensitive to the changes an expert would have made" not sure I follow what this point is?
 
basically, I think what MM is saying is that, it does changes that an expert wouldn't have made in those specific cases (I think, feel free to correct me if it's not right)
or maybe MM meant that it doesn't take into account changes made by someone knowledgeable?
 
The fun part of the question is the answer that only MM can provide, hence why I asked :P
 
I know, It's better to hear it from the one who is supposed to answer :D just wanted to fill in the silence
I'm also curious to see if that's what MM meant or not
 
Eh, I can cope with silence. MM is a busy guy. It's better than speculating - I can already do that
 
alright, that's fair
 
6:47 PM
GPT-3 is extremely good at transforming grammar. But it has no way of judging truth. It's simply not built for that. It doesn't know what a chunk of text means, but it can transform it or continue it with something that's statistically plausible.
 
@PM2Ring it's not just about truth (eg: real-world facts) but also about the programming aspect. For example, the people who made copilot never tried to use the AST or similar thing in other languages to map each token to a meaning/ensemble of meanings. They just use the comments in the code they train against instead...
yes, as you said (and I agree too) that it's mostly giving statistically plausible output, but a lot of times, it just seems like it's doing string matching instead of matching against their weights, although both have their own problems they bring to the table anyway
I think I found more than 3 instance where I could find the 100% exact source of the output chatgpt gave me (posted them in one of the rooms here)
 
@roganjosh There were some very obvious errors in the code (including outright syntax errors) that ChatGPT completely ignored (it just copied them); just fixing those would have mostly fixed the issue OP was asking about and enabled a much simpler final fix.
 
for copilot, it's easier since the focus there is much more about code than anything else, so it's either the code or the comments that you need to search around for
 
It was the coding equivalent of performing open heart dentistry – successfully.
 
I already knew hyperdontia was a thing, but imagine for a second if it happens to this extent? I prefer not to...
 
6:57 PM
@MisterMiyagi ah, ok. My original read of your statement was that it had cleaned up obvious errors in the first pass. Now I feel worse about this tech (but at least it's not taking my job any time soon)
 
if you want to feel even worse, read the post about it that I did on meta
 
There'll just be a wheat/chaff moment sometime soon
 
@roganjosh The problem is that even when it does practically magic, you cannot trust the thing that it got everything right. It will just as convincingly tell you that 2+2 is 4 and that 2+2 is 5.
 
I'm still shocked that I got 20+ upvote on that answer on meta though. Like, I remember saying a very similar thing once, but that was on a room on meta.SE, and was insulted just for that very similar thing I said. And now, especially now that people are seeing just how bad those stuff can be, somehow people aren't insulting me but instead agreeing
weird how things works sometimes, but I'm not complaining either way
 
Meta is the pits
 
7:05 PM
do you mean that it's where bad and good things are or?
or is it like an actual looney toons style pit or something
 
A horrible place to be. Seems that even Urban Dictionary hasn't kept up with the phrase and just invented other meanings
It goes back to the old coal mines where you used to send kids (basically) off to and they just got blown up or suffocated etc. etc.
 
@roganjosh yeah, there a lot of people who invent meanings there
@roganjosh ah, so that's what you meant
 
It's just slang in the north of England, and a phrase that will probably die away
 
pardon me if this sounds wrong, but are people in England actively say "wa" instead of "water" or is it just in certain part?
I saw a youtube video about this once, but wasn't sure if this was a joke or not
 
7:22 PM
Nobody I know would say "wa" but they might say "wa'er" (with the "er" really quiet). Dropping the "t" drives me nuts
 
I see. Thanks for the reality check
there we go, found the video I was talking about: youtube.com/watch?v=GceNsojnMf0
 
lol, blocked in England. Maybe for good reason. Let's see if the company VPN works
 
It was filmed there AFAIK, so that's a bit weird
 
Nope, blocked in Ireland too. I'll have to go on my own VPN in a bit
 
the timestamp for when he says "wa" is at 0.40~ or so I think. It's probably just me though, but I did notice he just said wa'er as you mentioned earlier too, except for this part
 
7:33 PM
That's a Scottish accent; it's very different to basically all English accents
 
oh, so that's why
I saw BBC in the description and immediately thought of England...
 
Britain encompasses Scotland (for now)
 
got you
 
I can give you a link on how people speak where I'm from, though it's definitely NSFW. here
 
lol, yeah I see what you mean
 
7:44 PM
I bet a lot of Americans would need subtitles for that. ;)
 
I'm glad then, because I can understand most of that
I feel like the hardest for me right now are some Australian accents.
 
FWIW I can't understand thick Scottish accents, or thick Irish accents.... or Scouse, and Liverpool is like 30 miles away
Scouse is a very interesting dialect, built from all the old trading that went on as a major port
 
I can see what you mean by thick Scottish and Irish accents. Looked up a couple to refresh my memory and it's definitely hard to understand
 
8:06 PM
The Scottish one I'm ok with (the accent can get much stronger) but in the Irish case I'm not sure it's all English
 

« first day (4439 days earlier)      last day (508 days later) »