#development

1 messages ยท Page 244 of 1

sharp geyser
#

I guess in case some software intercepts it and "creates" it itself

#

it tells you what exactly is creating it

frosty gale
#

it gets stored on your phone locally

#

if your phone has a TEE it gets stored there (aka hardware attestation)

#

if your windows machine has a TPM it gets stored there also

quartz kindle
#

what if i lose the phone? arent they keys backed up to google?

sharp geyser
#

I think they are

#

Cause I have keys I saved to my android on my iphone because I have google logged in

frosty gale
#

not sure if its backed up to google but its possible

quartz kindle
#

so basically we are handing it all to google

sharp geyser
#

not sure

frosty gale
#

im sure if that happens you can toggle it off though

#

as bad as google is they cant force you to

quartz kindle
#

my main concern tho is how to access my accounts if i lose my phone and/or google account

sharp geyser
#

sucks to suck

#

don't lose your phone L

frosty gale
#

similar problem as to losing a password manager or password

#

but im sure you can backup the keys somehow

#

its probably OS dependent

sharp geyser
#

I mean at a certain point there is no way to prevent something

#

they can allow you to backup your keys, but if you lose access to the places you backed them up there's nothing else you can do except maybe get new ones generated but idk how that works

civic scroll
#

tim

quartz kindle
#

ok i just tested it out, looks pretty cool

civic scroll
#

i think i will need to learn shaders if i want to make anyway remotely cool WAH

quartz kindle
#

when logging in i can chose whether i want to use username+password or a passkey device

#

so i can still use user+pass if i dont have myphone

quartz kindle
frosty gale
#

and the best part is the server only gets your public key, so if the company/server gets breached no user credentials get leaked

sharp geyser
#

damn no rust implementation

#

im not trying to impl webauthn myself

#

fuckkkk that

frosty gale
#

i did it in rust

civic scroll
frosty gale
#

my backend is going to be in rust

#

it was easier to implement than in nodejs

sharp geyser
#

I dont have the paitence to use rust rn

frosty gale
#

but there are a few steps involved and you need to understand what to verify

#

so its best to use a library

#

there is one for rust

sharp geyser
#

where

#

they must of not updated teh website for it then

frosty gale
sharp geyser
#

I guess there is that

frosty gale
#

you think the rust community wouldve missed a single opportunity to port something to their language?

sharp geyser
#

webauthn is cool ig, but I dont see its uses for me rn

civic scroll
sharp geyser
#

Actually I can use it for vidcord

#

not any of my other ones

quartz kindle
#

icba seting up vaulwarden, jhust gonna use bitwarden itself

#

now i just need to manually move over all my 50+ accounts that i have written in plain text

#

:^)

frosty gale
#

bad thing with it though is the webauthn standard supports authenticator attestation

#

that means a website can force you to use a single authenticator to login

#

specific*

quartz kindle
#

that makes sense for a business perspective, a company might want employees to use the company's own internal authenticator

frosty gale
#

google could make it so if you want to use webauthn, you have to have an unrooted phone or another phone approved by google/the company

#

if its rooted the TEE will not sign the attestation

#

and google will know

#

but thats the only downside and i doubt theyd do that

quartz kindle
#

also, i know why my windows doesnt have the option to store locally

#

i dont use lock screen

#

:^)

frosty gale
#

most secure IT system in brazil

quartz kindle
#

i havent used a windows password in 20 years

frosty gale
#

longer than how old most people on this server are

sharp geyser
#

tim

#

you need a password.....

#

omw to tims computer rn

quartz kindle
frosty gale
quartz kindle
#

i've always found windows passwords the most useless thing in the world

#

because 1, theres only me, and 2, i can just boot into some recovery iso and remove the password

sharp geyser
#

Just tell me a 50 ft radius at least

quartz kindle
#

:^)

civic scroll
quartz kindle
#

third world security: danger

sharp geyser
#

yea tbf

#

Id rather jump off a mountain than go through the brazilian jungle

radiant kraken
quartz kindle
#

when relatively famous but loved-by-community people make a kickstarter campaign

civic scroll
quartz kindle
#

i wish it was me

civic scroll
frosty gale
quartz kindle
frosty gale
#
  • rust backend to ensure prevention of memory corruption
sharp geyser
#

Right, so im not too sure on how swap memory works, but if a program requires at least 12gb of ram to function properly...could I substitute that with swap if I don't have the full 12gb?

quartz kindle
sharp geyser
#

Well no, but as the program is using ram, I can make the os prefer swap over ram no?

#

like on linux vm.swappiness controls how often the os swaps between ram and swap memory

lament rock
#

Yeah you can adjust the "swapiness"

sharp geyser
#

but I am wondering will this be sufficient

#

I dont want to upgrade to a higher ram server rn to run a test rust server

#

so I was wondering if I could just use swap in place of the missing ram needed

lament rock
#

I think your best bet is to optimize your program first

quartz kindle
#

you dont need to tho

sharp geyser
#

wdym

#

rust requires at least 8-10gb (12gb preferably)

#

I only got 6 Sadge

quartz kindle
#

the program will ask for whatever memory it needs, the OS will simply do its best, which includes many things, including swap, memory compression, paging files, etc...

sharp geyser
#

ok

#

but tim

#

thats not what im asking

quartz kindle
#

if the OS cant meet the requirements, the program will just run slow or crash

sharp geyser
#

I know the os will do its best

#

but will swap be sufficient to fill in the holes or is that not how swap works

lament rock
#

Swap usually starts by dumping inactive programs memory to disk

quartz kindle
#

if you have 6gb ram and 6gb swap, it will be sufficient to run the program, it will just run slowly

lament rock
#

The memory still has to be in physical memory at some point

lament rock
#

But if the same program has to use all physical memory and swap at the same time it probably wont work

sharp geyser
#

well

#

Its worth a try

#

I don't have the money to upgrade rn, and quite frankly I am bored and want to try my hand at making rust plugins again

eternal osprey
#
const enum variable6 {
test = 1, test2 = 3
}
console.log(typeof (3 as variable6))

why does this still show as a number?

#

like i can remember, in java we could take normal numbers, and cast them to enum types.
How can we do that in ts?
I assume that as is like cast in java/c++?

neon leaf
#

typescript?

eternal osprey
#

ye

neon leaf
#

as in typescript only changes the ts type

#

not the js type

#

in this case you would need to write custom logic to do this

#

there is no way to cast a number to an enum built in

quartz kindle
sharp geyser
#

poise?

#

I mean, you can definitely make use of macros here

#

It would be similar to what @radiant kraken made for our rocket routes

#

let me

#

get the code

#

one sec

#
#[macro_export]
macro_rules! gen_command_routes {
    ($($command:ident),*) => {
        $(mod $command;)*

        #[inline(always)]
        pub fn routes() -> Vec<Something> {
            vec![$($command::$command),*]
        }
    }
}

and you'd use it

gen_command_routes! {
  ping
}
#

providing that your ping cmd file is called ping and your command fn is also called ping

#

so

