#development

1 messages ยท Page 227 of 1

solemn latch
#

Yeah looks like it was fixed in 18.17.1

frosty gale
#

ah so it looks like it basically just crashes the app since node will likely throw an error if you try to set more headers than allowed by server.maxHeadersCount

solemn latch
#

Yeah, so a single request could have crashed it.
So, I get why it was marked as high

#

is there a way to get notified about these types of things?

frosty gale
#

github just randomly sent me this

#

so i guess you just need to enable dependabot if you use github

solemn latch
#

Oh cool

#

Easy

surreal sage
#

where'd ya see thissss

frosty gale
#

hubgit

surreal sage
#

ya but where

#

i go to dashboard, nun

#

or am i js lucky Troll

frosty gale
#

oh i think you can do it on repositories on applicable projects

#

ones with supported package managers

past field
#

how can i get my bot to purge messages that are older than 14 days old?

deft wolf
#

Probably only if the messages are deleted individually

#

Which will be terribly slow for a few hundred or a few thousand messages

neon leaf
#

@lyric mountain I am not home currently but what's the best way to optimise that full text search I am doing, I technically only need the count of matching rows that exist in both field and input and sort by that in my case

#

It takes almost 11sec on bigger text currently

lyric mountain
neon leaf
#

Yes

#

Didn't change speed

#

I think it's just too much data

#

Each value column is around 10kb

lyric mountain
#

how many characters?

neon leaf
#

Uhhhh

lyric mountain
#

also, how exactly are u trying to search?

neon leaf
#

I'd guess like 10k

neon leaf
#

Idrk

lyric mountain
#

do you want only 1 result or to order results?

neon leaf
#

I want 3 top results

lyric mountain
neon leaf
#

Look at the code, most is there

lyric mountain
#

and what kind of data are we looking at?

lyric mountain
neon leaf
lyric mountain
#

...ok, question stays

#

what kind of data are we looking at? (structure)

#

as in, send an example

neon leaf
#

Most of it is yaml, let me get a sample real quick

lyric mountain
#

also, what are u searching for?

#

key matches? value matches?

neon leaf
#

So basically

#

A user passes in his config

#

And I want to reverse search the most accurate match to get the version it was created by

#

I don't really know the optimal way for that

lyric mountain
#

to get the version it was created by
for example?

#

is that a field in the yaml?

neon leaf
#

No

#

It's a relation

#

The yaml does not contain any data I need

#

It's just there to search with

sharp geyser
lyric mountain
#

ah wait, u want to match whole configs against whole configs?

neon leaf
#

Yes, but since configs can be changed I need the best match

lyric mountain
#

yeah no, that's not going to cut it

#

similarity and alikes are for fuzzy searching

#

not for comparing whole documents

sharp geyser
#

I didnt think thats what he was going to use it for

#

๐Ÿ’€

neon leaf
sharp geyser
#

my fault g

lyric mountain
#

are the config files generated by you to the users?

#

or can they be anything?

neon leaf
#

The configs are generated by Minecraft

#

They can be anything

lyric mountain
#

you can use this

#

go check if it's constant for all configs with the same minecraft version

neon leaf
#

Hm, I guess I could for most configs

lyric mountain
#

if it's the same number for every config under a given version, then u can compare that value alone

neon leaf
#

If that doesn't really work out (which I can't test rn), would it be a good option to fetch all values into memory on start and search on those

lyric mountain
#

comparing whole documents will take a long time regardless of how you do it

neon leaf
#

Well I can use any algorithm if I have it on my app

lyric mountain
#

any algorithm will take a long time

#

we're talking about doing a full scan of every single entry

#

there are no shortcuts

neon leaf
#

I mean

#

Couldn't I just split all configs into array of lines

#

And check how many match

lyric mountain
#

yes, and it'll take a long time

neon leaf
#

Once

lyric mountain
#

you dont get it, if you're finding the most similar entries given a document, it will take a long time because you HAVE to process every single entry against that doc

#

anything you do will still require a long time

#

that's why people put version value in config files

neon leaf
#

I see

#

I will check when I'm home

#

Thanks so far

lyric mountain
#

if the value is constant among a given minecraft version, then u can simply use WHERE value LIKE '%config-version: ' || :version || '%'

#

as postgres doesn't have a built-in yaml parser

#

btw do keep the index, LIKE can also use pg_trgm indexes

surreal sage
#

jesus github actions.

build matrix for apple x2, linux & windows
ofc the apple two finish at the same time AND CREATE THEIR OWN RELEASE DRAFTS

#

max-parallel my most hated and beloved

frosty gale
#

what do you guys think is a better suitable reverse proxy? im planning to mainly use it to map subdomains and certain routes to different backend apps with maybe some static content

#

i only really know of apache2 or nginx but never really used them

lyric mountain
#

nginx

#

it was basically made for this

frosty gale
#

i'll probably use it then, thanks, i think its also simpler

#

i assume i can also set up https on the nginx end? so i dont have to do it on the application layer

#

so communication between nginx and app is http, but between nginx and browser its https

lyric mountain
#

for sure

#

tho what I do on my endpoints is to redirect http to https, if it wasn't already

#

just in case cloudflare misses it

lyric mountain
#

as you'll use localhost for communicating internally

#

and localhost cant have ssl

surreal sage
#

doing the walk of shame on github actions rn... fail, push, fail, push aaaaaaaa

#

FINALLY

#

YES

#

๐Ÿ˜ญ

#

after 8/9 attempts โค๏ธ

digital swan
sharp geyser
#

I use ssl on my machine when testing

#

.Net tools raaahhhh

#

gotta love dev-certs

surreal sage
#

why r let's encrypt certs only valid for 3 months

