#development
1 messages ยท Page 107 of 1
for all effects, it could be something completely unrelated to canvas
make it use more than 200mb?
i set mine to 500mb limit, even though it uses less than 200
800k
lmao
just found funny the question, it's basically "how many meters fit in a meter"
no idea
considering later versions of discord.js have been becoming less and less memory efficient
probably more than 200mb
i wanna use another library but
discord.js is simple and easy to use
๐
which yknow i like
regardless of the lib you'll still need to sacrifice more than 200mb
i never tried caching all members, but i remember when i ran my bot with default settings, it used like 800mb
at 9k servers
i dont think i tried running my bot on djs14 yet
me? doubt, but others can
let me try lol
tho I can definitely spot obvious issues
owner still rich tho
yeah
imagine becoming rich off your block game
๐ค
lol
ok
i am sending a lot of code
hatebin
please be aware this is quite a bit and will flood
HATEBIN
ok
or github, preferrably
bruh why github
but if you know where the issue lies then hatebin is enough
actually
because if you have no idea where the issue is, it'd be necessary to see the code as a whole
images are the worst option
hmm not that bad tbh, using 500mb after startng with discord.js 14 default settings
meanwhile me, sitting a little over 3gb
most of it comes from asset cache
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
BOOM
MY CODE
PLEASE REVIEW
pastebin ๐
sending the full msg to here is better
ads, lots of ads
ad block
also paste uses a bunch of trackers
and its blocked in some countries
// Create the canvas
const canvas = createCanvas(650, 380);
const ctx = canvas.getContext('2d');
// Set the rectangle image sizes
const rectWidth = 650;
const rectHeight = 145;
// Draw the rectangle on the canvas
ctx.strokeStyle = "#1b1b1b";
ctx.fillStyle = "#1b1b1b";
ctx.beginPath();
ctx.roundRect(0, 0, rectWidth, rectHeight, 10);
ctx.fill();
ctx.stroke();
ctx.textDrawingMode = "glyph";
// Measure the width of the title
ctx.font = '24px "Manrope Bold"';
const titleWidth = ctx.measureText(experienceData.details.name).width;
// Measure the width of the creator
ctx.font = '14px "Manrope Semibold"';
const creatorWidth = ctx.measureText('By ' + experienceData.details.creator).width;
// Check if both the title and creator can fit on the same line
// If not, only the title should be filled
if (titleWidth + creatorWidth + 30 > 500) {
ctx.fillStyle = "#d9d9d9";
ctx.font = '24px "Manrope Bold"';
ctx.fillText(truncate(experienceData.details.name, 35), 20, 37);
ctx.fillStyle = "#555555";
ctx.font = '14px "Manrope Semibold"';
} else {
ctx.fillStyle = "#d9d9d9";
ctx.font = '24px "Manrope Bold"';
ctx.fillText(experienceData.details.name, 20, 37);
ctx.fillStyle = "#555555";
ctx.font = '14px "Manrope Semibold"';
ctx.fillText('By ' + experienceData.details.creator, titleWidth + 30, 37);
};
// Fill in the credits
ctx.fillText('Made with โค๏ธ by battleless#0026', 0, 160);
// Fill in the statistic titles
ctx.font = '18px "Manrope Semibold"';
ctx.fillText('Playing', 20, 70);
ctx.fillText('Visits', 20, 100);
ctx.fillText('Favorites', 20, 130);
// Measure the width of the statistic titles
const playingWidth = ctx.measureText('Playing').width;
const visitsWidth = ctx.measureText('Visits').width;
const favoritesWidth = ctx.measureText('Favorites').width;
like turkey for some reason
ok this is one part
// Fill in the experience statistics
ctx.fillStyle = "#d9d9d9";
ctx.font = '24px "Manrope Bold"';
ctx.fillText(experienceData.statistics.playing.toLocaleString(), playingWidth + 30, 70);
ctx.fillText(experienceData.statistics.visits.toLocaleString(), visitsWidth + 30, 100);
ctx.fillText(experienceData.statistics.favorites.toLocaleString(), favoritesWidth + 30, 130);
// Load the icon into canvas
const icon = await loadImage(experienceData.details.thumbnail);
// Save the current canvas to clip again
ctx.save();
// Set the icon images sizes
const iconWeight = 115;
const iconHeight = 115;
// Round, clip then draw the icon
canvasRound(ctx, 10, 520, 15, iconWeight, iconHeight);
ctx.clip();
ctx.drawImage(icon, 520, 15, iconWeight, iconHeight);
// Restore the canvas to it's previous state
ctx.restore();
// Generate and load the chart into canvas
const chart = await generateChart({
x: labels.map(label => new Date(Math.round(label.timestamp * 1000)).toLocaleDateString(interaction.locale, options)),
y: labels.map(label => label.value)
});
const chartImg = await loadImage(chart);
// Round, clip then draw the chart
canvasRound(ctx, 10, 0, 165, 650, 215);
ctx.clip();
ctx.drawImage(chartImg, 0, 165);
const image = canvas.createPNGStream();
second part
lol taking a heap snapshot of a node process makes it use 4x more ram while snapshotting
whats growing
for what
for taking a heap snapshot
memory usage of what
of my bot
what was the initial heap size
oh
what is a heap size
taking a snapshot of 500mb makes it use 2gb+ for processing it lol
already 2.5gb lol
anyone know about my issue tho
testing djs 14 default settings on my bot
10k guilds
it's impossible to spot a leak that way
wym
there's nothing out of place, apparently
thats all my code
sounds like a lot of work
how do i do that
and how will it help
will it tell me where in my code memory is leaking?
npm install heapsnapshot
no, but it'll tell what's being kept in memory
how will that help
You have to work your way from the root tree to whatever depth to see what's being retained and where
know what's being kept = know what's excess = know the cause
a memory leak happens when something retains reference to the root scope and cannot be swept
why can't it be swept tho
i thought javascript is smart
if i'm not using it it should delete it
GC doesn't collect referenced objects
because the intention if you hold a reference is the user will want it later
@hushed robinthe first diagnosis is using process.memoryUsage()
ok
after your canvas finishes generating, log the result of process.memoryUsage()
what will that do
put in the code
where
bruh
i don't want to edit my code rn
oh nvm
i figured out how to do it
just had to do node then process.memoryUsage()
this is right now
{
rss: 37359616,
heapTotal: 7081984,
heapUsed: 5318840,
external: 1031824,
arrayBuffers: 76787
}
node simply opens a new node console
no
then you don't
i was too lazy to add one
would be easier if you used github as we told you before, you'd not need to copy the files over scp
well, expect to edit the code again, and again, and again, and again
with git you'd just need to do git add . & git commit -m "Testing" & git push (which can be saved as a script) after each edit
ok this is ridiculous
why does it take 6.5gb of ram to take a heap snapshot of 500mb
ok this is first time:
{
rss: 76943360,
heapTotal: 18800640,
heapUsed: 16544784,
external: 1169670,
arrayBuffers: 105398
}
this is after 20 times running command:
{
rss: 149000192,
heapTotal: 55173120,
heapUsed: 43716656,
external: 1581572,
arrayBuffers: 459961
perhaps node stacks are just big
heap snap needs to take a stacktrace of every single instance doesn't it?
probably
what do these numbers mean
why are they so high
they are high because it's measured in bytes
your JS memory usage increased from 16mb to 43mb, meaning what is increasing is JS memory, not native memory, meaning the problem is likely not canvas itself but something else
where u get 16mb from
heapUsed
divide by 1024 then by 1024 again
memory leak means something in memory that should have been cleaned is not being cleaned
do it enough times and even something small becomes a problem
well
if its not being cleaned it means its still being used somewhere
experienceData is from cache
bc i cache data so i don't always requesting from the api
i use lru-cache
does memory only increase like that if you use the command?
if you dont use it, it doesnt?
yes
does the command have more code besides what you have shown?
then im pretty sure the problem is elsewhere and not with canvas
e
if (timezone) {
if (!timezonesList.includes(timezone)) return interaction.editReply({
content: 'Could not validiate the provided timezone.',
ephemeral: true
});
};
// Get the experience data from the cache
let experienceData = cache.get(id);
if (experienceData === undefined) experienceData = await setExperienceCache(id);
// Some checks and stuff to see if data is up to date
// Not going to comment over all of this as it's pretty self explanatory
if (experienceData === false) {
return interaction.editReply({
content: 'Could not fetch the data for this experience.',
ephemeral: true
});
} else {
const game = database.prepare('SELECT * FROM games WHERE id = ?').get(String(id));
if (!game) {
if (experienceData.statistics.playing >= 25 && experienceData.statistics.visits >= 10000) {
database.prepare('INSERT INTO games (id, name, history) VALUES (?, ?, ?)').run(String(id), experienceData.details.name, String(1));
} else {
interaction.editReply({
content: '[(+)](<https://rostats.live>) This experience does not qualify for Rostats tracking.',
ephemeral: true
});
database.prepare('INSERT INTO games (id, name, history) VALUES (?, ?, ?)').run(String(id), experienceData.details.name, String(0));
};
} else if (game.history === '0') {
const lastHistory = database.prepare('SELECT * FROM history WHERE id = ? AND type = ? ORDER BY timestamp DESC LIMIT 1').get(String(id), 'playing');
if (!lastHistory) {
await updateSingleHistory(id);
} else if (lastHistory.timestamp <= Math.round(new Date() / 1000) - 3600) {
await updateSingleHistory(id);
};
};
};
const date = Math.round(new Date() / 1000) - 43200
const options = { timeZone: timezone || undefined, weekday: 'short', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric' };```
this is the other code
not much
you can test code independently to narrow the problem down
for example remove the line that generates the canvas, and run the command 20 times, and see what happens to memory usage
you can do the same with other parts
for example remove the line that generates the graph and run the command 20 times without it
and see how it affects memory usage
๐ต
thats called debugging
the process of investigating code issues by analysing it part by part
i don't like "debugging"
i think it's still canvas fault my code is good and should not make so much memory
debugging is 70% of coding
well that mindset wont get you far
now my question is, why does next take around 1 - 2 seconds to apply the css on some of my components
99% of coding issues are our own fault, its very rare to find issues that are not actually ours, and even when you find one, you need to do an extensive investigation to be 100% sure its someone else's fault before to start blaming them, thats how to submit a high quality bug report too
just remember: node-canvas is used by millions of people all over the world, ranging from newbies to professional experts with a huge spectrum of applications
bro
still think you, and you alone outskills all those people?
bye
reloading or realtime?
if anyone else has solution please spam me with pings
anyone knows how to get rid of it, i am using other libraries like tailwind and material-ui
like whenever i refresh
@hushed robin @hushed robin @hushed robin @hushed robin @hushed robin @hushed robin @hushed robin there
solution: git gud
cache maybe
please stop trolling
i will report you
for spam pinging me
so i'll just add a loader to await them
(and if someone else trolls i will not hesitate to report you)
Do it
or #support
Try adding a nocache header while ur finetuning the css
okay, i'll try that out
It should get the cache out of the way
@solemn latch is it just me or is Bing AI too annoying
its not quite as good as the normal chat gpt
ok
ima check
It's gotten so much worse yeah
how come?
It was insane, it's now eh
Yeah
Probably just got really expensive and limited the amount of data it can process
most likely
I use to understand how making cpu players work
I was convinced I needed to use montecarlo until gpt explained to me why it was unnecessary
I have used it to write code, and I still think it can be a valuable resource for that. but I might wait a bit longer before using it more often for writing code.
If this is the future for finding answers, so be it, I'm sick of having to use stackoverflow and deal with their ego
I use it for complex sql queries
I'm a little paranoid that it's going to give me a completely wrong answer about something and I'm going to believe it because it's convincing
Did you ever get access to gpt-4?
So usually I don't ask AI unless I'm truly desperate or just curious
I dont think thats a concern for you is it?
You're experienced enough to figure it out
I more or less meant for learning purposes
Well you shouldn't just blindly copy and paste
you should always seek to understand any code it gives you. But it also does a good job at explaining
Since I don't want to learn the wrong thing and end up believing it's true
Yeah I never use it for actually writing code, maybe sometimes for asking it a question about how to implement something or the process behind an algorithm
Yeah I've been using it for over a week
Good! It's slower, but idk if I've really put it through its paces much. I did have some sql queries it was having some trouble with this weekend. But at the same time even I was getting confused because it was working with 3 tables 
Slower was expected, but not great.
gpt-3 was kinda close to being to slow sometimes.
๐ I hope its worth it
I haven't done any side by side comparisons. But hey, apparently it's better and I'm getting it for free so I'm not gonna complain 
It did crash a couple of times on me this weekend but it came back after a couple of minutes
Honestly, side by side comparisons are kind of useless imo.
You just get a feel for how useful/better it is for yourself over time.
ah
I used 3.5 for some creative stuff
I only have a few hours with gpt itself, I swapped to bing ai as soon as I could.
and now bing-ai is kind of meh
Plugins for gpt-4 hopefully will give that kind of feature but a bit better
maybe a docs plugin?
allowing it to read doc websites?
I used gpt 3.5 to write a story about frozen peaches wanting to take a bath in some custard, and it was quite funny. And then once it finished the story, I said "now tell me the story from the custard's perspective" and it was hilarious 
lmao
Lol this is how chrome exports a web page as pdf on android apparently 
It's a little suggestive in places 
what llm isnt
I should ask chatgpt what gluten free dishes I can make with the ingredients I have at home ๐
never thought about it like that
Let's gooo!!!
GF cooking
Yeah, gotta be gluten free cus of celiac but it's actually pretty good nowadays
Gpt-4 has a plugin that you can ask for a recipe and it will add all the ingredients to an Instacart order
๐
Same
if you want
Either that or I forgot how good normal food tastes
When I was 11 and diagnosed, bread was like polystyrene. You could rub a slice of bread on a plate and it would make exactly the sound a piece of polystyrene would, squeaks and all.
GF food has come a long way 
I was 10 when I was diagnosed c:
๐
I remember one of my first gf meals was pasta
These are actually amazing.
It was awful
Plugins are going to be amazing
We were rofl at the custard's story 
Although it was Christmas and there may have been some wine involved 
Its still good sober
Yes! I just read it again and it's still funny 
man this actually sounds pretty good
I found it amazing how it was able to not only write the story, but then rewrite it under a different character's perspective. Pretty cool.
I don't have almost any of the ingredients but still
Now cook it and see if it got the quantities right 
did better than I could
Probably stole it from some website I imagine lol
It looks about right, nothing seems over the top
I need to make some new stuff to try but I'm a picky eater lol
Look at these GF pizzas and Tiramisu ๐ and the butter chicken with GF garlic and plain naans 
They were so good
my god that looks amazing
I had a real gluten free pizza from a restaurant for the first time 2 nights ago
Was absolutely delicious
I've been to lots of countries and cities around the place but Rome was the easiest place to eat out as a coeliac and had the best food by far.
Never been out of the country, I don't really travel much
Maybe one day when I have the money lol
Imagine talking about pizza in development channel or yall developing discord pizza bots Lmaoooo
is there a limit to the number of roles a server can have?
is there a way to get a list of users with a role via the api? im not seeing anything
https://discord.com/developers/docs/resources/guild#get-guild-roles
nop
sad times
its been a requested feature in like forever, but afaik never been implemented
t!top
@earnest phoenix does node 19 by any chance have crypto built-in or something?
My code on one laptop w/ node 19 works fine
On the other it requires the import w/ node 18
average discord moment
Huh? Node.js have had crypto built-in since the day it existed
Yeah, though I need to import it
Otherwise it errors out
However on 19, without import it works fine 
how do i work with the route handlers to render pages without reloading on the new nextjs beta
What you're seeing there is the browser-compatible Web Crypto API we exposed globally in Node.js v19, it's not the built-in node:crypto module
See
Right so 18 needs import and 19 doesn't
Yes but I'm very sure you're not trying to use the Web Crypto API but rather the Crypto API
Well what I'm using is https://nodejs.org/docs/latest-v19.x/api/webcrypto.html#cryptorandomuuid
Or pretty much https://nodejs.org/api/crypto.html#cryptorandomuuidoptions
Yeah
Though that needs the import
Yes but again the Crypto API and the Web Crypto API is different, and the Web Crypto API is only marked as stable in Node.js v19, so use it if you want
Ah right so without import it uses the web crypto api
Correct
Yeah then I'll say I use that 
Less imports
I've just moved my Next.JS application to my VPS and every time I run it and visit a page, it gets killed: https://cdn.hamoodihajjiri.com/2I8poIOfKg .
I'm trying to figure out why but can't since the website is EXTREMELY slow.
is there any to query to mongodb and have it to return only a field?
What do you mean?
Maybe you'll find an answer here
Hey can anyone tell me how I can gracefully stop a multiprocess process in python after the task is completed ? But the main thread still running
Itโs a flask app so I donโt wanna kill the app to stop the process, and the calling function will start the process and return a value back to the endpoint, this process will just execute and then I want it to terminate after it finishes
You have a process object, you wait for it to complete with join() and then you call terminate() on it
With flask you can use @app.before_first_request and start the process there & @app.after_request and check if it's alive, if not you can just terminate it
Aha, so I can fetch all the current child process in after request and stop the process there
I think kryp means storing the process reference somewhere that can be retrieved later
How would I know if the process task has completed or not? I want to kill it only if it has completed no
So ideally I wanna kill the process inside the calling function after the task completes
join()
no no, i want the value from the main function to return first and then spawn this process in the background
here's my code example:
background_process = multiprocessing.Process(target=__start_priority_func, args=(unique_id))
background_process.daemon = True
background_process.start()
print(background_process.pid)
def __start_priority_func(unique_id: str):
sleep(10)
print("After 10s")
def main():
start_process()
return "some value"```
this code actually runs the process in the background, but there's no clean up, i could try and use a global list and append the process there,
ig that should solve my problem
store this somewhere
can someone tell me if this will work
SELECT MAX(value)
FROM (
SELECT value, (rowid - 1) / n AS group_num
FROM my_table
WHERE (rowid - 1) % n = 0
)
GROUP BY group_num;
ok but i am not at pc
skill issue
so i wanna know if someone else knows
no
chat gpt gave me that and i wonder it its right
he said it will get the highest value of every nth row
alright so how can i store this, it says python cant store processes,
those are just objects, store like anything else
you won't be storing the process itself, you'll just store the reference
processes[unique_id] = background_process
I tried this and then tried to access it in another function with processes.get(unique_id)
But it returned None
But itโs never wrong right ๐ข
try an array instead
but well, that was supposed to work yes
Weird, itโs shows the data if I log it in the same func , wtf
help
How do you save the processes in that dictionary
def start_process(unique_id: str):
background_process = multiprocessing.Process(target=__start_priority_func, args=(unique_id))
background_process.daemon = True
background_process.start()
print(f"Spawned daemon process: {background_process.pid}")
processes[unique_id] = background_process
print("inside same func", processes.get(unique_id))
def __start_priority_func(unique_id: str):
sleep(10)
print("After 10s")
print("in calling func", processes.get(unique_id))```
This is all im doing  it says "None" when i print after 10s
Let me guess, processes is a global variable
It will always stay empty if you do it like that
ic
And using .get() returns none if the key is not found
yeah ik that
alr so i'll try moving both these funcs into one main func where i initialize processes locally
Well you've never written
global processes
in your start_processes function
So if you know it, why don't you have it
ahh i didnt know i had to use the keyword, anyway, i read somewhere that this wasn't recommended thing to do
so best is i move both these into 1 func
Using global variables isn't recommended, that's true
Though that's the solution to your question/current code
is there no other way i can do this?
It's a flask app, you can probably add variables to the app class
processes = {}
def __start_priority_func():
sleep(10)
print("After 10s")
print("in calling func", processes.get(unique_id))
# result = __get_content(prompt, "davinci")
logger.info("__start_priority_func: daemon task completed")
# Extractor.update(unique_id, {"content": json.dumps(result), "status": PROGRESSIVE_STATUS.COMPLETED})
background_process = multiprocessing.Process(target=__start_priority_func)
background_process.daemon = True
background_process.start()
print(f"Spawned daemon process: {background_process.pid}")
processes[unique_id] = background_process
print("inside same func", processes.get(unique_id))```
i see, is there a doc i can check?
I don't know, Google it
You'll most likely have to create a custom class where you inherit things from the default app class
i tried this code and ran into this error Can't pickle local object 'start_process.<locals>.__start_priority_func'
There you can add your custom variables
Well there you have exactly the same issue just as side note
but thats the entry point no
I'd rather use a global variable to be fair
ic
nah i'da rather use recommended stuff cause this needs to be production ready
so
The issues that global variables have don't really have much relevancy
its a learning for me as well anyway
using global keyword isn't ideal, when there are concurrent requests it'll most likely fail
or cause some glitchesmm
is there any other solution
guys help ๐ฑ
What do you mean
no
If u know that you should cache images instead of generating them every single time, and know how to create an image with canvas, idk what more we can give you lol
Like, u jus do it
I donโt think he knows how to use a map and I ainโt about to help him with it ๐
how do i cache them
loading them with canvas every time takes a long time
yes i know how to use .map
the fact you answered that proves you don't know what a map is
waffle, are u good with math?
ok then teach me pls
i need to cache bc loading so many times is taking forever
i need to load 9 things from api each time
command is ran
Iโd say Iโm decent, why?
trynna come up with a scalling formula for damage reduction
tho I'm struggling quite a bit with it
well, there's a little detail to it
(You can apply transformations to this if you wish as well)
like, let's say I have two cards, each has ATK and DEF, the card with higher ATK wins and the remaining value is dealt as damage
the damage reduction needs to be less effective on high values than on small values
this last detail is what's making me struggle
the intention is to make defense viable against burst damage, but not so much against chip damage
I managed to make the inverse
(high reduction on small, low reduction on big)
(1/(1 + e^x)) could work
x being defense, I imagine
Put it on desmos, it might be useful for that damage reduction
oh wait, x can no way be defense
I am lul, I use it to fine-tune formulas
๐ฆ
X is defense, Y would be the output damage multiplier
You can tweak it with certain numbers to make it output more of what youโre looking for
Depends on what your defense numbers look like
Actually let me think
Sigmoid function is definitely what you want here but I need to tweak it a bit
whats the best way to loop over an array that can dynamically change while its being ran? I have something like this but I dont think its a good solution
Iโll be back in a bit, just got out for lunch
(Probably around 30-40 mins from now)
who wants to make $2
for example, the red line represents a high damage (1800) and the green line represents a low damage (100)
the Y axis is damage reduction (%), and the X axis is the defense value
the intended scenario would be green where red is and vice versa
no
I don't need to be paid
no, I'll simply not help
this is a very serious issue
you kick people around and expect them to come help you?
to me
i did not kick u around
we are online
I cannot kick someone through the internet
i need to cache canvas image
so no need to load every time
bc load take so long
figure it out, research that topic and learn how to cache stuff
you probably didn't even try to solve that yourself
i tried seeing how to cache with no luck
I cant tell if you are serious or not
i only know how to use lru cache
the best way, honestly, would be not to loop
i am serious
I am a begineer developer
if you really need to loop it, make a copy of the array so you don't get CMEs (which isn't an error in js, but it's still a big problem)
he help other people nut not me
โน๏ธ
if anyone can help please spam me with pings
and direct messages
other people know how to be grateful
its for a queue, basically used to run async tasks in a sync function by scheduling them
and maybe the async tasks call other async tasks
i am grateful for help
i will show gratefulness by paypaling you $2
actually i have good idea
i will ask here on my alt so people dont know its me
๐ตโ๐ซ
either make a copy before looping or make the queue synchronous (which will prevent two tasks using it at the same time)
idk if u can do the latter on js
is there any library like lru cache but will last forever
if anyone knows let me know
you're really giving elon a run for his money eh
what library are you using for the api?
store the last request timestamp and compare whenever a new request from that same user is received
yes, but you'll be able to cut short
to get x requests/sec simply adjust the cooldown window
like, 500ms difference will be 2 requests/sec
250ms = 4 requests/sec
and so on
bump
I tried entering this into desmos to mess with it and see if I could figure something out and i think i entered it wrong as neither are showing
did u type the commas?
it's a bit hard to see it, but it's f(A_atk, B_atk, B_def)
but anyway, I'll leave that for later, still need some thinking on it
Not sure I understand?
like, in that chart the high damage gets reduced by ~91% at 2000 defense, while the low damage gets reduced by 60%
which is the opposite of what I was trying to achieve
average terminal developer
Oh
So high damage is reduced much less and low damage is reduced a lot more
yes, that chart shows the % reduction (instead of absolute values)
Ok let me mess around in desmos a little and Iโll try to see if I can get something to work
I tried asking gpt if it could help, but it got entirely lost
I'll rewrite the formula and send a link here
Yeah this is quite complex the way itโs defined
https://www.desmos.com/calculator/oofksx7ieh (got the coloring wrong smh)
the formula is actually quite simple, desmos makes it look fancy
Damage = (A_atk - B_atk) * Reduction
Reduction = 1 - B_def / (B_def + 10 * A_atk)
Damage = min(A_atk, Damage)
its literally one google search
considering they asked if there's an infinite lru cache lib, I doubt they even searched what a cache is
No
i am desperate i canโt figure it out
pleass bro
i need help
so mcuh help
i am in need of
Could you stop asking again and again?
Yes, and they've replied to search it up yourself?
What's so hard in understanding that?
thats not help
What's your question anyways?
you could say thwy for every question asked here
look above a little
Could you just reply with your question?
ok
here it is
๐ enjoy helping this dude, youโll see soon enough
i only know how to use lru cache tho idk how to use anything else for cache
i am understanding if theres a easy cache library
If you want to cache an image forever why not save it onto your drive and call it from there?
i donr want to xache forever
and if i do that i will still have to load it
on canvas
i want it to already be loaded bc when i load 10 images it takes too long
and you stop hating on me for no reason
"no reason"
bro
you were being mean and unhelpful
so i was mad
bc u were being mean
it's your fault
stop the defamation
It's like the one bae character all over again
whos bae
except we were trying to tell you nobody would notice the single pixel difference between two images
it was more than a single pixel
yet instead of showing what difference you were talking about you just kept saying we were blind or just lying
then u were calling me mean names acting like i'm crazy
when literally 5 people couldn't spot the difference
hi i am getting this error but i dont know what is wrong with it i dont have much experience with canvas btw
i told u many times that i was going to
but i was not at my computer
I didn't call you mean names, I called you (and will call again), delusional
that's not a mean name, that's a psychological condition
it is
is being delusional a good thing?
no
thats a bad thing
and your using it in a bad way
're
๐คฆ
and being a bad thing doesn't necessarily makes something a mean name
you simply refused to acknowledge what we were trying to tell you for 2 hours
insisting everyone would see something that was impossible to see
when the user wouldn't even have the second image to be able to compare it
Youโve fallen for the trap once again
which is the main concern
I'll say once, in a single clear tone
I have fallen for the trap more than you though
what trap he is the one who started talking to me
there is no trap
hi i am getting this error but i dont know what is wrong with it i dont have much experience with canvas btw
@hushed robin, you are a delusional, narcissistic, childish lazy troll that refuses to acknowledge your own lack of skill. You are extremelly egotistical and think the world revolves around you, and those who do something different are inherently wrong. You use people when they're useful and simply discard them afterwards.
You WILL fall deep one day and nobody will be there to help you, because of your OWN actions.
i am not reading all that
but i appreciate the effort u put into that
I do pray that one day you finally fall to the reality, but I, with no doubt, won't be there to help you get up.
though if someone has an answer to my question feel free to spam ping / dm me
what is bg?
background
me if i cared โน๏ธ
no, I mean, show the declaration
try awaiting it
okay i will try
Both should be awaited fyi
huh
are you sure the image is a png?
its saying png so yes
the url extension doesn't necessarily dictate the file format, some sites like to embed the image in an album or smth
which aren't images at all
just checked the url, it is a normal image
did u add await to it?
ye
try with this https://www.shutterstock.com/image-vector/no-image-available-icon-template-260nw-1036735678.jpg
see if it draws the image
i got the same error
weird, it was supposed to work with at least jpegs
see the docs if there's anything else u need to do
with my welcome image it is working fine but not in this command
is the code the same in both places?
Show image.js around line 50-70
(And anything relevant)
Oh wait
Iโm dumb
Thatโs a canvas stacktrace
HELP ๐
I got a message from Discord and it was this:
so I check my log and I saw this:
anyone know what should I do?
go on the developer portal and use your new token
what lib are u using?
its not invalid Token err
most libs prevent that from happening with an internal bucket
kuuhaku, okay so i tried using lists and appending the but its also still empty, global keyword also doesn't seem to be working
DiscordJS and Hybrid Sharding
kinda stuck
what's hybrid sharding?
is there no abstraction library available?
a really popular sharding library
^
i dont think so, im basically trying to run the task in the background by returning a value from the main function immediately, thats when i came accross multiprocessing, it works but i need to kill the process otherwise its gonna eat a lot of memory,
The first package which combines sharding manager & internal sharding to save a lot of resources, which allows clustering!. Latest version: 2.1.1, last published: 16 days ago. Start using discord-hybrid-sharding in your project by running npm i discord-hybrid-sharding. There are 4 other projects in the npm registry using discord-hybrid-sharding.
why not simply use d.js sharding?
wait, but that completely defeats the purpose of using another process
well, maybe they didn't add a bucket intentionally or smth then
wym, so the flow is like this
main():
// call some other func that runs in the bg aka process
return "some value" -> i use this to poll request
some_func()
// run some code here....
// runs until the main process is killed, which will not happen cause its a flask app
// so i need to kill this process after its task is complete
it was fine just randomly today this happening...
I use this lib since my bot reach 2K servers
it's quite dangerous not to have internal ratelimit management since the requests will reach discord
which can lead to stuff like what happened to u
you should make a tracker for how many times you IDENTIFY to prevent this from happening
bump
if i use prcess.join() its gonna wait until the process completes, welp
doesn't flask already handle async operations?
ay thanks, i'll look into this and see if it works for me
do you want me to send the entire code of the comamnd thats not working
it has 25 lines
i can sourcebin it for you
const Discord = require('discord.js');
const Canvas = require('canvas')
exports.run = async (bot,message,args) => {
const canvas = Canvas.createCanvas(700, 250)
const ctx = canvas.getContext("2d")
const target = message.mentions.users.first()
if(!target) return message.channel.send("Please mention someone.")
const bg = await Canvas.loadImage("https://i.ibb.co/tQJKznM/Screenshot-2023-03-26-21-51-27.png")
ctx.drawImage(bg, 0, 0, canvas.width, canvas.height)
const avatar = await Canvas.loadImage(message.author.displayAvatarURL({ format: 'png' }))
ctx.drawImage(avatar, 100, 25, 200, 200)
let atta = new Discord.AttachmentBuilder(await canvas.build(), { name: 'noor.png' })
message.channel.send(atta)
}
exports.help = {
name: 'noor'
}
put console.log("Draw BG") below the first drawImage and console.log("Draw Avatar") below the second
see if it logs the first
if it does, then the error is loading the avatar instead
okay
console is saying Draw BG
maybe i should do target.displayAvatarURL isntead
its still saying unsupported image type
console.log what displayAvatarURL is returning
then put it in the browser to see if it's indeed a png
so that would be console.log(avatar)
no, put the function inside it
tbh i dont know what you mean im sorry
do you mean console.log(target.displayAvatarURL({ format: 'png' }))
yes
it didn't log anything
Making 100% uptime software is so stressful and difficult
having to have fail over servers for deployment of services that cannot be hot reloaded is soโฆ Tedious to setup and get working
I've recently been iterating on my do all music track extractor and playback server and god am I suffering from my jank
And that is why you have dedicated tools/services/whatever it's called that do it for you
Also 100% uptime is a myth
If you just run your service with some command line or whatever else and hot reload enabled, that's bad design and nothing else 
react router is giving me so much grief
i know someone's gonna tell me to use remix (i'm currently taking this at my own pace so i considered remix router to be more suitable here) but essentially, my index route seems to smother the entire server. i have tried everything, setting an "exact" argument in the route tag, setting it as the index, and it continues to be the only thing that displays across the entire server.
the three supplied screenshots show differing urls which should return different things but instead return the noconfintro view, which is not what is in accordance with what i have written.
here's what i currently have:
<body>
<Header DiscordUser={props.DiscordUser} language={props.language} />
<Routes>
<Route path="/" exact element={<Noconfintro language={props.language} confErr={props.confErr} />} errorElement={<Error404 language={props.language} />} />
<Route path="/config" />
<Route path="/" element={<Error404 language={props.language} />} />
</Routes>
<script src="/resources/bundle.js" />
</body>```
Hello, everyone.
I'm looking someone who can migrate prestashop data from v1.7 to v8.0.2. If you think you can do this perfectly gm me DM, please.
Thanks.
Don't DM people you haven't built a rapport with. First because it's weird, and second because we would like everyone to benefit from questions that you ask. This cannot happen if the conversation is in direct messages
And prestashop most likely has migration guides of changelogs, follow them
Or someone has already attempted/done that and google will be your friend for finding that
this is the latest migration doc
how did you even miss 7 major updates? nvm, just looked at their docs, they apparently jumped from 1.7 to 8
lmao
why websockets with Js are so easy and convenient?
I'm getting too much into it
websockets are fairly simple once you understand what they are
can't speak for other languages tho, the only ones I ever used socket with were js and java
Pretty sure they are easy in all modern languages
But they're so comfortable (idk if i can use this word here
) because you can also send events to all connected clients.
I've been working with only HTTP(s) for 3y so this is a huge upgrade
the word you want is "convenient"
After
after wont work obviously
i tried to update my discord.py to newest version, and now the topggpy lib is not working
AttributeError: loop attribute cannot be accessed in non-async contexts. Consider using either an asynchronous main function and passing it to asyncio.run or using asynchronous initialisation hooks such as Client.setup_hook
is there any fix for this?
honestly, I'd suggest dropping the lib entirely and using raw http requests (or writing a wrapper yourself)
topgg api is extremely simple and straightforward
how do i make a vote reward? i dont really understand how to do it without the lib
unrelated
for that you'd use a webserver framework like flask
so i open a webhook using flask and use the hosting ip + port
then send webhook signal there?
yep
okay thanks
you simply create an endpoint and tell topgg to send requests there
don't forget to check for Authorization header to see if the requests are legit (the password u set in bot edit page)
hm, for python I don't really know, but there's the multitasking lib that adds parallelism (sorta) to python
see if there's anything on google about running flask + something
oh do you mean this then?
yes
it is sending the pfp link
does it open normally on browser?
"format" are you using discord.js v13 or v14?
i already fixed that sir i had to use extension
i will try it
how do you fix this? all edges around the background image aren't darkened
background-image: url("background.jpg");
background-size: cover;
backdrop-filter: brightness(50%);
you could use a div with background-color set to rgba(0, 0, 0, 0.5)
but well, check if there's no padding on that background
use F12 to see if there's any
by hot reload, I mean abusing the fact that my language of choice is interpreted and being able to drop module cache and then reimport the module and the changes are reflected without having to cold restart

use everything in production no matter how much pre-alpha stage it is
hot reloading in production is where real power stems
guys i need your help
Which name sounds better for a PHP library?
A) PlatinumPHP
B) KryptonPHP
C) Fluorine
I'm making a library for PHP to make it Object Oriented in an almost total way.
how total are we talking?
regarding the name, you could call it poop (php objected oriented programming)
jokes aside, idk what would be a good name