// ping.rs
pub async fn ping() {}
#

then you would just

commands::routes() where you tell poise what commands to load

#

Sorry if this is confusing (I myself hardly understand macros) I just vaguely know how to read it

#

@covert gale It helps to think macros like regex

#

* matches zero or more

#

tbh

#

macros are exactly just regex

#

but rust specific regex

#

btw

#

that macro expands to

mod ping;

pub fn routes() -> Vec<Something> {
  vec![ping::ping,]
}
#

now if you gave it multiple

gen_command_routes! {
  ping,
  avatar
}

it expands to

mod ping;
mod avatar;

pub fn routes() -> Vec<Something> {
  vec![ping::ping,avatar::avatar,]
}
#

Let me break it down for you

#
#[macro_export]
macro_rules! gen_command_routes {
    ($($command:ident),*) => {
        $(mod $command;)*

        #[inline(always)]
        pub fn routes() -> Vec<Something> {
            vec![$($command::$command),*]
        }
    }
}

Note: $ declares a macro variable containing the matched result
($($command:ident),*) - Match a identifiers that can either be zero or more (aka you can have zero, or you can have more than zero)
$(mod command) - basically puts mod ping into the file
No idea what #[inline(always)] does tbh, I know it inlines it but no idea why you specify always
vec![$($command::$command),*] - Specify that you are putting in, zero or more references to $command (the macro variable containing the identifier passed to the macro) becoming something like vec![ping::ping

#

@covert gale ^^^

#

This is the best I can do to explain it

#

@radiant kraken can likely explain it better if I missed anything

#

Pretty much

#

Its quite literally just rust specific regex

#

Here is a detailed explanation

#

I cba to read it tho

#

No problemo

#

Just make sure to credit null

#

realistically you'd be doing this in a mod file inside the folder commands

#
// mod.rs inside commands folder
gen_command_routes! {
  ping
}
#

then inside main.rs

commands::routes()
#

to get the vector of commands

proven lantern
sharp geyser
proven lantern
radiant kraken
radiant kraken
#

you explained it pretty well :)

frosty gale
#

programmers insisting on explicitly specifying inline even though single line functions already get inlined automatically

#

if applicable*

#

depending on usage of functions you can make inlining impossible

winged linden
#

can someone help? i am having a weird ass issue

#

const { client } = require("../../ufo");

if i have this in a specific file it works, if in another file it doesnt

lyric mountain
#

is the "another file" in the same folder?

winged linden
lyric mountain
#

did u save the file?

quartz kindle
winged linden
winged linden
quartz kindle
#

does ufo.js require a file that requires extra.js?

lyric mountain
#

that import chain restriction is ridiculous lmao

winged linden
lyric mountain
#

where is ufo in the file tree?

quartz kindle
winged linden
lyric mountain
#

try creating a new file and importing it

#

if it works, then it's circ depend

quartz kindle
#

easy way to test (and fix), in extra.js, remove the require from the top of the file, and put it inside the function that needs to access the client

winged linden
lyric mountain
#

then it's what tim said

winged linden
#

hmm

lyric mountain
#

I dont get why js has issues with that, only other lang I know that cannot deal with bidi imports is delphi

quartz kindle
#

it loads a file and parses it, when it reads another require, it loads the next file and parses that, before finishing parsing the previous file

lyric mountain
#

that sounds inefficient

quartz kindle
#

welp, thats how they chose to do it

#

because the file being required is not just parsed, it is also executed

lyric mountain
#

does esm also have that issue?

quartz kindle
#

and to be executed, it needs to have everything it needs loaded

quartz kindle
#

because like, if you have a file1.js like this:

console.log(10)
#

and you require that file, it will log, because the code executes

#

buf if your file1.js is like this: ```js
require("saomething else")
// or import something else

console.log(10)

#

the console.log needs to execute regardless

#

so what if it needs to log the contents of the loaded files?

#

not possible to log that without the full file chain being resolved synchronously

lyric mountain
#

so if a single lib in the chain has bad code like an infini loop then it'll get stuck if a single file references it

quartz kindle
#

yes

#

unlike compiled langs where a compiler examines the code and puts it together beforehand, an interpreted lang will dynamically load and run the file during runtime

#
// a.js
const b = require("./b.js");
console.log(b);
module.exports = "A";

// b.js
const a = require("./a.js");
console.log(a);
module.exports = "B";

what would happen if you run either of these?

#

a.js needs to log the contents exported by b.js, but when b.js loads, it needs to first log the contents exported by a.js, but a.js is still waiting for b.js to deliver its exported content, but it wont do it before it logs what a.js is exporting

#

so it will loop infinitely until it exceeds maximum stack size (not sure about this, maybe node is smart and just stops it from looping), and just return undefined

winged linden
#

Basically i might have found the issue

ufo.js requires a path called api.js
api.js requires ufo.js (it works fine though)
api.js requires a functions file extra.js
extra.js requires client.js

quartz kindle
#

if ufo.js is your main file, the one you run node ufo.js on, it should never be exporting anything

#

if it has something that needs to be exported, put that something in a separate file and import it in the main file

winged linden
#

i am only exporting redisClient & the discord client

#

i think the issue is with the redis client

#

gonna do it in a seperate file

#

thanks ๐Ÿค

quartz kindle
#

also, ideally you should not be exporting created instances

#

for example if you have a class in a file (like the discord "Client" class), the file should export the class, and the file who imports it should instantiate (new Client) the class

#

the file where the class is should not export a "new Client" directly

#

its also better for the class or instance of a class to call/require the functions/files it needs, and not the other way around

winged linden
#

how do you properly pass the discord client to your api routes file then?

quartz kindle
#

a function in extras.js should not require client, the client should require extras.js

quartz kindle
#

there are a million different ways to do things, but in general there is usually 1 thing that is the main thing the program is doing, and everything else is extras or addons to the main program

#

its much easier to design things with that in mind than trying to have multiple "main things"

winged linden
#

Yeah exactly

#

Main thing is obv the bot in my case

#

the api is an addition for my dashboard

#
const app = express();
app.use(cors());
app.use(bodyParser.json());
app.listen(PORT, () => {
  console.log(`API running on port ${PORT}`);
});
app.use("/", require("./routes/api"));```

thats how i currently do it, this is in the main ufo.js file
lyric mountain
#

why ufo btw

winged linden
lyric mountain
#

ah

quartz kindle
#

how does api.js look like?

winged linden
# quartz kindle how does api.js look like?

This is what it requires

const router = express.Router();
const { v4: uuidv4 } = require("uuid");
const { redisClient } = require("../ufo");
const { PublicKey } = require("@solana/web3.js");
const { Web3 } = require("web3");
const { BotStatus } = require("../src/functions/BotStatus");
const web3 = new Web3();
const { client } = require("../ufo");```
quartz kindle
#

the router?

winged linden
quartz kindle
# winged linden correct

you can do something like this:

// api.js
module.exports = function createRouter(client) {
  router.get(...);
  router.post(...);
  return router;
}

// ufo.js
const createRouter = require("./routes/api");
app.use("/", createRouter(client));
#

in fact you can move the entire express part into the api.js file

#

dont need express at all in ufo.js

#

ufo.js can just do ```js
const api = require("./routes/api");
api.start(client, PORT);

