#development

1 messages ยท Page 107 of 1

hushed robin
#

when someone is using my bot and it restarts bc over 200mb

lyric mountain
#

for all effects, it could be something completely unrelated to canvas

hushed robin
#

their prompt cancels bc i use collectors

#

which sucks

quartz kindle
#

make it use more than 200mb?

#

i set mine to 500mb limit, even though it uses less than 200

hushed robin
#

no 200mb is already a lot

#

how much memory would caching 800k memory cost me

lyric mountain
#

800k

quartz kindle
#

800k what

#

potatoes?

lyric mountain
#

lmao

hushed robin
#

oh

#

discord members

quartz kindle
#

probably a lot

#

i dont cache members at all

lyric mountain
#

just found funny the question, it's basically "how many meters fit in a meter"

hushed robin
#

how much

quartz kindle
#

no idea

#

considering later versions of discord.js have been becoming less and less memory efficient

hushed robin
#

yes i know

#

my bot uses so much fucking memory

#

discord.js sucks

quartz kindle
#

probably more than 200mb

hushed robin
#

i wanna use another library but

#

discord.js is simple and easy to use

#

๐Ÿ˜

#

which yknow i like

lyric mountain
#

regardless of the lib you'll still need to sacrifice more than 200mb

quartz kindle
#

i never tried caching all members, but i remember when i ran my bot with default settings, it used like 800mb

#

at 9k servers

hushed robin
#

bruh

#

if i send my code can you find problem ???!?!?!?!?!??

quartz kindle
#

i dont think i tried running my bot on djs14 yet

lyric mountain
#

me? doubt, but others can

quartz kindle
#

let me try lol

hushed robin
#

ok

#

i will send

#

in one moment

lyric mountain
#

tho I can definitely spot obvious issues

spark flint
#

so much lower than it used to be

hushed robin
#

owner still rich tho

spark flint
#

yeah

hushed robin
#

imagine becoming rich off your block game

#

๐Ÿค‘

#

lol

#

ok

#

i am sending a lot of code

lyric mountain
#

hatebin

hushed robin
#

please be aware this is quite a bit and will flood

lyric mountain
#

HATEBIN

hushed robin
#

ok

lyric mountain
#

or github, preferrably

hushed robin
#

bruh why github

lyric mountain
#

but if you know where the issue lies then hatebin is enough

hushed robin
#

actually

lyric mountain
hushed robin
#

imma just send images

#

it will be easier

lyric mountain
#

images are the worst option

hushed robin
#

ok

#

er

#

this is quite difficult

#

my code is messy

quartz kindle
#

hmm not that bad tbh, using 500mb after startng with discord.js 14 default settings

lyric mountain
#

meanwhile me, sitting a little over 3gb

quartz kindle
#

xD

#

10113 guilds

lyric mountain
#

most of it comes from asset cache

hushed robin
#

BOOM

#

MY CODE

#

PLEASE REVIEW

lyric mountain
#

pastebin ๐Ÿ˜”

hushed robin
#

whats wrong with it

#

i don't trust hatebin

earnest phoenix
#

sending the full msg to here is better

hushed robin
#

the code?

#

ok

#

one second

lyric mountain
hushed robin
#

ad block

lyric mountain
#

also paste uses a bunch of trackers

earnest phoenix
hushed robin
#
// 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;
earnest phoenix
#

like turkey for some reason

hushed robin
#

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

quartz kindle
#

lol taking a heap snapshot of a node process makes it use 4x more ram while snapshotting

hushed robin
#

ignore the lots of comments

#

i like commenting

quartz kindle
#

and still growing

hushed robin
#

whats growing

quartz kindle
#

memory usage

#

already 2gb+

hushed robin
#

for what

quartz kindle
#

for taking a heap snapshot

hushed robin
#

memory usage of what

quartz kindle
#

of my bot

lament rock
#

what was the initial heap size

hushed robin
#

oh

quartz kindle
#

500mb

#

is the actual usage

hushed robin
#

what is a heap size

lament rock
#

That's a lot

#

how many guilds/what are you doing

quartz kindle
#

taking a snapshot of 500mb makes it use 2gb+ for processing it lol

#

already 2.5gb lol

hushed robin
#

anyone know about my issue tho

quartz kindle
#

10k guilds

lament rock
#

oh lol

#

that's too much memory for me

#

my bot's at 78MB for almost 8k guilds