#

i dont feel like renewing it 4x a year

sharp geyser
#

ima be real

#

if you use cloudflare and still generate certs with let's encrypt

#

you're doing smth wrong

surreal sage
#

no like

#

i have a pterodactyl instance running on some server

sharp geyser
#

yea

#

ok

surreal sage
#

and i want ssl for node domain things

sharp geyser
#

yea ok

radiant fiber
sharp geyser
#

use cloudflare

surreal sage
#

no cloudflare

sharp geyser
#

why not

radiant fiber
#

worst in the game

sharp geyser
#

That's completely false

#

but alright

earnest phoenix
#

I used cloudflare and used NPM together

sharp geyser
#

Without cloudflare 90% of the websites on the internet would fail

surreal sage
#

cloudflare is great i use it for everything but i cant use it for pterodactyl without 24/7 struggles

sharp geyser
#

Its just like anything else you host

surreal sage
#

config ass

sharp geyser
#

What are you talkin bout bro

radiant fiber
#

Akamai ๐Ÿ”

surreal sage
surreal sage
radiant fiber
sharp geyser
radiant fiber
surreal sage
#

can we have polls to mute people

radiant fiber
radiant fiber
sharp geyser
#

never heard of it

radiant fiber
#

in top 3 #

#

global leader Akamai

surreal sage
#

cdn != network related (kinda)

#

what are you on

radiant fiber
#

i aint on nothing

#

iam on abt whats better

radiant fiber
sharp geyser
#

Ima be real with you

#

Cloudflare is more than a CDN

#

Not to mention, it seems akamai is a paid service

radiant fiber
#

thats why its better

sharp geyser
#

whereas cloudflare even their freetier is better than akamai's so called paid plans

radiant fiber
#

pay = better

sharp geyser
#

That most certainly is not the truth

radiant fiber
#

ovbs more than a cdn

sharp geyser
#

you are just buying into a fantasy that doesn't exist

radiant fiber
#

we pay them = higher quality

sharp geyser
#

no

#

๐Ÿ’€

#

you pay them because they need the money and can't afford to give a free tier

#

cloudflare gives you a free tier that is just as good as their business tiers

radiant fiber
#

made way more money than cloudfare

sharp geyser
radiant fiber
#

bc more ppl buy it bc it better

sharp geyser
#

10/10 website

#

cant even view it

radiant fiber
#

i can

#

ur end

sharp geyser
#

๐Ÿ’€

#

my end yea ok

radiant fiber
#

how come i can view it

#

you also get free and 100ยฃ credit

sharp geyser
#

you pay them to outsource your shit

radiant fiber
#

jsut look at the statistics...

sharp geyser
#

their computing stuff isn't even done by them

#

they outsource it to linode

#

Ah wait nvm guess its a child company

radiant fiber
#

they work together not jsut linode

sharp geyser
#

interesting

#

honestly linode isn't even that good either

#

the prices for their plans are absolute dogshit let alone the specs you get

radiant fiber
#

what are the statistics for cloudfare /

sharp geyser
#

like 8 million or so actively using

surreal sage
#

20% of all internet traffic per second goes through cloudflare or smthn

sharp geyser
#

ye

earnest phoenix
#

imagine if one day both cloudflare and googles servers went down

sharp geyser
#

hell would let loose

earnest phoenix
#

50-60% of the entire world wide web gone

sharp geyser
#

the furthest ring of hell would look like childs play

earnest phoenix
#

aws and oracle going down would also cause even more chaos

sharp geyser
#

Any of the big 4 hosting providers

#

OVH, AWS, Oracle, Google

#

Most of people's stuff is on those services

earnest phoenix
#

google and aws are the most major afaik

sharp geyser
#

OVH is up there as well

earnest phoenix
#

discord runs on aws and google iirc

sharp geyser
#

ye

earnest phoenix
sharp geyser
#

discord uses google for their storage

#

and aws for their other stuff afaik

earnest phoenix
#

its pretty much impossible for all of them to go down at the same time

sharp geyser
#

unless.... ๐Ÿ˜ณ

earnest phoenix
#

or even at all

sharp geyser
#

right so here's the plan

#

You go after aws and google

earnest phoenix
#

๐Ÿ’€

sharp geyser
#

I will go after ovh and oracle

earnest phoenix
#

are we playing payday 2

sharp geyser
#

nah

#

payday 3

#

because if we get caught its not even life in prison

earnest phoenix
#

payday 2 > 3

sharp geyser
#

its the deepest depths of corporate hell

earnest phoenix
#

(payday 3 sucks)

sharp geyser
#

exactly

#

fits perfectly

#

because going after the big 4 sucks as well

earnest phoenix
sharp geyser
#

idk who in their right mind would do it

sharp geyser
earnest phoenix
#

that game sucks

#

lmao

sharp geyser
#

I know

earnest phoenix
sharp geyser
#

Ive played the payday games

#

ngl

#

forgot about him

#

havent heard anything about him in a while

#

Lapsus$ right

#

thats the name of them

earnest phoenix
#

ig

sharp geyser
#

imagine getting hacked by an amazon firestick

#

that has to be embarassing

earnest phoenix
#

hows that even possible

sharp geyser
#

I mean

#

it connects to the internet

#

it has its own os

#

browser

#

and basically is android

earnest phoenix
#

how do you even hack someone using a fucking android device which has no peripherals other than a damn remote

#

i wonder what bro used to get in

#

maybe termux?

sharp geyser
#

maybe

#

its even funnier

#

it was from a hotel tv as well

#

Out on bail for allegedly hacking the hardware company Nvidia, Kurtaj, prosecutors say, pulled off the GTA heist while staying under police protection at a Travelodge hotel. Without his computer, he somehow managed to hack into Rockstar using his smartphone, an Amazon Firestick, and the TV in his hotel room.