#

and have a start function do all of the initialization and routing of express

winged linden
quartz kindle
#

if you want to store them to look at them later, then yes

#

but there are special dbs for that

#

one that supports append-only writes

#

such as time-series dbs

#

you can also let the OS handle that

#

linux itself for example stores all logs in various append-only log files

#

you can easily setup something that redirects all stdout into some log file and then just print/console.log stuff away

#

but a proper time-series database will give you a lot more tools to work with such data

eternal osprey
#

Shit's bullshit let me cast my thing pls

#

pls ts

#

mannn all my bot does is dm ppl who join the server..
shit's annoying

neon leaf
quartz kindle
#

in js types dont exist, only values

#

in ts, types exist, but they are removed when compiling

eternal osprey
#

though it's not needed, i can just use a switch right

lyric mountain
lyric mountain
#

dyno and mee6 are blocked for this very reason

eternal osprey
#

mannn

#

are they still blocked

#

cuz idk it;s not harmful right

lyric mountain
#

yes they are

#

I wont unblock anytime soon

#

it's not harmful but annoying af

eternal osprey
#

damn

lyric mountain
#

especially mee6 cuz it's everywhere

eternal osprey
#

sorry ig

deft wolf
eternal osprey
#

yeah that shit is annoying asf indeed

quartz kindle
eternal osprey
#

i am joining a gaming community and out of nowhere i get 18+ servers shoved into my screen

deft wolf
#

fr fr

eternal osprey
quartz kindle
neon leaf
quartz kindle
pearl trail
neon leaf
#

I may need to redo my amazing js

#

(I should just use a library for this)

quartz kindle
neon leaf
#

ok now it uses matterjs for physics which seems to work a lot better (who couldve guessed)

quartz kindle
#

i just see a dark screen with some settings buttons, but i dont see a way to start/create the blocks

neon leaf
#

right click

quartz kindle
#

ah

#

they dont move tho?

neon leaf
#

did you set it to static

quartz kindle
#

ah

#

xD

#

physics engines always have issues with "resting" position

#

throw a bunch of objects in a pit and they will keep moving forever and never settle

neon leaf
#

ye

quartz kindle
#

still fun

neon leaf
#

oh god

quartz kindle
#

xD

neon leaf
#

oh wait i broke importing oof

#

nvm

pearl trail
lyric mountain
#

I can almost hear source engine's clank sound from the bottom part

eternal osprey
#

Am i a bitch that i secretely fall in love with wordpress?

#

I used to do all my website coding in html, css etc but damn that was crazy

#

Wordpress is so easy to manage

lyric mountain
#

that's why non-coders use it

eternal osprey
#

๐Ÿ˜ญ

lyric mountain
#

it's easy & cheap to get a website running

eternal osprey
#

yeah

#

So far ive been creating my sites in plain js/ts and html/css with bootstrap

#

Its been a pain cant lie

#

Is react worth it to speed up the process of developing a site?

lyric mountain
#

personally I hate react

#

first because it's very prone to dependency hell

eternal osprey
#

I see

lyric mountain
#

second because the source quickly becomes unreadable if you lower your guard

eternal osprey
#

I see yeah thats true

#

Could i basically rely solely upon a css library and plain js/html?

lyric mountain
#

on react? not really

#

you need to use react in react

eternal osprey
#

No i mean without react

lyric mountain
#

I like doing sites with pure html5 kit

eternal osprey
#

i hear everyone talking about react and thst its a must have etc, but idk i find it bs cuz ive been creating some good sites without

lyric mountain
#

dynamic pages are a bit complicated, but jquery is a thing

lyric mountain
#

it's like python, it's easily the most popular lang

eternal osprey
#

Yeah true

lyric mountain
#

but it doesn't mean anything else is inferior

#

I'd say use html or the closest-to-html library you can find

#

the output becomes clean and you get better grip on your changes

eternal osprey
#

Damn you gave me hype. Ill stick with the vanilla shit and bootstrap then

scenic kelp
#

i am a big svelte advocate i love you svelte

#

i used to be hardcore vanilla css/html

#

i am like 10x more productive with svelte and tailwind

lyric mountain
#

I never liked how "pre made" it felt

eternal osprey
#

That shit makes my site responsive tho

#

Without i am lost

#

Lost in the sauce

lyric mountain
#

nah, you can easily make responsive sites by using flexbox

#

bootstrap is more for standardized themes

#

you can easily make your own stylesheets and have 999x less classes on elements

eternal osprey
#

crazy

#

yeah that's true

#

i've been relying way too much on bootstrap

#

fuck it guys i go in raw

#

plain html and js

lyric mountain
#

but if u like bootstrap then it's fine too, my reason for avoiding is that it feels too much like theme packages I've used before

#

it works dandy, until you need to change something

#

then it's documentation hell to find out how to do it without cascade breaking

lyric mountain
#

u dont need to keep refreshing to see changes

eternal osprey
#

yeah that's true

eternal osprey
quartz kindle
#

if you're gonna write your own CSS, check out LESS or even SASS

#

being able to nest CSS rules makes everything so much easier and smoother

lyric mountain
#