lyric mountain
hushed robin
#

wym

lyric mountain
#

there's nothing out of place, apparently

hushed robin
#

thats all my code

lyric mountain
#

do what tim is doing

#

a heap shot helps finding a leak

hushed robin
#

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?

lament rock
#

npm install heapsnapshot

lyric mountain
hushed robin
#

how will that help

lament rock
#

You have to work your way from the root tree to whatever depth to see what's being retained and where

lyric mountain
#

know what's being kept = know what's excess = know the cause

hushed robin
#

oh ok

#

how do i do that

#

on visual code studio

lament rock
#

a memory leak happens when something retains reference to the root scope and cannot be swept

hushed robin
#

why can't it be swept tho

#

i thought javascript is smart

#

if i'm not using it it should delete it

lyric mountain
#

GC doesn't collect referenced objects

lament rock
#

because the intention if you hold a reference is the user will want it later

quartz kindle
#

@hushed robinthe first diagnosis is using process.memoryUsage()

hushed robin
#

ok

quartz kindle
#

after your canvas finishes generating, log the result of process.memoryUsage()

hushed robin
#

what will that do

quartz kindle
#

run your canvas about 20 times as you say

#

and notice how values change

hushed robin
#

ok

#

how do i run javascript on my vps

#

i don't have an eval command

lyric mountain
#

put in the code

hushed robin
#

where

lyric mountain
#

idk, the start of the canvas command?

#

console.log it obviously

hushed robin
#

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

lyric mountain
#

that'll log the new process' usage

#

not your bot's

hushed robin
#

{
rss: 37359616,
heapTotal: 7081984,
heapUsed: 5318840,
external: 1031824,
arrayBuffers: 76787
}

hushed robin
#

wym

lyric mountain
#

node simply opens a new node console

hushed robin
#

bruhhh

#

how can i run it on my bot

#

without editing code

lyric mountain
#

you don't

#

I mean, do you have an eval command?

hushed robin
#

no

lyric mountain
#

then you don't

hushed robin
#

i was too lazy to add one

hushed robin
#

l bot

#

ok

#

time to edit code

lyric mountain
#

would be easier if you used github as we told you before, you'd not need to copy the files over scp

hushed robin
#

bro

#

that is too difficul

lyric mountain
#

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

quartz kindle
#

ok this is ridiculous

#

why does it take 6.5gb of ram to take a heap snapshot of 500mb

hushed robin
#

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

lyric mountain
#

heap snap needs to take a stacktrace of every single instance doesn't it?

quartz kindle
#

probably

hushed robin
#

why are they so high

lyric mountain
#

they are high because it's measured in bytes

quartz kindle
hushed robin
#

where u get 16mb from

quartz kindle
#

heapUsed

lyric mountain
#

divide by 1024 then by 1024 again

hushed robin
#

i don't think it's other things in my bot

#

tbh

quartz kindle
#

it can be generateChart

#

it can be experienceData

hushed robin
#

experienceData is only text

#

wym

#

how memory issue

quartz kindle
#

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

hushed robin
#

well

quartz kindle
#

if its not being cleaned it means its still being used somewhere

hushed robin
#

experienceData is from cache

#

bc i cache data so i don't always requesting from the api

#

i use lru-cache

quartz kindle
#

does memory only increase like that if you use the command?

#

if you dont use it, it doesnt?

hushed robin
#

yes

quartz kindle
#

does the command have more code besides what you have shown?

hushed robin
#

yes

#

thats just canvas

quartz kindle
#

then im pretty sure the problem is elsewhere and not with canvas

hushed robin
#

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

quartz kindle
#

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

hushed robin
#

๐Ÿ˜ต

quartz kindle
#

thats called debugging

#

the process of investigating code issues by analysing it part by part

hushed robin
#

i don't like "debugging"

#

i think it's still canvas fault my code is good and should not make so much memory

quartz kindle
#

well, deal with it, all devs need to know how to debug code

#

its part of the job

lyric mountain
#

debugging is 70% of coding

hushed robin
#

bruh

#

i do not debug

quartz kindle
hushed robin
#

bro you see my code

#

it's good

slender wagon
#

now my question is, why does next take around 1 - 2 seconds to apply the css on some of my components

quartz kindle
#

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

lyric mountain
#

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

hushed robin
#

bro

lyric mountain
#