earnest phoenix
#

he did have a phone

sharp geyser
#

yea

#

still impressive tho

earnest phoenix
#

but i wonder how did he actually get it

sharp geyser
#

get what?

earnest phoenix
#

get in*

sharp geyser
#

oh

#

yea idk

earnest phoenix
#

some sort of exposed port?

sharp geyser
#

bro probably works for the CIA or NSA now tho

earnest phoenix
#

easy to guess password?

sharp geyser
#

US gov heard about this

#

recruited his ass

earnest phoenix
sharp geyser
#

fosho

frosty gale
#

tf is this

#

the one time i decide to use react i get problems

#

i regret not using svelte or vue already

sharp geyser
#

this typically happens when you upgrade react to a higher version than the one the dep relies on

#

or vise versa downgrading

frosty gale
#

yeah i left this project for a few months so things are probably outdated somehow

#

im trying to upgrade all packages first to see if that works

slender wagon
#

what type of scaling is usually applied on a discord bot if it has setup something like discordeno?

lament rock
#

That's fair. It isn't an issue for me and I like how it looks a lot

#

Wdym? There are folders and tabs that arent pinned or favorited get removed after a set amount of time

quartz kindle
#

if you have a separate process for the gateway, you need to scale that independently based on how many guilds you have

#

then your code will be scaled based on actual command usage

sharp geyser
#

just get more servers

#

kubernetes it

#

raahhhhhh

#

:D

#

tbh idek how you'd scale a discord bot

#

if not getting more system resources

quartz kindle
#

the thing about discord is that its not very compatible with horizontal scaling

pine willow
quartz kindle
#

so just getting a beefier machine is still the easiest way to scale

#

and of course, optimize your code and cache usage

sharp geyser
#

well

#

fair enough

quartz kindle
#

but its still possible to scale it horizontally, just a bit tricky to do

sharp geyser
#

but could you not split the processes off onto other servers?

quartz kindle
#

you can, but its tricky

#

while the sharding system is very good for horizontal scaling,there are two parts of discord that are still centralized

#

the shard login queue and the rest rate limits

#

so while you can split all your shards accross different servers, when they login, they need to contact some central server first, to make sure they login in the right sequence

sharp geyser
#

So it'd be ideal to horiztonally scale

#

but if not verticle scaling is the way to go?

quartz kindle
#

vertical is the easiest

sharp geyser
#

right easiest

#

but in reality is either one better than the other?

quartz kindle
#

horizontal would be best for large bots

frosty gale
#

you can do it horizontally it just gets annoying and complicated, but a fun project definitely

quartz kindle
#

as long as its implemented correctly

sharp geyser
#

I see

#

shards have to be logged in based on their id right?

#

0-x

quartz kindle
#

yeah

#

once you achieve "large bot sharding", which happens at around 100-150k guilds

sharp geyser
#

Oh then that sounds rather easy to implement no? You just have each server send their shard login requests to a central server and just log them in order of id?

quartz kindle
#

you will be able to connect 16 shards at a time, every 5 seconds

#

but only specific ids can login at the same time

sharp geyser
#

thats weird

frosty gale
#

so youd probably have to broadcast to each server from some master server their shard ID to login as or something

sharp geyser
frosty gale
#

think you can do stuff like this with kubernetes

sharp geyser
#

yea

#

most likely

#

kubernetes has a master server that runs all the children servers

#

making sure there is always a consistent amount of servers running

quartz kindle
sharp geyser
#

I hope my bot reaches this level one day

#

this would be a cool project

frosty gale
#

so how do you know which shards can login?

quartz kindle
frosty gale
#

weird system

quartz kindle
sharp geyser
#

youd probably store some kind of state on the master server

#

I wonder how youd handle resumes/reconnects

frosty gale
quartz kindle
#

reconnects need to follow the same rules as login tho

sharp geyser
#

icic

#

Honestly

#

this seems like something i'd want a custom library for

#

simply because any existing library might be hard to incorporate this into

quartz kindle
frosty gale
#

i think a custom sharder would be enough

quartz kindle
#

login timings are different, then you also have reconnects

sharp geyser
quartz kindle
sharp geyser
#

I mean you can use an existing library

frosty gale
#

does someone have a 150k bot i can quickly borrow the token from to do some testing

sharp geyser
#

all you have to do is make a new client for each shard no?

quartz kindle
sharp geyser
#

ic

#

I know the lib im using rn DSharpPlus if you are manually sharding you have to create a new DiscordClient with the appropriate shard id and event handlers

quartz kindle
sharp geyser
#

For most looking to shard, the built-in DiscordShardedClient will work well enough. However, those looking for more control over the sharding process may want to handle it manually.

This would involve creating new DiscordClient instances, assigning each one an appropriate shard ID number, and handling the events from each instance. Considering the potential complexity imposed by this process, you should only do this if you have a valid reason to do so and know what you are doing.

quartz kindle
#

yeah so you can use the sharded client

#

one for each process

sharp geyser
#

sure just depends on how much control you ant

#

and I figure for smth like this you likely need as much as you can

quartz kindle
#

i ant all the control

#

:^)

sharp geyser
#

shut up

quartz kindle
#

i need to rework a bit this part on tiny discord, its not perfect yet

#

the shards need to have an ipc connection with the master to go back and forth while connecting

#

because if you use a fixed 5 second rule like discord allows, you can have issues

sharp geyser
#

honestly this sounds like a fun project to make into a tool for people to use

#

Sell it as well /j

#

bots like Dyno would probably buy into it tbh

#