also never forget that instead of ```css
#parent #this {

}

#parent #that {

}

#parent .those {

}
u can just docss
#parent {
#this {

}

#that {

}

.those {

}
}

quartz kindle
#

i dont remmeber that ever being possible without LESS/SASS

lyric mountain
#

idk, found out when I was making the roulette thing

#

it was made using pure html + css (+ js later)

#

no libs or anything

quartz kindle
#

oh dayum

#

i didnt know they actually made it built in, finally holy shit

lyric mountain
#

ie is dead, so no need to worry abt it anymore

solemn latch
quartz kindle
solemn latch
#

jpeg-xl

quartz kindle
#

oh

solemn latch
quartz kindle
#

considering what happened to jpeg2000

#

i wouldnt count too much on it

solemn latch
lyric mountain
#

all I want is anything other than gif on discord

solemn latch
#

I just want sharp to add native support, but they refuse because chrome wont.
But chrome wont, because webdevs dont.

So its a circle of no one adding support because others wont.

eternal osprey
#

what yall think of this logo

#

imo it's too white

#

could also do this

lyric mountain
#

what about black?

#

white aint gonna work as the background is bright already

quartz kindle
#

yeah try black

lyric mountain
#

could even use transparent, then darken the logo if page background is too bright

eternal osprey
#

hmm black let me see

neon leaf
neon leaf
quartz kindle
neon leaf
#

smh abusing the cubes

quartz kindle
#

:^)

lyric mountain
quartz kindle
neon leaf
#

i dare you

lyric mountain
#

will do it later

#

oh wait, u mean to the app?

#

just get the source engine collision sound and add it to onCollide or whatever you use

neon leaf
crystal wigeon
#

can i send svgs in embed image?

#

or just image

quartz kindle
crystal wigeon
#

mhm

crystal wigeon
#

ik canvas is more cpu intensive. flork_think im thinking of drawing stuff using svg then load it onto canvas and stream the jpg to embed image

#

idk if that will be faster because im like drawing shapes and texts and some icons on it

quartz kindle
crystal wigeon
#

a couple of rectangles

#

and couple of images

#

like a banner

quartz kindle
#

if the end result is gonna be to output an image, going canvas directly is probably preferable

crystal wigeon
#

hmm

#

i feel like if i were to add some animations canvas will start causing issues

#

or lag

quartz kindle
#

where do you want to display those animations?

crystal wigeon
#

whereas svg is just simpler to work with no? and it just loads faster

#

on the canvas

quartz kindle
#

i mean, where on the user's end

crystal wigeon
#

ah on embeds images

quartz kindle
#

on discord?

crystal wigeon
#

yea

#

the animations will be in the image itself

quartz kindle
#

what animation formats does discord support?

crystal wigeon
#

idk that

quartz kindle
#

gif, mp4, anything else?

crystal wigeon
#

gif

#

ig

quartz kindle
#

idk if they support apgn or animated webp

crystal wigeon
#

mp4 will be weird

quartz kindle
#

in any case, those are all done better with canvas

crystal wigeon
#

ive seen png images ebing animated and shown on discord

#

got it

quartz kindle
#

svg animations are done by css, you cant put that into an image

crystal wigeon
#

mm, ok so is there a way for me to add text into a rect on canvas and tell me to automatically take the width of the text?

#

or do i have to calculate the text width and adjust it

quartz kindle
#

you have to calculate stuff, but canvas does offer a measureText() method

crystal wigeon
#

ic, also canvas positioning is all absolute right?

#

is there any relative positioning i could use

quartz kindle
#

yes, its all based on XY 2d coordinates

crystal wigeon
#

alr

quartz kindle
crystal wigeon
#

man wish there was an easier way kekcry

quartz kindle
#

welp, its a good learning experience

#

i enjoyed watching my shit slowly turn up good looking with canvas

crystal wigeon
#

yeah. gotta learn some optimal ways to write text and draw on canvas and make it load in less than 50ms

lyric mountain
quartz kindle
#

and the funny bugs i got from miscalculating stuff

lyric mountain
#

do you NEED infinite resolution?

crystal wigeon
#

my only concern is canvas taking too long

lyric mountain
#

(also discord doesnt display svgs)

quartz kindle
crystal wigeon
#

im trying to compress all my images considerably small. but if i allow users to like upload their own image it might be problematic

quartz kindle
#

well not exponentially but like cubically or something, idk

crystal wigeon
#

like showing a banner

lyric mountain
#

it's cubically yeah square

#

w * h

quartz kindle
quartz kindle
crystal wigeon
quartz kindle
#

then its fine

#

you can easily generate those in < 100ms

crystal wigeon
#

yeah well there gonna be 2 images, lets see. also is there way i can like fit this image to have cover object fit into a rect?

#

like on canvas i have a rect of some 100x200, i want to fit the banner in this box

#

and have rounded corners

quartz kindle
#

yes, canvas's drawImage method has variables for source cropping/resizing and destination resizing

quartz kindle
crystal wigeon
#

can.t i use roundRect and then add some image as bg?

quartz kindle
#

sure

crystal wigeon
#

how

quartz kindle
crystal wigeon
#

ig need to use clip path

neon leaf
#

TPS: 22 / 240 (9%)
Bodies: 2917, Removed 1513

very small slowdown

quartz kindle
crystal wigeon
#

thanks

quartz kindle
#

scroll down to example images

#

for example

#

you draw the image you want

#

then you change mode to destination

#

then you draw the rectangle on top of the image

#

otherwise you can also do clip paths, with beginPath(), moveTo(), lineTo(), arc(), closePath() and then clip()

neon leaf
#

@lyric mountain it has been completed

#

it sounds absolutely horrible

lyric mountain
quartz kindle
#

xDDDD

neon leaf
#

nah someone make a pr (ok=

quartz kindle
#

just got a dm from someone

#

"hi, im a developer and i have a client that wants to use your api, can you help me"
"i asked chatgpt to parse the response your api gives me, but the result is wrong"

#

developer in 2024

eternal osprey
#

crazy

quartz kindle
#

its not even hard, i literally gave him copy pastable code to parse the api response into the format he wants

#

and hes still asking chatgpt to do it for him

#

and getting wrong results

#

lmfao

#

"developer" my ass

solemn latch
real rose
#

i wish i could send it on Teams to my colleagues

solemn latch
#

lol

eternal osprey
#

what yall think of the little design on the bottom left corner

#

it's a webpage that explains how we check for downtime.

#

tryna make a very minimalistic site

#

(site colors are orange, white and black btw)

#

maybe black actually loops beter!

quartz kindle
#

but black doesnt look bad either

lyric mountain
#

I prefer black

#

feels lighter on the eye

neon leaf
#

same

proven lantern
#

have you ever seen this? should all these people just be banned?

pearl trail
#

well those people are people who flagged by discord/cloudflare because spamming scam links

#

idk but that's my guess

quartz kindle
#

i have a few of those on mine, i didnt do anything to them

#

they didnt do anything either (yet)

spark flint
#

You already see that marker in chat, up to you if you want to ban

#

They are more than likely already disabled / restricted from chatting in or joining servers

proven lantern
#

i should just kick them. they might spam other members

sharp geyser
#

As I was looking in a server I own, and null had that next to her

pearl trail
spark flint
#

They disable only some of the time

#

Generally if itโ€™s a new account or if the account shows indicators of compromise

pearl trail
#

i joined 121 servers and i'm surprised there's none that is a spamming server KEK

lyric mountain
#

I mean, u need to kinda look for to be in one

solemn latch
#

๐Ÿ‘€

sharp geyser
#

Love it

pearl trail
feral rose
#

Why does on_dbl_test but not on_dbl_vote literally makes no sense

sharp geyser
#

Anyone here ever use grafana with nginx and cloudflare origin certs? I am running into an issue where visiting the page it shows a 400.

grafana.ini

[server]
# Protocol (http, https, h2, socket)
protocol = https

# This is the minimum TLS version allowed. By default, this value is empty. Accepted values are: TLS1.2, TLS1.3. If nothing is set TLS1.2 would be taken
;min_tls_version = ""

# The ip address to bind to, empty will bind to all interfaces
;http_addr =

# The http port  to use
http_port = 3000

# The public facing domain name used to access grafana from a browser
domain = grafana.greenzone101.com

# Redirect to correct domain if host header does not match domain
# Prevents DNS rebinding attacks
enforce_domain = false

# The full public facing url you use in browser, used for redirects and emails
# If you use reverse proxy and sub path specify full url (with sub path)
root_url = https://grafana.greenzone101.com/

# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
serve_from_sub_path = false

# Log web requests
;router_logging = false

# the path relative working path
;static_root_path = public

# enable gzip
;enable_gzip = false

# https certs & key file
cert_file = /etc/ssl/certs/somecert.pem
cert_key = /etc/ssl/certs/somecert.key

nginx

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name grafana.greenzone101.com;

    ssl_certificate /etc/ssl/certs/somecert.pem;
    ssl_certificate_key /etc/ssl/certs/somecert.key;

    ssl_verify_client on;
    ssl_client_certificate /etc/ssl/certs/cloudflare.crt;

    location / {
      proxy_pass    http://127.0.0.1:3000;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection 'upgrade';
      proxy_set_header Host $host;
      proxy_cache_bypass $http_upgrade;
    }
}
#

nginx looks setup properly

#

it seems to be the grafana.ini file causing problems

quartz kindle
#

you're not using them at all, you're connecting via http

tribal bridge
#

Since I got my bot added to Top.gg, I've been getting errors with my bot, which forces it to go offline. Been getting an error with webhooks, and also this one here.

      throw new DiscordAPIError(data, "code" in data ? data.code : data.error, status, method, url, requestData);
            ^

DiscordAPIError[50013]: Missing Permissions
    at handleErrors (F:\YannaBot\Bot\node_modules\@discordjs\rest\dist\index.js:730:13)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async SequentialHandler.runRequest (F:\YannaBot\Bot\node_modules\@discordjs\rest\dist\index.js:1133:23)
    at async SequentialHandler.queueRequest (F:\YannaBot\Bot\node_modules\@discordjs\rest\dist\index.js:963:14)
    at async _REST.request (F:\YannaBot\Bot\node_modules\@discordjs\rest\dist\index.js:1278:22)
    at async TextChannel.send (F:\YannaBot\Bot\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:177:15) {
  requestBody: {
    files: [],
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      enforce_nonce: false,
      embeds: [
        {
          color: 3447003,
          description: '![YannaLevelUp](https://cdn.discordapp.com/emojis/1267046635217879091.webp?size=128 "YannaLevelUp") @coarse belfry, you have reached Level 1!'
        }
      ],
      components: undefined,
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: undefined,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined,
      thread_name: undefined,
      applied_tags: undefined,
      poll: undefined
    }
  },
  rawError: { message: 'Missing Permissions', code: 50013 },
  code: 50013,
  status: 403,
  method: 'POST',
  url: 'https://discord.com/api/v10/channels/707673693160996895/messages'
}

Node.js v20.14.0```
quartz kindle
#