still think you, and you alone outskills all those people?

hushed robin
#

my code is simple

#

there are no issues

quartz kindle
#

lmao

#

good luck then

#

i g2g see ya

hushed robin
#

bye

hushed robin
#

if anyone else has solution please spam me with pings

slender wagon
slender wagon
lyric mountain
#

@hushed robin @hushed robin @hushed robin @hushed robin @hushed robin @hushed robin @hushed robin there

#

solution: git gud

lyric mountain
hushed robin
#

i will report you

#

for spam pinging me

slender wagon
hushed robin
#

(and if someone else trolls i will not hesitate to report you)

lyric mountain
lyric mountain
slender wagon
lyric mountain
#

It should get the cache out of the way

slender wagon
#

@solemn latch is it just me or is Bing AI too annoying

#

its not quite as good as the normal chat gpt

hushed robin
slender wagon
solemn latch
#

It's gotten so much worse yeah

slender wagon
solemn latch
#

It was insane, it's now eh

slender wagon
#

it's like they are adding water to the milk

#

no taste

solemn latch
#

Yeah

#

Probably just got really expensive and limited the amount of data it can process

slender wagon
#

most likely

sudden geyser
#

you guys actually use the ai?

#

what for?

solemn latch
#

tbh, learning.

#

It was really good at explaining app router for nextjs.

lyric mountain
#

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

solemn latch
#

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.

lyric mountain
#

If this is the future for finding answers, so be it, I'm sick of having to use stackoverflow and deal with their ego

solemn latch
#

lmao yeah ^

#

for general questions its so nice.

rose warren
#

I use it for complex sql queries

wheat mesa
#

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

solemn latch
wheat mesa
#

So usually I don't ask AI unless I'm truly desperate or just curious

solemn latch
wheat mesa
#

I more or less meant for learning purposes

solemn latch
#

Oh

#

Absolutely

rose warren
#

Well you shouldn't just blindly copy and paste darkAYA you should always seek to understand any code it gives you. But it also does a good job at explaining

wheat mesa
#

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

rose warren
solemn latch
#

How is that going?

#

is it much better?

rose warren
#

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 darkAYA

solemn latch
#

Slower was expected, but not great.

gpt-3 was kinda close to being to slow sometimes.

#

๐Ÿ‘€ I hope its worth it

rose warren
#

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 darkAYA

#

It did crash a couple of times on me this weekend but it came back after a couple of minutes

solemn latch
#

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.

rose warren
#

I didn't use 3.5 enough to have any frame of reference tbh

#

At least not for coding

solemn latch
#

ah

rose warren
#

I used 3.5 for some creative stuff

solemn latch
#

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?

rose warren
#

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 darkAYA

solemn latch
#

lmao

rose warren
#

Lemme see if I can export it darkAYA

#

We had fun with my family with it at Christmas darkAYA

solemn latch
#

I'm afraid to show it off to my family

#

My dad/sisters humor is teenager boy humor.

rose warren
#

@solemn latch

solemn latch
#

are you trying to linus tech tips me rn?

#

lmao

rose warren
#

Lol this is how chrome exports a web page as pdf on android apparently darkAYA

#

It's a little suggestive in places kekw

solemn latch
#

what llm isnt

wheat mesa
#

I should ask chatgpt what gluten free dishes I can make with the ingredients I have at home ๐Ÿ‘€

#

never thought about it like that

rose warren
#

Let's gooo!!! peppapog GF cooking

wheat mesa
#

Yeah, gotta be gluten free cus of celiac but it's actually pretty good nowadays

solemn latch
#

Gpt-4 has a plugin that you can ask for a recipe and it will add all the ingredients to an Instacart order

#

๐Ÿ‘€

solemn latch
#

if you want

wheat mesa
#

Either that or I forgot how good normal food tastes

rose warren
#

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 darkAYA

wheat mesa
#

I was 10 when I was diagnosed c:

solemn latch
#

๐Ÿ‘€

wheat mesa
#

I remember one of my first gf meals was pasta

solemn latch
wheat mesa
#

It was awful

rose warren
rose warren
#

Although it was Christmas and there may have been some wine involved darkAYA

solemn latch
#

Its still good sober

rose warren
#

Yes! I just read it again and it's still funny darkAYA

wheat mesa
#

man this actually sounds pretty good

rose warren
#

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.

wheat mesa
#

