« first day (4834 days earlier)      last day (338 days later) » 

user22676652
00:03
hello, could anyone help me please? i am making a discord bot that can show the verses of the Quran, and I am trying to figure out how to be able to constantly change the value of a variable. I have been trying to figure this out for a while but to no avail. the only way i found out was to use them as global variables but their values stay the same, which i do not want. I would ask on stack overflow normally, but I was question banned, so i came here for help. i tried editing my variable like this:
02:42
@zoomingspeed :57000371 If you got question-banned on SO, read the reasons for being banned. Like, I see you asked duplicate questions, also make sure your questions always have reproducible code example (MCVE). v = v + 1 does indeed only add one not two, so use print(v) copiously to see what's happening. And you'd need to show more code than just that one line to figure out what's happening.
Also please see the room rules ; one rule is not to promote questions (from SO) here until they are at least 48h old.
 
6 hours later…
08:17
Has anyone else experienced CDN issues this morning? I've had a full 10 minutes where about 50% of sites (including SO and wikipedia) wouldn't load and all the rest loaded just fine. It looked like a major outage and some sites are still struggling
08:28
Everything seems to load fine for me
09:05
It's been stable since but I had two separate "blackouts". I thought we might be in for another fun day of the internet being on fire
 
1 hour later…
10:06
@roganjosh no, we have aws for compute and snowflake/s3 for storage
In that case, my suggestion would be to stay in the aws ecosystem. My experience of pyspark has not been great at all, on top of all the other difficulties. I can't really use any of my experience with pandas/polars to understand how to do pretty much anything, so I have to look up every operation from scratch (logically it's the same, but the API is not)
Our clusters frequently need restarting for reasons unknown to me (and if you blow the RAM, which you can't know a priori, you have to start your notebook again from scratch. On top of this, the pseudo-SQL aspects baffle me - with AWS you'd at least have redshift possibilities on hand, which is easily my favourite DB so far for mega data processing. For everything I've had to do so far, I can get polars running on my laptop to blow the spark capabilities out of the water
Snowflake would be the same too as a replacement for redshift. The only thing that makes me suspicious about snowflake is that the dialect is incompatible with any other RDBMS that I know of, and their low cost is a draw. My theory is that they're biding their time to get buy-in and then will hike the prices, at which point you're kinda locked in. But at least it's generally SQL with real tables
And you get athena for your S3 storage. I haven't used it but Sagemaker is a clear standout for me here
Plus when an angry roganjosh comes knocking, you can just give me a plain old EC2 box and shut me up :P
10:32
awesome, thanks
 
3 hours later…
user22676652
13:21
@smci this was not a question posted on stack overflow. i read the reasons for being banned and tried to fix it but to no avail either. I would send the function, but it is kind of long.
@zoomingspeed you can use a code paste site and link here. See also our rules
user22676652
should i send the entire command?
user22676652
@AndrasDeak--СлаваУкраїні
sorry, I don't understand your question
user22676652
should i send all the code for the whole command so you can look deeper into it? also it adds one as requested, but it doesn't keep adding one @AndrasDeak--СлаваУкраїні
[root@miyagicorpserver ~]# yum list python3.11
...
Available Packages
python3.11.x86_64
squee
@MisterMiyagi woop woop
@zoomingspeed is your verse a variable at top level?
user22676652
its the argument i provided with async def qurantest
user22676652
but i have the variable equal what the user puts
user22676652
13:41
and if i set the verse/surah variable as a local one then when i run the program whoever sets its value first, everyone running the command will get the same one the user first called and everyone will be editing that local variable
@zoomingspeed ah, right, sorry
user22676652
i want to be able to edit a variable inside an asynchronous function just like how you are able to edit a global variable using variable += int
user22676652
if i do that with a variable inside a function it gives me an error
@zoomingspeed that also only works if you do global variable first
@zoomingspeed because you are mixing local variables and references to nonlocal ones
I'm on mobile, sorry, can't explain right now.
user22676652
yeah thats what i do
user22676652
13:44
i tried using global verse_variable and the same with surah variable
user22676652
and it results in what i explained earlier
user22676652
making the surah/verse variable global makes it work when i click Next/Previous Verse button or Next/Previous Surah button, but once someone tries editing that global variable when they click next or previous verse/surah, the variable gets set to the one that was initiated first by whoever first calls the command
I know basically nothing about discord but, being a web-based program, global variables are usually a terrible idea
Yeah, this sounds like state that should live on a type
user22676652
so for example say i set the surah int to 1 and the verse variable to 2, the buttons work as expected but when trying to call it again using different variables (say i called it again but this time i did surah int as 2 and verse as 3), if i click the next or previous button for surah or verse, it automatically edits the variables that i set first
user22676652
13:48
@roganjosh i learned this the hard way 😅
You might be able to save the state in a user session as a cookie but I can't find that particular bit of functionality from a scan and I don't have much spare time to search now
You need to store the position against the client session, not globally on the backend
user22676652
ive been thinking about trying this in three formats
user22676652
a. json file
b. data base
c. global dict variable
Ditch (a) and (c)
user22676652
i already have a database on supabase.com
user22676652
13:52
but idk how to use it :p
If it's just a lightweight piece of kit you're building, I'd find a way to get the session id and you could even get away with a local sqlite3 db just to test it out quick
user22676652
i could try making session ids...
user22676652
but its not about sessions its really about like
user22676652
just editing variables in a function thats all i really wanna do
You store the variable in the db against the session id. When you want to increment it, query the db for the int value stored against that session, increment it, and write back the new value
user22676652
13:54
pardon me but im particularly new
user22676652
so simplify what you just said
The purpose of a database is just like a super-optimised excel spreadsheet. In it you have two columns - "session id" and "page number". When you need to get a value, you pass the session id to your function and ask for the corresponding page number at the start of your function. It will give you back the numeric page number. Add or subtract 1 from it, update the database for that session, and then return the new value
user22676652
ok
user22676652
could i try to explain what i want in further detail before trying this out
user22676652
its not that this isnt helpful just that i want to try one more time to see if i can update my variable in a function
13:59
You can try but I'm not sure how much help I will be having never used discord
user22676652
paste.ofcode.org/6vFadvB2FcW6MmYM6en9Dh looking at this code, i have buttons for a next verse, previous verse, next chapter, and previous chapter
user22676652
if i use a global variable, then every time i click next verse, it always adds one everytime i click it once
user22676652
but using this code, whenever i continue clicking next verse after I click once, it doesnt go further.
user22676652
and clicking previous verse subtracts two from the integer that i called in the command
There is no chance I can debug any of that. It's 200 lines of dense code in a context I don't understand sorry
user22676652
14:02
alright
user22676652
@AndrasDeak--СлаваУкраїні do you have any solutions besides a data base?
You would be better just making a simple mini example for the feature you want and testing on that
All you want is a button to add or subtract 1 from some number. The verses are completely irrelevant to that functionality
user22676652
the code i provided, i use a third party package that displays the verse based on the chapter and verse
user22676652
should i try something like this? stackoverflow.com/questions/65397197/…
Something like that at least. That's the kind of bare-bones example where you remove all the noise and just focus on the one bit of functionality you want to implement in a little test case. For all the rest of us, it doesn't matter how simple your 3rd party package it, we don't understand it and it just dominates the screen. We ALL know already that you can get a verse by number, so we don't need to see that machinery, just the bit that increments/decrements an integer
Not only does it help others understand, but it will help you too. Now all you care about is whether the number went up by 1 or 2 in every change you make to the code. Once it's working, port your new found knowledge to your actual code
user22676652
14:09
it goes up by one but using previous verse decrements by two
user22676652
and after clicking the decrementing button once, it adds two after you click the incrementing button
user22676652
is what im essentially saying
user22676652
and it doesnt continue incrementing after i continue clicking next verse more than once. clicking it once adds one but no more than that
I've gone to great lengths to try explain how you can debug this yourself, how you might implement an approach with a database, and how we will struggle to debug any example you have given. I have to get back to work.
user22676652
ok have a good day
user22676652
17:04
Hello guys, how do I import choices when calling my slash commands as bot.slash_command()?
20:22
@zoomingspeed You will need to give a more complete code example for us to answer your question.
20:38
@roganjosh noticed that on my end too, thought I was crazy
20:49
It didn't seem to be cloudflare but that's the only one I know of when half the interwebs dies

« first day (4834 days earlier)      last day (338 days later) »