the channel ID is 707673693160996895

#

you can look up this channel in your bot's channel cache, and check which permissions are causing the issue

#

but ultimately you will need to check permissions before sending the message, and you also need to catch the error if sending fails to prevent the crash

tribal bridge
#

Only thing I can think of is that its within a server thats added my bot

sharp geyser
#

now its sending this tho

quartz kindle
sharp geyser
#
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name grafana.greenzone101.com;

    ssl_certificate /etc/ssl/certs/greenzone101.com.pem;
    ssl_certificate_key /etc/ssl/certs/greenzone101.com.key;

    ssl_verify_client on;
    ssl_client_certificate /etc/ssl/certs/cloudflare.crt;

    location / {
      proxy_pass    http://127.0.0.1:3000;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection 'upgrade';
      proxy_set_header Host $host;
      proxy_cache_bypass $http_upgrade;
    }
}
#

and in grafana I set http_addr to be 127.0.0.1

#

since it was assigning to * aka all interfaces

quartz kindle
#

did you remove https from grafana?

sharp geyser
#

no

#

because I need it to be https

quartz kindle
#

you dont need grafana to be https

sharp geyser
#

oh?

quartz kindle
#

you already have nginx

#

proxy_pass http://127.0.0.1:3000

#

nginx connects to grafana via http

sharp geyser
#

Thanks tim

#

you are a godsend

quartz kindle
#

https is only for outside networks, you dont need https for internal networks

sharp geyser
#

I was under the assumption grafana needed to be https as well

#

Cause thats what the docs told me

quartz kindle
#

only if you expose it to the outside

#

and access it without nginx

sharp geyser
#

well thanks a lot tim

#

<3

quartz kindle
#

np

quartz kindle
feral rose
frosty gale
#

what is grafana

sharp geyser
#
        private async Task<long> GetBalance(string playerId)
        {
            long res = 0;
            _sqlite.Query(new Sql("SELECT balance FROM player WHERE playerId = ?", new object[] { playerId }), _conn, async result =>
            {
                result[0].TryGetValue("balance", out object balance);
                if (balance == null)
                {
                    Debug.LogError($"Economics: Error reading balance: {balance}");
                }
                res = await Task.FromResult(Convert.ToInt64(balance));
            });

            return await Task.FromResult(res);
        }

For some reason this looks wrong skuLul

#

It doesn't seem to error but like

#
        private async Task<long> GetBalance(string playerId)
        {
            // Set an initial res value to be 0
            long res = 0;

            // Perform an sql query to get the balance based off the playerId
            _sqlite.Query(new Sql("SELECT balance FROM player WHERE playerId = ?", new object[] { playerId }), _conn, result =>
            {
                // Check if result is empty, if so report it. Later make this so it actually reports at some point.
                if (result.IsEmpty())
                {
                    Debug.LogError("Economics: Nothing found for that user.");
                }

                // If result is not empty, balance must exist.
                var balance = result[0]["balance"];

                // Convert balance to be an Int64 aka long
                res = Convert.ToInt64(balance);
            });

            // Return res as a task result
            return await Task.FromResult(res);
        }
digital swan
ionic schooner
#

grafana is beautiful

#

we love grafana

eternal osprey
#

i see so many sql prijects on github not preparing their statements.

#

is there a way to preview html files on discord?
Not the actual code inside the html file, but a preview of the actual site the file described.

lament rock
#

Me getting prepared for my statements against sql and how you should totally just use a json DB :)

#

Oops I forgot my /s

scenic kelp
winged linden
quartz kindle
proven lantern
#

i can't believe intel stock just crashed. it only too 2 generations of faulty processors to make it happen

wheat mesa
#

Tbf many chipmakers arenโ€™t doing well rn

quartz kindle
#

its like the boeing situation

proven lantern
wheat mesa
#

My poor AMD shares are down pretty bad rn

#

Still up from what I bought them at but still

#

Same with my NVIDIA stock

#

Never wouldโ€™ve bought Intel stock though. Theyโ€™ve been downhill for years

quartz kindle
#

lel

proven lantern
#

they might be a buy in a a year or so

wheat mesa
#

Doubt it

proven lantern
#

they'll be bailed out

wheat mesa
#

People have been saying that for years

#

Their stock peaked in literally 2000

proven lantern
#

dont they have a new foundry being built now

wheat mesa
#

They havenโ€™t been able to capitalize off of the modern era of chip making and to me thatโ€™s a very bad sign that something isnโ€™t right there

proven lantern
#

something isn't right

wheat mesa
#

AMD is doing much better than Intel ever has, I trust them a lot more

winged linden
sharp geyser
#

Ive not used async without using Task so idk how else to do it