I know they spend thousands on their servers rn

quartz kindle
#

lmao

sharp geyser
#

horizontally scaling would cut the cost down a bit id imagine

#

since you are buying smaller servers

quartz kindle
#

indeed

radiant kraken
sharp geyser
#

its not tiny enough if its not in machine code

#

1s and 0s

#

get to work tim

#

discord-binary library when?

quartz kindle
#

write 1s and 0s directly to ram with a microscopic eletric needle

sharp geyser
#

tim

#

we need the discord-binary library

#

please make it

#

its your new mission in life

quartz kindle
#

what would that even be?

sharp geyser
#

idk

#

thats up to you to figure out

#

๐Ÿ’€

quartz kindle
#

dafuq

radiant kraken
#

i wanna make a discord bot programming language

quartz kindle
sharp geyser
#

so discord bot maker?

quartz kindle
#

aoi.js

radiant kraken
#

but better

#

smhhhhh

quartz kindle
#

xDDDD

radiant kraken
#

yuhh

frosty gale
#

ihob

radiant kraken
#

whats IHOP anyway

quartz kindle
#

no idea

frosty gale
#

mid restaurant

quartz kindle
#

looks like a pancake shop

radiant kraken
#

yum

sharp geyser
#

its a US breakfast restaurant chain

#

that sells shitty pancakes

quartz kindle
frosty gale
#

my vps ran out of memory when running npm update

#

this is cooked

#

how many dependencies does react have

#

amazing

#

i can live with a html minifier being susceptible to a ddos

radiant kraken
quartz kindle
radiant kraken
#

i love pancakes

sharp geyser
#

terrible taste

radiant kraken
#

oh

#

make it gluten free like what waffle did ๐Ÿ’ช

frosty gale
#

americans eat this shit for breakfast

#

the cardiovascular health statistics arent a surprise

#

when did these poor diets become normalised

dusty bronze
#

Does anyone know a free host for the App?

frosty gale
#

school computer

earnest phoenix
#

Btw it's currently no free spots but they are doing a purge of free servers so there should be free spots open soon

quartz kindle
earnest phoenix
#

First person I have seen with it

frosty gale
#

mans stalking profiles

earnest phoenix
quartz kindle
radiant kraken
#

omg!!!!!!

#

๐Ÿ™€

earnest phoenix
#

I have seen

quartz kindle
#

ยฏ_(ใƒ„)_/ยฏ

#

im a rare shiny pokemon

frosty gale
#

at least now you can sell your account if you ever get on hard times

earnest phoenix
quartz kindle
#

my special ability is procrastination

radiant kraken
#

you are also Experienced!!!!!!!!

quartz kindle
#

experienced in procrastinating

radiant kraken
earnest phoenix
dusty bronze
#

Jajqjq

quartz kindle
#

procrastinates entering the ball

earnest phoenix
#

I love the discord bot development community sometimes

quartz kindle
#

:^)

earnest phoenix
#

Yeah sometimes cuz someone hacked my bot and banned over 1.2k members

quartz kindle
#

lmao

#

leaked token?

earnest phoenix
#

Idk but most likely

#

Good thing I have the ability to reset my token

frosty gale
frosty gale
#

@lyric mountain nginx is really good

#

you can even configure ratelimits and automatic spamassassin headers for SMTP

#

ive been missing out

lyric mountain
#

yep, it has basically anything you'd need for a webserver

#

and if it doesn't have, you can install plugins

sharp geyser
#

also waffle doesnt have a choice but to eat gluten free products

radiant kraken
#

๐Ÿ˜”

sharp geyser
#

How do I give a docker container access to its own volume folders?

#

One of my containers errored out because it couldn't read a file inside its data folder

sharp geyser
#

LOG is literally in its volumes folder tho

#

๐Ÿ˜”

earnest phoenix
#

lol

sharp geyser
sharp geyser
#

@lyric mountain question for you about postgres

#

I am trying to come up with a db structure for a bot I am making

#

I am thinking I will need 3 tables at least

  1. Profiles - This will store their user id, opt in for global leaderboard, position on leaderboard [maybe], as well as a references to the images they have uploaded
  2. Leaderboard - User Id (One-to-Many relation), Image (one-to-one), Rating (the rating of this image on the leaderboard)
  3. Images - Do I need to store a reference to the user here since its on leaderboard?, Image Url (url of the image from my cdn)
#

I am not sure if this is the best way though

#

My requirements are to

  1. Keep track of the user on the leaderboard
  2. Keep track of the images on the leaderboard for profile reasons (e.g they can run /images or smth to see their highest rated images putting them on the leaderboard)
lyric mountain
#

Don't store position on leaderboard

#

What kind of leaderboard are we talking about?

#

And what about the images? What are they for?

sharp geyser
#

They are just images people can up/down vote

sharp geyser
lament rock
#

You can usually have the DB calculate the ORDER BY upvotes - downvotes and then tack on a DESC

sharp geyser
#

yea im not too worried about that tbh

#

Im more worried about the structure of the db

lyric mountain
#

Yes, you'd have only 2 tables

#

Profile and Images

#

Image would have the ID of who uploaded

#

The whole leaderboard would always be generated, u can make a view if u want

#
SELECT p.id
     , sum(i.upvotes) AS total_votes
FROM profile p
INNER JOIN image i ON i.profile_id = p.id
GROUP BY p.id
sharp geyser
#

so Images would have an Upvote and Downvote field?

lyric mountain
#

U don't need both, just one

#

Let it go into negative

sharp geyser
#

Ah

#

right

#

saves me from having to do math

#

should I need a WHERE clause as well?

#

WHERE p.id = $1

lyric mountain
#

If u want a specific user, yes

sharp geyser
#