I don't have almost any of the ingredients but still

rose warren
wheat mesa
#

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

rose warren
#

Look at these GF pizzas and Tiramisu ๐Ÿ‘€ and the butter chicken with GF garlic and plain naans peppapog

#

They were so good

wheat mesa
#

my god that looks amazing

rose warren
#

Pizzas were like in Rome

#

Top notch

wheat mesa
#

I had a real gluten free pizza from a restaurant for the first time 2 nights ago

#

Was absolutely delicious

rose warren
#

GF food in Rome is also amazing and very very easy to find btw

#

Definitely recommend

wheat mesa
rose warren
#

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.

wheat mesa
#

Never been out of the country, I don't really travel much

#

Maybe one day when I have the money lol

sharp geyser
#

@wheat mesa @rose warren this is development

#

leave

boreal iron
#

Shut up misty

#

I want that Pizza and I want it now!

warm surge
#

Imagine talking about pizza in development channel or yall developing discord pizza bots Lmaoooo

proven lantern
#

is there a limit to the number of roles a server can have?

proven lantern
proven lantern
#

sad times

quartz kindle
#

its been a requested feature in like forever, but afaik never been implemented

little yarrow
#

t!top

earnest phoenix
#

@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

earnest phoenix
#

Yeah, though I need to import it

#

Otherwise it errors out

#

However on 19, without import it works fine krShrug

slender wagon
#

how do i work with the route handlers to render pages without reloading on the new nextjs beta

earnest phoenix
earnest phoenix
#

Yes but I'm very sure you're not trying to use the Web Crypto API but rather the Crypto API

#

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 kek

#

Less imports

feral aspen
#

I'm trying to figure out why but can't since the website is EXTREMELY slow.

compact pier
#

is there any to query to mongodb and have it to return only a field?

deft wolf
#

What do you mean?

#

Maybe you'll find an answer here

crystal wigeon
#

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

earnest phoenix
#

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

crystal wigeon
lyric mountain
#

I think kryp means storing the process reference somewhere that can be retrieved later

crystal wigeon
#

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

lyric mountain
#

join()

crystal wigeon
# lyric mountain `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

lyric mountain
#

store this somewhere

crystal wigeon
#

yep, imma use a global list and then terminate it once the task completes

#

thanks

hushed robin
#

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;

lyric mountain
hushed robin
#

ok but i am not at pc

lyric mountain
#

skill issue

hushed robin
#

so i wanna know if someone else knows

hushed robin
#

chat gpt gave me that and i wonder it its right

#

he said it will get the highest value of every nth row

crystal wigeon
lyric mountain
#

those are just objects, store like anything else

#

you won't be storing the process itself, you'll just store the reference

crystal wigeon
wheat mesa
lyric mountain
#

but well, that was supposed to work yes

crystal wigeon
#

Weird, itโ€™s shows the data if I log it in the same func , wtf

crystal wigeon
#

Man, idk what to do mmmKnC_sad

crystal wigeon
#

help