scenic kelp
#

ah that makes sense

#

you absolutely should be using task for async

frosty gale
#

immediate critical vulnerability if you dont use them

#

even sanitizing values before inserting into an sql query is risky

#

best to tell the db engine whats sql and what isnt

eternal osprey
#

like 40% of the projects don't prepare their statements

#

or sanitize anything

eternal osprey
#
cron.schedule('0 5 * * *', () => {
  scrape();
}, {
  scheduled: true,
  timezone: "America/New_York" 
});

hey guys i am a bit restarted right now.
i want to run the script at 12 am, each day in est time. Would this be configured right/

#

idk about the whole am pm type thing, i use 24h like any other country

pearl trail
#

that means at 5am

neon leaf
#

0 0 * * * should be correct

eternal osprey
#

owh damn

eternal osprey
neon leaf
#

its 0:00 so 12am

eternal osprey
#

wait no i remember 0 0 being at night

#

ah so 0 12 would be in the morning?

neon leaf
#

i think you are talking about 12pm

#

yes

eternal osprey
#

ah yeah

#

thankss!

neon leaf
deft wolf
#

r word

eternal osprey
#

it is tho ngl

#

shit got me confused asf

neon leaf
#

i dont get why 12pm is 12:00

#

and 1pm is 13:00 ????

#

that together is so weird

#

couldve just done 1-12 = am
13-24 = pm

pearl trail
neon leaf
#

Ye ik

#

That's normal

neon flicker
#

It throws an error to try to edit the components an interaction reply that already has a few

#

How may I avoid it?

eternal osprey
neon flicker
#

Aw, I just realised that I forgot to use .setCustomId() for the new components

#

Nevermind, it still throws the same error

rawError: {
    message: 'Invalid Form Body',
    code: 50035,
    errors: {
      components: { '0': { components: { '0': [Object], '1': [Object] } } }
    }
  },
eternal osprey
#

i hjate it when i explain stuff to others but they end up ignoring me

#

lemme retry again, set the hook from one to the other and then reverse the entity to be able to reload it.

#

no jk, please show me your code @neon flicker

#

can't help without any form of code.

eternal osprey
#

i just created a ticket saving bot

#

what yall think ๐Ÿ—ฃ๏ธ

#

it saves ticket transcripts to maria db, and i then host a private weblink for it for the users to see

#

only problem is that i need some way to make sure that people can't randomly enter someone else's ticket.

frosty gale
# neon leaf

sorry you have used the "R" word which can be used to describe mentally challenged individuals in a derogatory way

#

back in my day it wasnt such a big deal

frosty gale
eternal osprey
#

srry chloe

#

my sincere fucking apologies ๐Ÿ—ฃ๏ธ

wheat mesa
#

Aka 00:00

#

Then by noon (12pm) itโ€™s 12:00

#

An hour later itโ€™s 1:00pm/13:00

scenic kelp
#

12pm and 12am are also completely arbitrary

#

even the US government used 12 am for noon as recently as 2000 smth

neon flicker
#

It fixed it eventually to set the styles of the buttons

sharp geyser
#

Hey guys, I recently decided to take a look at valve's RCON protocol and I can't really make heads or tails of it

#

I am also not exactly sure how to form a TCP packet to send over

proven lantern
#

AI knows

sharp geyser
#

I see

#

Makes sense

proven lantern
#

here's a zig example

const std = @import("std");

pub fn main() !void {
    // Create a little-endian integer
    const value: u32 = 0x12345678;

    // Convert host integer to little-endian bytes
    var bytes: [4]u8 = undefined;
    std.mem.writeIntLittle(u32, &bytes, value);

    // Print the bytes
    std.debug.print("Little-endian bytes: ", .{});
    for (bytes) |byte| {
        std.debug.print("{x:0>2} ", .{byte});
    }
    std.debug.print("\n", .{});

    // Read little-endian bytes back to an integer
    const read_value = std.mem.readIntLittle(u32, &bytes);
    std.debug.print("Read value: 0x{x:0>8}\n", .{read_value});

    // Example for RCON-like packet
    var packet: [12]u8 = undefined;
    std.mem.writeIntLittle(u32, packet[0..4], 8); // Size
    std.mem.writeIntLittle(u32, packet[4..8], 1); // ID
    std.mem.writeIntLittle(u32, packet[8..12], 3); // Type (SERVERDATA_AUTH)

    std.debug.print("RCON packet: ", .{});
    for (packet) |byte| {
        std.debug.print("{x:0>2} ", .{byte});
    }
    std.debug.print("\n", .{});
}
sharp geyser
#

Not sure about that for loop at the bottom.

#

That is zig specific syntax

proven lantern
#

zig doesn't do anything tricky. it's all simple stuff

sharp geyser
#

No idea what .{] or .{byte} is

#

x:0>2 is also a bit weird

#

I assume thats like pythons x[0..2]

proven lantern
#

no, it's different

#

it's like sprintf

sharp geyser
#

Either way x is undefined

sharp geyser
proven lantern
#

sprintf (buffer, "%d plus %d is %d", a, b, a+b)

sharp geyser
#

interesting

#

such a weird and annoying way to do that

proven lantern
frosty gale
#

zig users trying to be unique for absolutely no reason

proven lantern
proven lantern
#

it is copying C there

#

that's not unique

proven lantern
proven lantern
radiant kraken
#

the whole "hidden control flow" thing doesnt even get me interested

#

that's literally just C

proven lantern
#

it is literally just figuratively C

radiant kraken
#

Bun uses zig just to look different KEKW

proven lantern
#

isn't zig kinda a bad idea for a JS runtime? don't you actually need saftey for that?

#

i know zig is planning to have memory safety on par with rust someday, but that's not today

radiant kraken
#

well the v8 runtime is in C++ so

proven lantern
#

well it's a step in the right direction

#

zig having 3 release modes is a good idea though. safe/fast/small

scenic kelp
#

i also don't really think runtimes are very safe in the first place when you're writting JITters

#

you're literally just injecting assembly code to be run

frosty gale
#

thats not quite how it works

#

the bytecode doesnt get converted to assembly/machine code, it just gets interpreted by some low level program written in c/c++/rust/whatever that does something depending on that bytecode instruciton

#

kinda something like:

if (line.instruction.op === "ADD_NUMBER_TO_VARIABLE") {
  variable += line.parameter;
}
#

unless you have a memory corruption bug its impossible to run arbitrary binary code in a JIT engine from a flaw in the bytecode

#

nevermind, apparently there is actual compilation involved in most JIT runtimes

#

im not sure how it works but id imagine it would be a sequence of predefined instructions for the most part so it would still be very difficult to execute any arbitrary binary code using that

sage bobcat
radiant kraken
#

because no hidden control flow!!!! ๐Ÿ’ช

#

zig fans when operator overloading ๐Ÿคฎ

sage bobcat
#

One message removed from a suspended account.

radiant kraken
#

so real

proven lantern
scenic kelp
scenic kelp
quartz kindle
#

JSC is c++ like V8