||I like this name||
idk like 50%
or 75% soon because i'm working on strings with mbstring
like, OOP has 4 pillars that must exist to be called OOP
encapsulation, abstraction, inheritance and polymorphism
KryptonPHP obviously
No meed to think twice
lol
encapsulation meaning you need to be able to create hold values within objects
abstraction meaning you need to be able to add additional processing inside value accessors, and optionally be able to prevent them from being accessed directly (js breaks this)
inheritance meaning objects should be able to inherit properties and methods from another object
polymorphism meaning objects should be able to become other objects through specialization
from what I see u fulfilled the first pillar
wdym with "additional processing inside value accessors" because the lib actually elaborate the input and have internal functions
I'll give an example in java
public class Example {
private int number;
public int getNumber() {
return number;
}
public void setNumber(int n) {
if (n < 0) n = 0;
number = n;
}
}
see how I added additional processing inside the setter? (prevent values smaller than zero from being inputted)
this abstracts the user from worrying about inputting valid numbers (or checking for them)
How does JS break that though
But side effects ๐ญ
it breaks the optional part
js has no visibility modifier
Can't you create a function in your class and also have that check implemented
so u could do example.number = -1
isn't there that thing where when doing that it executes a function you've defined
the library actually do this, preventing bad inputs and if needed correct it
the what
you can prefix field names with # and they're considered private
is that new?
but can you make objects with customized validation?
Also isn't Object.defineProperty a thing
it's been a thing for a while, not sure what standard it's a part of
Where you can overwrite the getter and setter
And make it not possible to use x.something = "blah"
I'll hop on pc in a sec
with "customized validation" dym defined by the user or the library?
the user
also what an ABYSMAL syntax to do that
i hate how you have to do that kind of stuff in JS it's just so ugly
make that a declaration site thing
js suffers from the same burden java does, but js' past makes thing much harder for it
JS itself is madness either way
backwards compat
at a certain point backwards compatibility is harmful
like prototype and its shenanigans
plus for adding new keywords in you can always implement them as contextual keywords
it makes parsing more complicated but it's also just fully backwards compatible
why does the user needs to define validation?
If he's working with the Array object the library will correct any error relying on the requirements of the object
by user I mean the developer (as in, library user not general user)
for example, if I needed to have an object that has a method to call an api and return the value, is it possible?
I still don't understand, if it is not the purpose of the object why should it be?
it's a library that adds support to oop in php right?
also ```js
class Person {
#firstName
#lastName
constructor(first, last) {
this.#firstName = first;
this.#lastName = last;
}
get FirstName() { return this.#firstName }
get LastName() { return this.#lastName }
}```
that works
which means allowing custom objects (with custom behavior)
javascript really just is roundabout java
at least javascript actually has proper getters and setters skull
hm, interesting
class Point {
#x;
#y;
constructor(x, y) {
this.#x = x;
this.#y = y;
}
setX(x) {
this.#x = x;
}
getX() {
return this.#x;
}
}
const p1 = new Point(37, 37);
p1.setX(13);
console.log(p1.getX()); // 13
p1.x = 76;
console.log(p1.getX()); // 13
With PHP you can create custom objects with custom methods, this library allows you to handle strings, arrays and associative arrays as objects
so I misunderstood your lib
I thought u were trying to add full oop support to php instead of additional objects
class Point {
#x;
#y;
constructor(x, y) {
this.#x = x;
this.#y = y;
}
get x() { return this.#x; }
set x(value) { this.#x = value; }
get y() { return this.#y; }
set y(value) { this.#y = value; }
}``` daaamn
that's so much boilerplate but yknow
The fact that it is needed to do that makes me throw up
Also why on earth # and not be normal with private
class Point
{
public int X { get; set; }
public int Y { get; set; }
public Point(int x, int y)
{
X = x;
Y = y;
}
}
``` fr makes C# look like a language that's free of boilerplate
PHP oop support is actually not that bad so nope :(
people with variable named private:
people when contextual keywords
void Example() {
var async = 4;
var await = 3;
}
async Task Example2() {
await Task.Delay(500);
}
minus the assigning void that's valid C# code
class Point {
private int x, y
void leftShift(int v) {
x = v
}
void rightShift(int v) {
y = v
}
String toString() {
return "[$x, $y]"
}
}
def p = new Point()
p << 1
print p // [1, 0]
p >> 5
print p // [1, 5]
``` 
kt?
groovy
o