earnest phoenix
crystal wigeon
#
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 ![MiaIsCold](https://cdn.discordapp.com/emojis/935541709155233873.webp?size=128 "MiaIsCold") it says "None" when i print after 10s
earnest phoenix
#

Let me guess, processes is a global variable

crystal wigeon
#

yea

#

its outside both functions

earnest phoenix
#

It will always stay empty if you do it like that

crystal wigeon
#

ic

earnest phoenix
#

And using .get() returns none if the key is not found

crystal wigeon
#

so i gotta move both the funcs into once func

#

?

earnest phoenix
crystal wigeon
#

yeah ik that

#

alr so i'll try moving both these funcs into one main func where i initialize processes locally

earnest phoenix
#

Well you've never written

global processes

in your start_processes function

#

So if you know it, why don't you have it

crystal wigeon
#

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

earnest phoenix
#

Using global variables isn't recommended, that's true

#

Though that's the solution to your question/current code

crystal wigeon
#

is there no other way i can do this?

earnest phoenix
#

It's a flask app, you can probably add variables to the app class

crystal wigeon
#
    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))```
crystal wigeon
earnest phoenix
#

I don't know, Google it

crystal wigeon
#

im assuming its pretty much app[name] = <>

#

alr

#

thanks

earnest phoenix
#

Probably not, app is not a dictionary

#

Not everything is a dictionary

crystal wigeon
#

need to find how to get the app thing inside folders

#

mm

hushed robin
#

guys

#

how do i cache an image in canvas so it doesn't take long to load

earnest phoenix
#

You'll most likely have to create a custom class where you inherit things from the default app class

crystal wigeon
earnest phoenix
#

There you can add your custom variables

crystal wigeon
#

ic,

#

but how do i access the app object inside other files?

#

i gotta import?

earnest phoenix
crystal wigeon
#

but thats the entry point no

earnest phoenix
#

I'd rather use a global variable to be fair

crystal wigeon
#

ic

#

nah i'da rather use recommended stuff cause this needs to be production ready

#

so

earnest phoenix
#

The issues that global variables have don't really have much relevancy

crystal wigeon
#

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

hushed robin
undone rose
wheat mesa
undone rose
#

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

wheat mesa
#

I donโ€™t think he knows how to use a map and I ainโ€™t about to help him with it ๐Ÿ™

hushed robin
#

loading them with canvas every time takes a long time

lyric mountain
#

the fact you answered that proves you don't know what a map is

wheat mesa
#

๐Ÿ’€

#

Not even nearly the same thing either

lyric mountain
#

waffle, are u good with math?

hushed robin
#

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

wheat mesa
lyric mountain
#

tho I'm struggling quite a bit with it

wheat mesa
#

You could use something like a sigmoid function

lyric mountain
#

well, there's a little detail to it

wheat mesa
#

(You can apply transformations to this if you wish as well)

lyric mountain
#

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)

wheat mesa
#

(1/(1 + e^x)) could work

lyric mountain
#

x being defense, I imagine

wheat mesa
#

Put it on desmos, it might be useful for that damage reduction

lyric mountain
#

oh wait, x can no way be defense

lyric mountain
hushed robin
#

why help people but not ne

#

!!!

#

i am in deer need of help

#

pls someone

lyric mountain
#

๐ŸฆŒ

hushed robin
#

help me kuuhaku

#

pls

#

i will paypal you $2

wheat mesa
#

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

lyric mountain
#

average is 500 or so

#

I'll grab my older formula to show u, just a sec

wheat mesa
#

Actually let me think

#

Sigmoid function is definitely what you want here but I need to tweak it a bit

neon leaf
#

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

wheat mesa
#

Iโ€™ll be back in a bit, just got out for lunch

#

(Probably around 30-40 mins from now)

hushed robin
#

who wants to make $2

lyric mountain
hushed robin
#

@lyric mountain can you help me

#

pls

lyric mountain
#

no

hushed robin
#

?

#

why

#

i will pay u

lyric mountain
#

I don't need to be paid

hushed robin
#

oo

#

ok

#

help for free?

lyric mountain
#

no, I'll simply not help

hushed robin
#

this is a very serious issue

hushed robin
#

why be mean

lyric mountain
#

you kick people around and expect them to come help you?

hushed robin
#

to me

hushed robin
#

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

lyric mountain
#

figure it out, research that topic and learn how to cache stuff

hushed robin
#

noooooo

#

pls help

lyric mountain
#

you probably didn't even try to solve that yourself

hushed robin
#

i tried seeing how to cache with no luck

neon leaf
#

I cant tell if you are serious or not

hushed robin
#

i only know how to use lru cache

lyric mountain
hushed robin
#

I am a begineer developer

lyric mountain
#

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)

hushed robin
#

he help other people nut not me

#

โ˜น๏ธ

#

if anyone can help please spam me with pings

#

and direct messages

lyric mountain
#

other people know how to be grateful

neon leaf
#

and maybe the async tasks call other async tasks

hushed robin
#

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

#

๐Ÿ˜ตโ€๐Ÿ’ซ

lyric mountain
#

idk if u can do the latter on js

hushed robin
#

is there any library like lru cache but will last forever

#

if anyone knows let me know

lyric mountain
#

you're really giving elon a run for his money eh

hushed robin
#

who

#

me or the number guy

neon leaf
#

what library are you using for the api?

lyric mountain
#

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

queen needle
lyric mountain
#

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

queen needle
#

Yeah not sure what I missed

lyric mountain
#

weird, seems correct

#

I already closed the tab, else I could share the link

lyric mountain
#

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

earnest phoenix
#

average terminal developer

wheat mesa
#

So high damage is reduced much less and low damage is reduced a lot more

lyric mountain
#

yes, that chart shows the % reduction (instead of absolute values)

wheat mesa
#

Ok let me mess around in desmos a little and Iโ€™ll try to see if I can get something to work

lyric mountain
#

I tried asking gpt if it could help, but it got entirely lost

#

I'll rewrite the formula and send a link here

wheat mesa
#

Yeah this is quite complex the way itโ€™s defined

lyric mountain
#

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)
hushed robin
#

can anyone fogure out my iweue

#

?

neon leaf
#

its literally one google search

lyric mountain
#

considering they asked if there's an infinite lru cache lib, I doubt they even searched what a cache is

hushed robin
#

please

#

i need help

wheat mesa
#

No

hushed robin
#

i am desperate i canโ€™t figure it out

wheat mesa
#

Too bad

#

Shouldโ€™ve thought about that before kicking us

hushed robin
#

i need help

#

so mcuh help

#

i am in need of

feral aspen
#

Could you stop asking again and again?

hushed robin
#

no?

#

i will ask because this is what the channel is for

#

stop hating

feral aspen
#

Yes, and they've replied to search it up yourself?

#

What's so hard in understanding that?

hushed robin
#

thats not help

feral aspen
#

What's your question anyways?

hushed robin
#

you could say thwy for every question asked here

hushed robin
feral aspen
#

Could you just reply with your question?

hushed robin
#

ok

queen needle
#

Caching lasting forever?

#

Database?

wheat mesa
#

๐Ÿ’€ enjoy helping this dude, youโ€™ll see soon enough

hushed robin
#

i dont wanna use a database

#

i want to cache the image

hushed robin
#

i am understanding if theres a easy cache library

queen needle
#

If you want to cache an image forever why not save it onto your drive and call it from there?

hushed robin
#

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

hushed robin
lyric mountain
hushed robin
#

you were being mean and unhelpful

#

so i was mad

#

bc u were being mean

#

it's your fault

#

stop the defamation

queen needle
#

It's like the one bae character all over again

hushed robin
#

whos bae

lyric mountain
hushed robin
#

it was more than a single pixel

lyric mountain
#

yet instead of showing what difference you were talking about you just kept saying we were blind or just lying

hushed robin
#

then u were calling me mean names acting like i'm crazy

lyric mountain
#

when literally 5 people couldn't spot the difference

maiden gazelle
#

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
#

but i was not at my computer

lyric mountain
hushed robin
#

exactly

#

thats a mean name

#

i am not delusional

lyric mountain
#

that's not a mean name, that's a psychological condition

hushed robin
#

it is

#

is being delusional a good thing?

#

no

#

thats a bad thing

#

and your using it in a bad way

lyric mountain
#

're

hushed robin
#

๐Ÿคฆ

lyric mountain
#

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

hushed robin
#

your just a bad person with an overinflated ego who is not helpful

#

period

lyric mountain
#

insisting everyone would see something that was impossible to see

hushed robin
#

bro someone saw it

#

it was not only me

lyric mountain
#

when the user wouldn't even have the second image to be able to compare it

hushed robin
#

i saw it very easily when i first saw the two

#

the difference was light and day

lyric mountain
#

the user would not see "the two"

#

because there wouldn't be "two"

hushed robin
#

but

#

the font looked uglier

wheat mesa
#

Youโ€™ve fallen for the trap once again

hushed robin
#

which is the main concern

lyric mountain
#

I'll say once, in a single clear tone

wheat mesa
#

I have fallen for the trap more than you though

hushed robin
#

there is no trap

maiden gazelle
#

hi i am getting this error but i dont know what is wrong with it i dont have much experience with canvas btw

lyric mountain
# lyric mountain I'll say once, in a single clear tone

@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.

hushed robin
#

but i appreciate the effort u put into that

lyric mountain
#

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.

hushed robin
#

though if someone has an answer to my question feel free to spam ping / dm me

maiden gazelle
#

background

lyric mountain
#

no, I mean, show the declaration

maiden gazelle
lyric mountain
#

try awaiting it

maiden gazelle
#

okay i will try

earnest phoenix
#

Both should be awaited fyi

hushed robin
#

no

#

only load image needs to be awaited

maiden gazelle
lyric mountain
maiden gazelle
#

its saying png so yes

lyric mountain
#

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?

maiden gazelle
#

ye

lyric mountain
#

try with this https://www.shutterstock.com/image-vector/no-image-available-icon-template-260nw-1036735678.jpg

#

see if it draws the image

maiden gazelle
#

i got the same error

lyric mountain
#

weird, it was supposed to work with at least jpegs

#

see the docs if there's anything else u need to do

hushed robin
#

loading and drawing that image works fine for me

#

๐Ÿ˜‚

maiden gazelle
#

with my welcome image it is working fine but not in this command

lyric mountain
wheat mesa
#

Show image.js around line 50-70

#

(And anything relevant)

#

Oh wait

#

Iโ€™m dumb

#

Thatโ€™s a canvas stacktrace

stiff dust
#

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?

crystal wigeon
#

go on the developer portal and use your new token

stiff dust
#

I update the token

lyric mountain
stiff dust
#

its not invalid Token err

lyric mountain
#

most libs prevent that from happening with an internal bucket

crystal wigeon
#

kuuhaku, okay so i tried using lists and appending the but its also still empty, global keyword also doesn't seem to be working

stiff dust
crystal wigeon
#

kinda stuck

lyric mountain
lyric mountain
hushed robin
#

a really popular sharding library

stiff dust
#

^

crystal wigeon
# lyric mountain is there no abstraction library available?

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,

stiff dust
#
lyric mountain
#

why not simply use d.js sharding?

lyric mountain
lyric mountain
# stiff dust

well, maybe they didn't add a bucket intentionally or smth then

crystal wigeon
stiff dust
#

I use this lib since my bot reach 2K servers

lyric mountain
#

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

crystal wigeon
#

if i use prcess.join() its gonna wait until the process completes, welp

lyric mountain
#

doesn't flask already handle async operations?

crystal wigeon
#

nop

#

apparently no

lyric mountain
#

told ya there was a lib

#

easier than u needing to juggle processes around

crystal wigeon
#

ay thanks, i'll look into this and see if it works for me

maiden gazelle
#

it has 25 lines

#

i can sourcebin it for you

lyric mountain
#

send it here, 25 isn't too big

#

but send inside a code block

maiden gazelle
#
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'
}
lyric mountain
#

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

maiden gazelle
#

okay

#

console is saying Draw BG

#

maybe i should do target.displayAvatarURL isntead

lyric mountain
#

probably

#

but at least now we know the error isn't when drawing the bg

maiden gazelle
#

its still saying unsupported image type

lyric mountain
#

console.log what displayAvatarURL is returning

#

then put it in the browser to see if it's indeed a png

maiden gazelle
#

so that would be console.log(avatar)

lyric mountain
#

no, put the function inside it

maiden gazelle
#

tbh i dont know what you mean im sorry

lyric mountain
#

just like you did for loadImage

#

put the whole thing inside console.log

maiden gazelle
#

do you mean console.log(target.displayAvatarURL({ format: 'png' }))

lyric mountain
#

yes

maiden gazelle
#

it didn't log anything

lyric mountain
#

where did you put it?

#

before or after?

burnt blade
#

Everyone loves me

#

lolipop

lament rock
#

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

earnest phoenix
#

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 kek

earnest phoenix
#

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>```
severe linden
#

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.