gotcha

radiant kraken
sharp geyser
#

yea but with just upvotes

#

if someone downvotes I can just -1

lyric mountain
#

Honestly call it score

sharp geyser
#

sure

lyric mountain
#

Also, make sure to create an index on score sorted by desc

sharp geyser
#

how do you do that

lyric mountain
#

Since most of your queries will be sorted like this

sharp geyser
#

like a gin index?

lyric mountain
#

CREATE INDEX score_idx ON image (score DESC)

#

Gin is for text, not numbers

sharp geyser
#

oh

#
create table profile (
id serial,
user_id bigint,
);

create table image (
id serial,
url varchar(255),
score int,
);
CREATE INDEX score_idx ON image (score DESC)
#

?

#

bigint for the userid might actually be too big

lyric mountain
#

Url 255 is risky

sharp geyser
#

idrm

#

why?

lyric mountain
#

Check mozilla docs for how big a valid url can be

#

And use that

lyric mountain
#

Varchar i mean

sharp geyser
#

why

#

C# gives it as ints

radiant kraken
#

what are serials for

sharp geyser
#

auto generated ids

lyric mountain
#

Alias for int autoincrement

radiant kraken
#

LMAOOO

sharp geyser
#

C# gives ids as ints

#

is it not better to store it how you recieve it?

lyric mountain
#

Iirc it's already near the limit

radiant kraken
#

bigint has a limit?

sharp geyser
#

welp

#

ofc

radiant kraken
#

i thought its infinite in many languages

lyric mountain
#

Lul it's 64 bits

radiant kraken
#

well, as much as the computer can handle

sharp geyser
#

isnt big int a 64 bit

radiant kraken
#

oh

#

then thats an ordinary 64 bit int

lyric mountain
#

Only BigInt in java is boundless

radiant kraken
#

and python

#

and javascript

lyric mountain
#

Javascript ain't boundless

sharp geyser
#

bigint in java is like 128 right?

lyric mountain
#

Nor python

radiant kraken
#

how

lyric mountain
radiant kraken
#

isnt it like an array of words or something like that

#

so it can grow like a vector/string

sharp geyser
#

interesting

lyric mountain
#

It's a very very big limit, but there's one

radiant kraken
#

what is it

sharp geyser
#

is there yet capability in most languages to handle 128 bit numbers?

radiant kraken
#

yes

#

Rust has 128 bit integers

#

u128 and i128

sharp geyser
#

for reference 340,282,366,920,938,463,463,374,607,431,768,211,456

#

thats the size of a 128 bit int

radiant kraken
#

unsigned?

sharp geyser
#

I think so

#

let me check

#

yea

#

roughly

radiant kraken
#

interesting

sharp geyser
#

maybe minus a few

radiant kraken
#

256 bit int when

lyric mountain
#

Oh nvm, js bigint is the same as java

radiant kraken
#

see

#

smh

#

what about python's

sharp geyser
sharp geyser
#

๐Ÿ’€

lyric mountain
#

Python too

lyric mountain
#

16 bits

sharp geyser
#

what should I use for user_id

#

whats a safe varchar limit

lyric mountain
#

Doesn't matter much, varchar resizes to actual value size

#

Just put something sensible

sharp geyser
#

oh wait

#

varchar is extendable right?

lyric mountain
#

Variable char

#

Varchar

sharp geyser
#

then there is char

#

which is not

#

its set in stone?

lyric mountain
#

Correct

sharp geyser
#

now I remembe our convo

#

so 255 is just a suggestion

#

if it needs ot it expands?

lyric mountain
#

No, 255 would be the ceiling

#

It resizes down, not up

sharp geyser
#

im talkin bout varchar

#

sorry

lyric mountain
#

To resize up u need to alter table

#

And set a new ceiling

sharp geyser
#

even with varchar?

lyric mountain
#

Yes

sharp geyser
lyric mountain
#

If u need unbounded text use text

sharp geyser
#

ic

lyric mountain
#

Even the text has a limit, which u enter into longtext area

sharp geyser
#

I make an FK on the image table right?

lyric mountain
#

But u won't reach it

#

Yes

sharp geyser
#
create table profile (
id serial,
user_id varchar(255) unique not null
);

create table image (
id serial,
user_id varchar(255) not null,
url varchar(65535) not null,
score int not null default 0,
constraint fk_user foreign key (user_id) references profile(user_id)
);
#

this looks right

#

:D

lyric mountain
#

U don't need an id on profile

sharp geyser
#

huh

lyric mountain
#

Use user_id as id

#

It's redundant to have 2

sharp geyser
#

but you said I should always have an id before

#

๐Ÿ˜ญ

lyric mountain
#

Well yes, but user_id is an id already

#

Since it's coming from discord

#

All tables must have an id, not necessarily a serial or anything

#

Just dont put text as primary key

sharp geyser
#

so I should set it as primary

lyric mountain
#

At least not without gin

lyric mountain
#

Also unless u plan to add more data to profile, u don't even need a profile table

sharp geyser
#

I actually did yea

#

forgot about it

#

oh shoot

#

I wont need to change anything if I have both a global and a server leaderboard will I?

#

To get on the global leaderboard you have to be #1 in your server

lyric mountain
#

Can't people just make a priv server and invite the bot?

sharp geyser
#

Its a bot meant for a community

lyric mountain
#

But u need to store guild id somewhere if u want to rank by server

sharp geyser
#

I guess I can do it on the image itself

#

and when its on the global leaderboard I can still query for it from the image table

lyric mountain
#

U can use rank function for classifying btw

#

rank() OVER (PARTITION BY guild_id ORDER BY score DESC)

sharp geyser
#

Thats a thing?