quartz kindle
sharp geyser
#

icic

#

ty

quartz kindle
#

tcp is basically just writing bytes

#

create tcp, connect to some ip address, once connection is open, use some write function to write bytes

proven lantern
quartz kindle
#

8v is like chrome, JSC is like safari

#

(quite literally, chrome uses v8, safari uses jsc)

spark frost
#

how can i obfuscate my website so noone can see the code from its elements ???

proven lantern
spark frost
#

if i use elements from dev tool it shows all the correct codes

#

is there any way to obfuscate them ?

proven lantern
proven lantern
quartz kindle
#

node is a wrapper around V8

quartz kindle
spark frost
# proven lantern can you give a fake example of a code you want to obfuscate?
<form action="action_page.php" method="post">
  <div class="imgcontainer">
    <img src="img_avatar2.png" alt="Avatar" class="avatar">
  </div>

  <div class="container">
    <label for="uname"><b>Username</b></label>
    <input type="text" placeholder="Enter Username" name="uname" required>

    <label for="psw"><b>Password</b></label>
    <input type="password" placeholder="Enter Password" name="psw" required>

    <button type="submit">Login</button>
    <label>
      <input type="checkbox" checked="checked" name="remember"> Remember me
    </label>
  </div>

  <div class="container" style="background-color:#f1f1f1">
    <button type="button" class="cancelbtn">Cancel</button>
    <span class="psw">Forgot <a href="#">password?</a></span>
  </div>
</form>
quartz kindle
#

at most you can use front-end frameworks, they usually have a very different source code from what the resulting code looks like

spark frost
quartz kindle
#

but you can also google some "html obfuscator" and try using that lol

spark frost
#

oh ok

#

thanks for info

quartz kindle
#

none of that is very good at preventing people from reading the page tho, anyone with enough time and dedication can find ways to de-obfuscate

spark frost
quartz kindle
#

thats why you should never put important things like api keys and passwords on the front end

#

because its impossible to protect

spark frost
quartz kindle
#

you cannot hide network requests, they always show up in the dev tools network tab

#

even if the code is obfuscated, once the request executes, it will show up in the network tab

spark frost
#

ohh

spark frost
quartz kindle
#

you need to add SSL to your application

#

there are many ways to get free SSL, for example using letsencrypt or acme.sh

#

there is also cloudflare

spark frost
quartz kindle
#

yes

#

you do need a domain tho

spark frost
#

ok ill buy one or can we get domain for free ??

quartz kindle
#

some are free

#

you can also get free subdomains

spark frost
#

how ?

quartz kindle
#

or you can create a subdomain on the website you already have

pearl trail
#

free domains!!;??!??!?!??

frosty gale
#

people abuse them though which is why they don't tend to last

#

one bad website can get the entire domain flagged

#

the domain owner is also on the hook with the registrar and ICANN

soft laurel
#

Are the new SKUs for bot monetization the same as Entitlements?

dense quarry
#

how do I get a discord bot token

soft laurel
proven lantern
soft laurel
#

Thanks! I see that now.

proven lantern
soft laurel
# dense quarry how do I get a discord bot token

On the discord developer portal you create an application. It'll be under the Bot tab. Be sure to save it somewhere as you won't be able to see it without refreshing it. You should be shown it during or imediately after Bot creation.

soft laurel
soft laurel
#

lol sorry, lots of things. I'm also having trouble creating a test SKU. What scope on the Oauth token do I need? I keep getting a 401 unauthorized with body

{
    "sku_id": "my id",
    "owner_id": "my guild",
    "owner_type": 1 // guild subscription (1) user subscription (2)
}

with url https://discord.com/api/v10/applications/< bot-id >/entitlements
with scopes applications.store.update applications.builds.read applications.entitlements applications.commands.update

proven lantern
soft laurel
#

Even the test skus? Does the entitlements not create the test skus?

#

I'll give it a try

#

bit confusing on discords end

proven lantern
#

create-test-entitlement does not create a sku

soft laurel
#

If I created the SKU in the development portal is that not the same thing?

#

Like I have a store and everything

#

The create test entitlement takes a guild subscription or user subscription owner_type which isn't a consumable? Question mark?

i'm not fighting you, just making sure I understand the terminology

#

Maybe I should clarify and say that I'm creating a test entitlement to test my implementation of checking skus in my bot.

proven lantern
soft laurel
#

That's the issue i'm having is a 401 on the test entitlement endpoint

#

was wondering if I was missing a scope in my token request

proven lantern
soft laurel
#

I'm sending a bearer token, does it have to be the Bot API Token?

proven lantern
soft laurel
#

I used the client_secret and client_id of the bot to generate the token. Maybe that wasn't doing what I thought it was

#

worked like a charm. Had to use the Bot < bot token >

proven lantern
soft laurel
#

ty ty

proven lantern
#

nice

crystal wigeon
#

ok so

#

anyone there

#

what is the best resolution i should use for a canvas to send on discord as an image?

#

for example:

#

im using 708x550. but the icons are not legible at all

pearl trail
#

more like the color

#

bright bg + bright icon = THPepeEyes

crystal wigeon
#

even if i use dark bg.

#

the badges are too small i feel

#

no?

#

the text on it is not visible. i tried to like zoom in and all

#

i need a bigger reso

lament rock
#

@crystal wigeon Your problem is contrast. The icons themselves are very low contrast and your choice of colors isnt the best against the background. You can create a higher contrast while retaining both the background color and the icon colors by having a container for the icons.

Inside the icons, I can see what is supposed to be identifying features for what the icon is, but unless I zoom in, I can't make it out and it isn't a resolution issue as on the client, the images are covered to a container size. The only benefit would be from super sampling at the detriment of lower connection speed download rates and higher transmission size and memory footprint while compositing and sending the image

crystal wigeon
#

the container bg

#

lemme try it out

crystal wigeon
#

how do i make them high contrast

#

in figma

#

the icon color itself needs to be high contrast right? nothing to do with icon resolution?

#

i was thinking of increasing the icon reso from 24px to like 32

#

the icons are better visible now hmmm. or is it not?

lament rock
#

Colors. Black and white is the highest contrast possible and white text on a black background is the most legible. You need to look into what colors contrast nicely with what colors you already have and deem to be non negotiable like if you have brand colors you arent gonna change those

#

Slightly, but that can be an issue of exposure/glare on the light theme

crystal wigeon
#

so like i want to allow the user to change the background.

#

right

#

if i added a color on the container would that help?

lament rock
#

you cannot control user content contrast

crystal wigeon
#

gotcha

#

now i just need to make the icons itself more light

lament rock
#

I have two profile styles. You can have some control over user background contrasts but it's limited

#

Still need a container just with a semi transparent background

crystal wigeon
#

gotcha

#

thanks

crystal wigeon
lament rock
#

My method only requires me to build the profile background once and then just add the next frame on top of the previous one. If you need transparency, you need to dispose of the previous frame after adding it to the encoder and rebuild it

#

nvm I rebuild the whole frame anyways

#

:3

crystal wigeon
#