earnest phoenix
#

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

spark flint
#

this is the latest migration doc

lyric mountain
earnest phoenix
#

kek yeah

#

welcome to the world of weird versioning

lyric mountain
#

lmao

sterile vault
#

why websockets with Js are so easy and convenient?
I'm getting too much into it

lyric mountain
#

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

earnest phoenix
#

Pretty sure they are easy in all modern languages

sterile vault
#

But they're so comfortable (idk if i can use this word here thonk) 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

lyric mountain
#

the word you want is "convenient"

sterile vault
#

oh thanks

#

anyways I think I made it clear what I meant

maiden gazelle
lyric mountain
dense ivy
#

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?

lyric mountain
#

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

dense ivy
#

how do i make a vote reward? i dont really understand how to do it without the lib

lyric mountain
#

unrelated

lyric mountain
dense ivy
#

so i open a webhook using flask and use the hosting ip + port

#

then send webhook signal there?

lyric mountain
#

yep

dense ivy
#

okay thanks

lyric mountain
#

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)

dense ivy
#

also, how do i run both the bot and the flask app?

#

they seem to be a loop function

lyric mountain
#

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

dense ivy
#

ah i think its asyncio thing

#

thanks for the help

maiden gazelle
lyric mountain
#

yes

maiden gazelle
#