lyric mountain
#

Yep

sharp geyser
#

interesting

#

I only plan on showing the top 10 for both global and server leaderboards tbh

#

I will still have a way to check your standing tho

lyric mountain
#

Just use the rank function to populate the numbers

#

Then select the result of that

#

Since if u use where in the same scope as the rank func it'll always return 1

#

As you're always the first if you're the only competitor

sharp geyser
#

so basically

#
SELECT * FROM (rank function) WHERE user_id = $1
lyric mountain
#

?1 btw

#

Not $

#

But yes

#

Inside the from clause you'll put the whole select for sorting and ranking

#

Also handy tip, if you don't care about realtime data, you can use materialized views

#

They're basically snapshots of a resultset

#

They only re-fetch data if you call REFRESH VIEW nameofview

#

It's a good idea to have one if you start noticing slowness in computing the ranking

sharp geyser
#

I dont think i will ever need realtime data tbh

#

I was only planning on updating the rankings every 15m

lyric mountain
#

It's fine then I suppose

#

You can hook a periodic event to refresh the mat view

sharp geyser
#

yea once I figure out how

#

๐Ÿ’€

#

theres still a lot about postgresl I dont know

lyric mountain
#

I just showed u how

#

To create a mat view u just put MATERIALIZED after CREATE

#

The syntax is the same as regular view

sharp geyser
#
SELECT user_id FROM (RANK() OVER (PARTITION BY guild_id ORDER BY score DESC)) WHERE user_id = ?

is how i'd get the person right?

lyric mountain
#

No

sharp geyser
lyric mountain
#

First make a select to get a full ranking

#

Then select that select

sharp geyser
#

so

SELECT RANK() OVER (PARTITION BY guild_id ORDER BY score DESC) FROM image;