pro

lament rock
#

You should probably make use of a worker_threads thread pool since this will exhaust the thread even though it's async

pine willow
#

Good Ping?

earnest phoenix
#

rly bad

fallow gale
#

terrible

rustic nova
#

Me when pinging myself

warm surge
#

Shitty

sharp geyser
#

@rustic nova

rustic nova
#

@sharp geyser

#

What's your response time

#

Timed out: 5000ms

sharp geyser
#

2ms

rustic nova
#

Lie

bitter granite
pine willow
#

Thats true

warm surge
#

๐Ÿ‘€

rustic nova
#

Guessing someone just did rubber duck debugging here

warm surge
#

Bru

surreal sage
#

does this code look broken

warm surge
surreal sage
#

whar

warm surge
surreal sage
#
  if (message.attachments.size > 0)
    for (const attachment of message.attachments.values())
      if (
        attachment.contentType &&
        !attachment.contentType.startsWith("image/") &&
        !attachment.contentType.startsWith("video/")
      )
        return message.delete();```
spark flint
#

whats the problem with it

#

it looks fine

surreal sage
#

i don't know

#

for some reason it doesnt work

spark flint
#

try doing console.log(attachment) before the if

#

see if its definitely returning the right thing

surreal sage
#

wait

#

oops

#

okay

#

it wasnt broken

#

i was testing with a psd

spark flint
#

ah

surreal sage
#

not knowing its mimetype starts with image/vnd

warm surge
#
  if (message.attachments.size > 0) {
    for (const attachment of message.attachments.values()) {
      if (
        attachment.contentType &&
        !attachment.contentType.startsWith("image/") &&
        !attachment.contentType.startsWith("video/")
      )
        return message.delete(); 
}
} ```
spark flint
#

webster that looks worse

surreal sage
#

brackets are optional in javascript

spark flint
#

you also dont need { for the if

warm surge
#

Ahh

#

Im on my phone

surreal sage
spark flint
#

if in doubt, js if (message.attachments.size && !message.attachments.every(a => a.contentType.startsWith("image/") || a.contentType.startsWith("video/"))) message.delete();

surreal sage
spark flint
#

i mean

#

thats readable

#

it does the same job, if not faster

#

tested

#
const attachments = [
  {
    name: "image.png",
    contentType: "image/png",
    size: 1024
    // whatever
  },
  {
    name: "video.mp4",
    contentType: "video/mp4",
    size: 2048
    // whatever
  },
  {
    name: "file.exe",
    contentType: "application/exe",
    size: 1024
    // whatever
  },
  {
    name: "blahaj.shark",
    contentType: "shark/chomp",
    size: 1234
    // whatever
  },
  {
    name: "fish.png",
    contentType: "image/png",
    size: 1024
    // whatever
  }
];

// test performance
console.log("testing original version");
console.time("original version");
for (const attachment of attachments) {
  if (
    attachment.contentType &&
    !attachment.contentType.startsWith("image/") &&
    !attachment.contentType.startsWith("video/")
  )
    console.log("some attachments are not images or videos");
}
console.timeEnd("original version");

// test performance
console.log("testing short version");
console.time("short version");
if (attachments.some(a => !a.contentType.startsWith("image/") && !a.contentType.startsWith("video/"))) {
  console.log("some attachments are not images or videos");
}
console.timeEnd("short version");```
quartz kindle
#

the first one will keep looping even after it found one

#

should have a break in there

quartz kindle
#

figured out a hack to detect webrtc audio activity lmao

#
/** @type {Map<string, RTCRtpReceiver>} */
const ___receivers = new Map();

const ___peer = Object.getOwnPropertyDescriptor(window, "RTCPeerConnection");
Object.defineProperty(window, "RTCPeerConnection", {
    value: function() {
        const p = new ___peer.value(arguments);
        p.addEventListener("track", trackEvent => {
            if(trackEvent.track.kind === "audio" && ["6666", "6667", "6668"].includes(trackEvent.streams[0].id)) {
                ___receivers.set(trackEvent.streams[0].id, trackEvent.transceiver.receiver);
            }
        })
        return p;
    }
});

setInterval(() => {
    for(const receiver of ___receivers.values()) {
        const contributors = receiver.getContributingSources();
        const active = contributors.filter(x => x.source > 100 && x.audioLevel > 0.001);
        for(const source of active) {
            document.dispatchEvent(new CustomEvent('@_@', { detail: { type: "audio", data: source.source } }))
        }
    }
}, 200);
#

google meet works in very weird ways, instead of having a dedicated audiotrack for each participant, like they do with videotracks, they have 3 fixed audio streams, each handling a certain number of participants

#

and i found out that the audio activity of each participant is temporarily held on the receiver and accessible via getContributingSources()

#

RTCRtpReceiver.getContributingSources()
Returns an array that contains an object for each unique CSRC (contributing source) identifier received by the current RTCRtpReceiver in the last ten seconds.

timber hatch
#

does anyone know a responsible way to stop people absolutely ruining my life with bandwidth? creating a UGC web app which allows user to input custom html to be displayed on their page. But obviously don't want them to abuse it, make their page extremely large, then get thousands of visitors to it

quartz kindle
frosty gale
quartz kindle
#

but pretty sure its faster than using mutationObserver on the html

#

and listening to html changes

#

running receiver.getContributingSources(); 100k times took ~150ms

#

so its not that slow, should be no problem running it 5x per second

#

but it does scale with how many people are in the call

vivid fulcrum
quartz kindle
#

there already is a dedicated stream for each peer, but it only has a video track, not an audio track

vivid fulcrum
frosty gale
quartz kindle
#

yes thats me on cam

frosty gale
vivid fulcrum
quartz kindle
spark flint
#

so it just caches their page

frosty gale
#

bun try not to suggest a proprietary service challenge (hard)

sharp geyser
#

CF is good

neon leaf
#

cf is good

frosty gale
#

@quartz kindle when creating a write stream in node to a file does it flush the data immediately on write?

#

or does it write to a buffer first then flushes once theres enough data written or its closed?

#

ideally id want it to flush only after some inactivity on the write stream just so i save some write cycles on the disk

quartz kindle
#

if you want to pause it for a bit, you can cork then uncork

#
function createInactivityWriteStream(file) {
  const stream = fs.createWriteStream(file);
  let timeout;
  const writer = stream.write;
  stream.write = function(data) {
    if(!stream.corked) {
      stream.cork();
    }
    writer(data);
    clearTimeout(timeout);
    timeout = setTimeout(() => {
      stream.uncork();
    }, 1000)
  }
  return stream;
}
``` no idea if this works xD
frosty gale
#

do you know what the size of the internal buffer is?

#

id also want it to flush if enough data is written but not sure if node will do that anyways

quartz kindle
quartz kindle
sharp geyser
#

@rustic nova have you ever gotten an net::ERR_CERT_AUTHORITY_INVALID when visiting your mailcow dashboard?

#

Its saying my certs are invalid but thats def not true

#

I haven't touched them at all skuLul

frosty gale