it is sending the pfp link

lyric mountain
#

does it open normally on browser?

maiden gazelle
#

yes

#

it opens a new tab and then it is showing my pfp

#

since i mentioned myself

maiden gazelle
#

wait i fixed that problem

#

i have a new problem xd

earnest phoenix
#

As the error says

#

build() is not a function existing

#

iirc it's toBuffer()

earnest phoenix
maiden gazelle
maiden gazelle
frosty gale
#

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%);

lyric mountain
#

but well, check if there's no padding on that background

#

use F12 to see if there's any

lament rock
# earnest phoenix

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

quartz kindle
#

who the f uses nodemon in prod

#

pm2 > *

#

:^)

earnest phoenix
lament rock
#

who the fuck uses software in production

#

not being a dev > *

quartz kindle
#

use everything in production no matter how much pre-alpha stage it is

sudden geyser
#

hot reloading in production is where real power stems

sterile vault
#

guys i need your help
Which name sounds better for a PHP library?
A) PlatinumPHP
B) KryptonPHP
C) Fluorine

lyric mountain
#

C sounds like a minecraft fabric optimization mod

#

what is the lib about?

sterile vault
#

i wrote a message, let me find it

#

this

lyric mountain
#

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

sterile vault
#

or 75% soon because i'm working on strings with mbstring