SELECT user_id FROM result_from_rank WHERE user_id = ?;
```?
lyric mountain
#

U need to include user id in the inner select

#

The outer select can only see what the inner select returns

#

Also you should group the ranking, since you don't want repeated entries

sharp geyser
lyric mountain
#
SELECT user_id
     , rank() OVER (PARTITION BY user_id ORDER BY score DESC) AS rank
FROM image
GROUP BY user_id
#

This will give the outer select user_id and rank fields

#

So u can do where user_id = ?1

sharp geyser
#

oh right

#

yea

#

my b g

lyric mountain
#

Dw, you get used to it

sharp geyser
#

also to make a materialized view, its basically just

CREATE MATERIALIZED VIEW global_rankings AS SELECT user_id
     , rank() OVER (PARTITION BY user_id ORDER BY score DESC) AS rank
FROM image
GROUP BY user_id;
#

or smth like that

lyric mountain
#

With data?

sharp geyser
#

I might be missing smth

#

im on mobile rn so the pages im reading are squished

lyric mountain
#

Idk what that is for

sharp geyser
#

neither do I

#

its just smth I am reading

lyric mountain
#

Nvm

sharp geyser
#

but yea thats how it'd work right?

lyric mountain
#

Yes

#

Also make an index for user id

sharp geyser
#

and then i'd SELECT * FROM global_rankings WHERE user_id = ? when I populate it with REFRESH MATERIALIZED VIEW global_rankings

lyric mountain
#

U can select without refreshing

sharp geyser
#

oh?

lyric mountain
#

Only refresh if you want to grab fresh data

sharp geyser
#

well yea

lyric mountain
#

It'll keep the last snapshot u took

sharp geyser
#

I meant when im updating the leaderboard

lyric mountain
#

Yep

#

Btw, prefix ur views

sharp geyser
#

this is starting to fry my brain ngl

lyric mountain
#

So u can diferentiate them from tables

sharp geyser
#

too much to remember

lyric mountain
#

I put v_ before every view name

#

Or mv_ for mat views

sharp geyser
#

ima have to re-visit this tmrw

#

my brain not braining

lyric mountain
#

Once u have too many tables it becomes hard to find what's a view and what's a table

#

Especially if u get large selects

sharp geyser
#

I see

sharp geyser
#

Chances are ima be in here tmrw again asking the same question

#

cuz my dumbass is going to forget all of this

#

I got this achievement at birth

lyric mountain
#

Sql takes a while, but it becomes very easy once you get used

#

The only issue then is to optimize the queries so ur not being wasteful

sharp geyser
#
create index score_idx on image (score desc);
create index user_idx on image (user_id);

should i add desc to the useridx as well?

lyric mountain
#

Nope, but do add unique

sharp geyser
#

oh?

lyric mountain
#

The more constraints u have the better, so the database needs to do less checks to get data

sharp geyser
#

icic

#

so it will create a new index every entry?

lyric mountain
#

For example, if you dont have unique, if you do where user_id = ?1 it'll still keep looking after finding one

#

Whereas with unique it'll exit as soon as it finds one

#

Since it knows there's not another to find

sharp geyser
#

but wait

lyric mountain
sharp geyser
#

a user can submit multiple images

#

wont that prevent this?

lyric mountain
#

Ah, those are image indexes

sharp geyser
#

the way the ranking is supposed to work is the average of all their image's scores

lyric mountain
#

I was saying to put user_id index on the mat view

sharp geyser
#

oh

lyric mountain
#

Since there's where you'll query data

sharp geyser
#

so put a score index on the image

#

user index on the mat view

lyric mountain
#

Yes

#

Index on what's your main criteria to query

#

Or on what'll be the main sorting

sharp geyser
#

ic

lyric mountain
#

For example, I have a desc index on the xp field for my bot

#

As I'll often query user lvl ranking

#

Just refrain from making too many indexes, as that'll negatively impact insert/update/delete

#

And make the table heavier

sharp geyser
#

alright

#

Do I need a different amt view for global and server leaderboards?

lyric mountain
#

If ur going to put a guild_id column on image, yes

sharp geyser
#

Also, how does the rank function work exactly, because idk if it will do what I need? As i've stated I plan on totalling up the upvotes and then dividing it by the total number of images they've posted to get the avg

#

that avg would be their global score

lyric mountain
#

Rank is what you'd expect

#

It'll classify the entries based on the ORDER BY clause

#

Entries with the same value will share the same ranking

#

If u want to have no repeated rankings then u can use row_number instead

#

If u don't want a classification at all, then just remove the field, use a regular order by

sharp geyser
#

this is becoming more confusing

lyric mountain
#

For example, let's say you have 5 users, with scores 8, 5, 5, 3 and 1

#

Rank will do this:

rank | user
1    | user 1
2    | user 2
2    | user 3
3    | user 4
4    | user 5
#

Row_number will do this:

rank | user
1    | user 1
2    | user 2
3    | user 3
4    | user 4
5    | user 5
#

Regular order by will just sorte the rows, no numeric classification at all

sharp geyser
#

hmmm

sharp geyser
#

I guess my main question is

#

should I take the sum of all their scores from the images they have posted and use that?

lyric mountain
#

Yes, just put it in the mat view

sharp geyser
#

I feel like that number could become quite high and it'd be almost impossible for people to surpass rank 1 person and take the leaderboard spot

#

I want it to be a sort of competition

lyric mountain
#

There's not much u can do tbh

sharp geyser
#

Hmm yea you're right

lyric mountain
#

U could limit number of user submissions per day/week

#

Or how long to allow voting

sharp geyser
#

hm

#

well I need to rethink my plan then

#

originally for global leaderboards I was going to post the message with the vote buttons to an announcement channel and have it crosspost to following channels

#

but now that I think about it

#

I might have a different idea

#
  1. User posts image, it gets sent to a designated server channel.
  2. User happens to become #1 in the server and they are opted in for global leaderboards their photos start to get sent globally via the announcement channel
  3. Now anyone can vote and from that point on it starts affecting their global standing
#

Im not sure how that'd play out functionality wise

#

because people could "double" vote

lyric mountain
#

You can, instead of a numeric column, have a separate table with image_id, voter_id and upvote

#

Where upvote would be a bool

#

Then for getting user score you'd sum all trues and subtract falses from that table

#

Image_id would be only to be able to check whether a user already voted for the image

#

You can even make a unique constraint for it + voter_id

#

So it fails if u attempt to insert the same image_id + voter_id combo

sharp geyser
#

you can do that?

lyric mountain
#

Sure, nothing prevents you from making a composite constraint

sharp geyser
#

I thought if you did that then itd not allow the same user to vote for another image

lyric mountain
#

Even primary keys can be on multiple columns

lyric mountain
#

If u pass 2 columns to the constraint, it'll only require them to have a unique combination

#

But either value can repeat if the other doesn't

sharp geyser
#

icic

#

so something like

#
constraint fk_image_voter FOREIGN KEY (voter_id, image_id) REFERENCES ??
lyric mountain
#

Not foreign, use a regular unique constraint

#

Foreign would be one for each

#

Not both at once

#

Voter_id would point to profile

sharp geyser
#

icic

lyric mountain
#

Image_id would point to image

#

Tho idk if u should put an fk on voter

#

As they might not be on the database

#

Unless u add everyone who interacts with the bot

sharp geyser
#

I was going to force them to signup tbh but that might not be a good idea for those just looking to vote and not post

#
create table profile (
user_id varchar(255) unique not null primary key,
global_agreement bool not null default false
);

create table image (
id varchar(255) not null unique,
user_id varchar(255) not null,
guild_id varchar(255),
url varchar(65535) not null,
score int not null default 0,
constraint fk_user foreign key (user_id) references profile(user_id)
);

create table voter (
id serial,
user_id varchar(255) not null,
image_id varchar(255) not null,
upvote bool not null default false,
unique (user_id, image_id)
);

create materialized view mat_global_rankings as 
    select user_id, row_number over (partition by user_id order by score desc) 
    from image group by user_id;
    

create materialized view mat_server_rankings as
    select guild_id, row_number over (partition by guild_id order by score desc)
    from image group by guild_id;
    

Right so this is my sql, I just added in the voter table but im not quite sure how it will play out in deciding the ranking?

sharp geyser
#

@scenic kelp sorry for the ping but you are the only C# dev I know here

#
        var profile = db
            .Profile
            .Where(prof => prof.UserId.Equals(ctx.User.Id.ToString()))
            .First();

do you know why this could possibly be halting execution of any code after it?

#

I've ran the debugger and either im not doing smth right or it doesnt even know

#

I am using EFCore (NpgSql)

sharp geyser
#

fixed

surreal sage
#

any1 got a clue on how to selfhost FaaS/serverless (for next.js)?

#

(like vercel)

earnest phoenix
#

yo can someone help me cuz welper just reviewed my bot and declined it and i can see my bot page on the website to see if typed my bot prefix wrong

surreal sage
earnest phoenix
bitter granite
frosty gale
#

one popular and pretty feature complete one is supabase

#

at least i think hold on

#

yep its supabase

bitter granite
#

I read FaaS as "Food as a service"

frosty gale
#

its just buzzwords as with almost everything in tech that involves businesses in any way

earnest phoenix
#

just spent a few mins read discord.py doc trying to override default help command

surreal sage
surreal sage
eternal osprey
#
[error] [launcher] error during sbt launcher: java.lang.UnsatisfiedLinkError: Error looking up function 'stat': java: undefined symbol: stat```

i am using sbt package and this is what happens. Why?
surreal sage
wheat mesa
solemn latch
#

I'd just use nextauth

#

I dont like how sessions are managed too much by nextauth, but it works well.

#

Handling sessions in nextjs really will depend on a lot of things.
Sessions can be managed on the client or the server.
For example, an SSR component can handle the session on the servers side.

#

A lot of it is above my head on how you would actually make it work.

But you'll first need to determine if you want the client or server to get session data.(you'll probably want both imo)

#

Say what you want about AI. But at least I don't have to do basic math.

lyric mountain
#

Buckets

#

Also 600 per 10 is 1 req/s

quartz kindle
lyric mountain
#

So u can put a delay of 1.5s between each request

quartz kindle
#

i cant read math formulas exdee

solemn latch
#

The sad part is this is way simplier than what I've seen you doing

quartz kindle
#

xDD

#

the only problem is

#

sometimes AI gets it wrong

#

and you have no way of confirming the result is accurate

solemn latch
#

Oh I do, this is a script for animation in blender ๐Ÿ˜„

quartz kindle
#

xDDD

#

its good if you have something to compare to, or in your case you can see the result

#

but if you dont, then its kinda tricky

solemn latch
#

Yeah, I bet

sharp geyser
#

Well you know because the cookie exists?

#

If the cookie exists they are logged in

#

The client side has access to that localstorage where teh cookie is

#

Just have your client side code keep track of the state.

#

Check the cookie, grab the user data, store it in state

#

log out, delete them from state

quartz kindle
#

but you still need to confirm that the login is valid on every backend request

sharp geyser
#

^

#

Which I think he does

#

I cant remember

slender wagon
#

I think i have become dependent on AI

#

I wish i was like Tim or like some OG guys

#

Long story short build a middleware and just call it as a function on the routes u want to be auth protected

sharp geyser
#

what are you talking bout big bro

#

middleware for your frontend?

solemn latch
#

perfect

#

It figured it out

#

I wonder if I redo it but say 5 itll agree

sharp geyser
#

idk what that ai is talkin bout

solemn latch
quartz kindle
quartz kindle
surreal sage
#

hi chat i need some rust help (i have no experience)

#

im trying to get the latest release tag name of a github repo using octocrab

#
  let octocrab = octocrab::instance();
  let binding = octocrab.repos(REPO_OWNER, REPO_NAME);
  let release_handler = binding.releases();

  match release_handler.get_latest().await {
    Ok(latest_release) => {
      println!("hdfghdh: {}", latest_release.tag_name.to_string())
    }

    Err(e) => {
      eprintln!("check_for_updates: {}", e);
    }
  }```
#

for some reason, release_handler.get_latest().await errors and only that

lament rock
sharp geyser
sharp geyser
#

it seems to be a tower issue

#

try and install a version or two lower than the current octocrab version

surreal sage
#

already at 0.35.0 (0.38.0 = latest) and nothing

surreal sage
#

(and I have no idea how to fix it)

#

as I'm running Tauri, I get the current app version within the Tauri setup callback and then I want to call check_for_updates in the background with that app version

#

yess i think i fixed it

sharp geyser
#

oh you are using tauri

#

should of ran with that

#

cause it could also be tauri

#

๐Ÿ’€

bright valley
#

hey, i developed a giveaway bot, do you guys want to use it :v

eternal osprey
#

Hey guys, i am currently working on an automcoplete feature for my bot.

 async autocomplete(interaction) {
    const premium = await isPremium(interaction.guild.id);
    if(!premium){
      // return
    }```

what would happen in above case? Like would it successfully not execute the autocomplete or will it still run?
sharp geyser
#

wdym

#

oh ic

sharp geyser
#

because its before all your auto complete logic it will never reach it

#

pressumably

lament rock
#

You have to respond to interactions, no?

sharp geyser
#

nah

#

you can just return

#

autocomplete doesn't require a response

#

if it doesn't get one it wont autocomplete

eternal osprey
#

Ah that's sickk

#

Wait can i just autocomplete with an error message lol

#

sum like: "You ain't got no premium broke boy"

sharp geyser
#

Don't think so

#

Since it works as you are typing the slash command

eternal osprey
#

ahh

sharp geyser
#

you might be able to send an embed, but whats the point

eternal osprey
#

yeah true

sharp geyser
#

Just make it clear what your premium features are.

#

Anyone who doesn't read em well, tough luck :D

eternal osprey
#

whahahha exactly, thank you so much

sharp geyser
#

๐Ÿ‘

eternal osprey
#

Ahh hell nah

#

I submitted a spark job on 8tb of data, how the fuck did it double the data on the dfs???

#

I swear it saved 16tb.. i think i am saving the intermediate keys instead of destroying them lmao

quartz kindle
#

it will show a loading screen, sort of

#

it shows this while waiting for a response

#

not sure how long it waits, presumably the usual 3 seconds

#

you can just use "you are not premium" as the default autocomplete response

sharp geyser
#

Forgot you can do that

#

I used to just return nothing

frosty gale
quartz kindle
#

xDDD

sharp geyser
# quartz kindle xDDD

Is it possible to get the stream data of a url without downloading the content first

#

or do I have to

quartz kindle
#

stream data?

sharp geyser
#

yuh

#

like the file stream data

#

contents of file

#

yknow

quartz kindle
#

only if they are in the headers

sharp geyser
#

do you know if it is on a discord url

#

๐Ÿ’€

quartz kindle
#

try making a request and look at the headers

sharp geyser
#

alright

#

what would the header look like?

quartz kindle
#

anything really

sharp geyser
#

Doesn't look like it does

quartz kindle
#

headers about content are optional

#

the only standard one is content-size