lyric mountain
#

like, OOP has 4 pillars that must exist to be called OOP

#

encapsulation, abstraction, inheritance and polymorphism

earnest phoenix
#

No meed to think twice

sterile vault
#

lol

earnest phoenix
#

I'd rather remove the PHP to be fair

#

And find some cool name

lyric mountain
#

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

sterile vault
lyric mountain
#
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)

earnest phoenix
#

How does JS break that though

wheat mesa
#

But side effects ๐Ÿ˜ญ

lyric mountain
#

js has no visibility modifier

earnest phoenix
#

Can't you create a function in your class and also have that check implemented

lyric mountain
#

so u could do example.number = -1

earnest phoenix
#

isn't there that thing where when doing that it executes a function you've defined

sterile vault
scenic kelp
#

(technically js does have this.#number)

#

or whatever it is

lyric mountain
#

the what

scenic kelp
#

you can prefix field names with # and they're considered private

lyric mountain
#

is that new?

lyric mountain
earnest phoenix
#

Also isn't Object.defineProperty a thing

scenic kelp
#

it's been a thing for a while, not sure what standard it's a part of

earnest phoenix
#

Where you can overwrite the getter and setter

#

And make it not possible to use x.something = "blah"

scenic kelp
#

I'll hop on pc in a sec

sterile vault
lyric mountain
#

the user

scenic kelp
#

i hate how you have to do that kind of stuff in JS it's just so ugly

#

make that a declaration site thing

lyric mountain
#

js suffers from the same burden java does, but js' past makes thing much harder for it

earnest phoenix
#

JS itself is madness either way

lyric mountain
#

backwards compat

scenic kelp
#

at a certain point backwards compatibility is harmful

lyric mountain
#

like prototype and its shenanigans

scenic kelp
#

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

sterile vault
# lyric mountain the user

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

lyric mountain
#

for example, if I needed to have an object that has a method to call an api and return the value, is it possible?

sterile vault
earnest phoenix
lyric mountain
scenic kelp
#

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

lyric mountain
#

which means allowing custom objects (with custom behavior)

scenic kelp
#

javascript really just is roundabout java

#

at least javascript actually has proper getters and setters skull

earnest phoenix
#
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
scenic kelp
#

wait ig with the #name syntax you could have getters and setters as just name

#

nice

sterile vault
lyric mountain
#

so I misunderstood your lib

sterile vault
#

np

#

maybe my terrible english contributed

lyric mountain
#

I thought u were trying to add full oop support to php instead of additional objects

scenic kelp
#
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

earnest phoenix
#

The fact that it is needed to do that makes me throw up

#

Also why on earth # and not be normal with private

scenic kelp
#
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
sterile vault
lyric mountain
#

people with variable named private:

scenic kelp
#

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

lyric mountain
#
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]
``` ![mmLol](https://cdn.discordapp.com/emojis/356831697385422848.webp?size=128 "mmLol")
scenic kelp
#

kt?

lyric mountain
#

groovy

scenic kelp
#

o