#development

1 messages ยท Page 239 of 1

quartz kindle
#

does the column id exist?

neon leaf
#

yes

quartz kindle
#

so```sql
ON CONFLICT (location) DO UPDATE SET location=location
RETURNING id

neon leaf
#
{
  result: [],
  success: false,
  errors: [
    {
      code: 7500,
      message: 'ON CONFLICT clause does not match any PRIMARY KEY or UNIQUE constraint'
    }
  ],
  messages: []
}```
#

o wait

#

config_id is part of the unique index

#

very nice

#

works

#

thanks guys

green kestrel
#

whats the number 10 do, and what is function t?

#

i recommend making it a bit less magic-number'y and easier to read ๐Ÿ˜„

neon leaf
#

time(10).m()

#

10 minutes in ms

green kestrel
#

what if you wanted to change that value, do you use it in other places too?

neon leaf
#

?

neon leaf
#

beautiful

quartz kindle
neon leaf
#

as long as its fast its acceptable

quartz kindle
#

ima be honest, these functions were made with help from chatgpt

radiant kraken
#

what do you use them for

quartz kindle
#

games n stuff

#

jk

radiant kraken
#

u made ur own game engine?

#

damn

neon leaf
#

astronomy right?

quartz kindle
#

the second pic is for converting ecliptic coordinates into cartesian

radiant kraken
#

interesting

quartz kindle
#

ie longitude+latitude+distance -> xyz

radiant kraken
#

whats ur game again

quartz kindle
#

its not a game, that was jk

#

its astro stuff

radiant kraken
#

yeah ik

neon leaf
#

smol db

quartz kindle
neon leaf
#

yes

quartz kindle
#

thats already 1/5th

#

hue

neon leaf
#

well I use workers paid anyway

quartz kindle
#

ah

neon leaf
#

because I am reading wayy too many rows

#

I need the 25bil

quartz kindle
#

wait

#

when you do a query they count scanned rows as rows read?

neon leaf
#

yes

quartz kindle
#

wtf

#

thats bulshit

neon leaf
#

thats why you index everything to infinity

#

this only reads 1400 rows

#

with 120k builds

quartz kindle
#

ngl thats pretty garbage from D1 then

neon leaf
#

still way cheaper than serverless pg/mysql

quartz kindle
#

i guess

#

i still prefer local tho

neon leaf
#

ye

#

this needs to be in the cloud though

#

way too many people rely on this api

#

and hosts

quartz kindle
#

with all the hype around edge, from what ui've seen its pretty lackluster

lyric mountain
#

if you were using pg instead of sqlite you could code almost everything within the db tbh

neon leaf
#

ye however all serverless pg i found is 20โ‚ฌ/month/location

lyric mountain
#

then return everything processed to the api

neon leaf
#

like wtf

quartz kindle
#

get 20 cheap vps's around the world

#

and do the replicastion yourself

#

:^)

neon leaf
#

I mean yes thats what im currently doing

#

however I cant find good providers everywhere

#

(and providers that have good cf routing)

lyric mountain
#

pg has that built in

neon leaf
#

ye i am using built in master-slave replication

lyric mountain
#

manager-paid_worker mmLol

neon leaf
#

mmmm

#

ohno

runic flame
#

Opinions on the experimental node:sqlite module in Node.js?

surreal sage
frosty gale
#

better-sqlite3 is cooked

#

yeah they literally copied its syntax for the most part

#

dont blame them because its good

runic flame
#

It's good yeah

radiant kraken
sharp geyser
#

native node sqlite module

#

interesting

green kestrel
lyric mountain
#

calculating lagrange 2

#

tim doing tim stuff

quartz kindle
quartz kindle
#

i mean, are they actually basing it off of better-sqlite3?

#

if so, thats pretty pog

green kestrel
lyric mountain
#

it's planet science smh my head

real rose
#

planet science is crazy

green kestrel
#

thats what i said

#

i said its not rocket science

runic flame
#

The design seems very similar to that of better-sqlite3

quartz kindle
#

there were talks of having both a sync and an async api for sqlite

#

and the author of better-sqlite3 recommeded them to expose the raw sqlite C api

#

but there are still a lot of issues for them to solve, like sqlite's compilation flags and extensions

#

so it seems they are going to try doing their own thing

runic flame
#

I guess, this comment https://github.com/nodejs/node/pull/53752#issuecomment-2228852505 also seems enticing

From a quick test, compiling SQLite in Node with the same settings used by better-sqlite3 yielded roughly the same performance. There may be other things to optimize as well, but it's good to know we aren't doing anything too awful ๐Ÿ˜„.

quartz kindle
#

ye i guess the author of the initial implementation did follow better-sqlite's footsteps

#

but lets see where it goes from here

runic flame
#

It'll probably get optimized a lot

quartz kindle
#

the problem is, node's getting more bloated every year KEKW

#

time for a new runtime :^)

runic flame
#

Follow your father's footsteps, C++

quartz kindle
#

just-js had a lot of potetial, i wonder which direction that will take

runic flame
#

What is that?

quartz kindle
#

they moved to a new project called lo

quartz kindle
sharp geyser
#

tim

#

just

#

optimize node yourself

#

๐Ÿ™„

quartz kindle
#

ew

sharp geyser
#

nodejs-light when?

quartz kindle
# runic flame What is that?

when the author launched just-js, he did make a barebones webserver and added it to those big ass web framework benchmark competitions

#

it was the only js thing in the top 10

runic flame
sharp geyser
#

what about express

#

v8 is the js engine

quartz kindle
quartz kindle
#

just is like a barebones wrapper around it

#

like node but without the entire node api

runic flame
#

Oh so it's a runtime, not a separate engine

#

I wonder why it's Linux-only

sharp geyser
#

thats what they decided to build it for

runic flame
#

Considering V8 supports all platforms they could probably add support for all platforms

quartz kindle
#

yeah, it heaviliy interacts with linux syscalls

sharp geyser
#

they could

#

but then they'd have to build different versions

runic flame
quartz kindle
lyric mountain
#

besides 99% of use-cases will be linux anyway

runic flame
#

Or at least Linux distributions, macOS, and Windows

quartz kindle
#

but its still in very early stages

#

after the bun hype, its time to hype a new thing

#

:^)

runic flame
#

Coming soon to a browser near you in 2089

quartz kindle
#

indeed

runic flame
neon leaf
#

bun is still so broken.

#

the http lib polyfill literally leaks memory

#

they still havent fixed it properly

runic flame
#

Did they fix the runtime running into a segfault every 2 seconds?

neon leaf
#

no

runic flame
#

Amazing

neon leaf
#

still segfaults constantly

runic flame
#

People really be hyping broken new stuff up like crazy

#

Reminds me of the VSCode killer stuff

sharp geyser
#

Zed?

lyric mountain
#

mid diff no mia ff 15

quartz kindle
#

x9 jg

neon leaf
#

btw cloudflare d1 is suprisingly fast

#

I never expected serverless sqlite to be that fast

lyric mountain
#

I mean, it's cloudflare

#

plus sqlite is made for speed

neon leaf
#

I mean

sharp geyser
#

sqlite is slow

neon leaf
#

I didnt expect it to search a 800k row table thats 800mb in postgres within 100ms

#

UNINDEXED

lyric mountain
#

sqlite is far from slow, it's just that it cant benefit from threads for write

lyric mountain
#

aka rowid

neon leaf
#

well i wasnt searching by that tho

#

it had to scan every row

lyric mountain
#

it implicitly uses it

#

unless you declare a column as INTEGER AUTOINCREMENT PRIMARY KEY

#

in which case it overrides rowid

neon leaf
#

yknow whats weird

#

d1 just denies your request if it contains a ;

#

since it does not support multiple params

#

is it normal that this reads 2180 rows every time

 DEB  18.07.2024, 20:09:38 Database Query
 
SELECT id, project_version_id, rehash
FROM builds
WHERE type = "SPONGE" AND version_id LIKE 1.11.2%
 
(rows read 2180, rows written 0)
 INF  18.07.2024, 20:09:38 Found 90 builds for version 1.11.2 (SPONGE)
 DEB  18.07.2024, 20:09:39 Database Query
 
SELECT id, project_version_id, rehash
FROM builds
WHERE type = "SPONGE" AND version_id LIKE 1.12%
 
(rows read 2180, rows written 0)```
#

its the total number of sponge builds

neon leaf
#

I am sleep deprived

#

please summarize

sharp geyser
#

D1 sounds expensive

neon leaf
quartz kindle
neon leaf
#

wtf

#

how does that make sense

quartz kindle
#

This constraint arises from the fact that numbers do not sort in lexicographical order. For example: 9<10 but '9'>'10'.

neon leaf
#

...

#

so im gonna have to suck it up?

quartz kindle
#

there is also the issue of case sensitivity, even if not applicable in this case

#

LIKE is case-insensitive by default. To have it use your index, you need to either make the index case-insensitive:

CREATE INDEX test_name ON test (name COLLATE NOCASE);

or make LIKE case-sensitive:

PRAGMA case_sensitive_like = 1;

quartz kindle
neon leaf
#

its a placeholder

quartz kindle
#

ah

neon leaf
#

my logger replaces it for readability

quartz kindle
#

you can also try this workaround

#

WHERE word >= 'search_string' AND word < 'search_strinh'

neon leaf
#

wtf

quartz kindle
#

in your case

#

WHERE version_id >= '1.11.2' AND version_id < '1.11.3'

neon leaf
#

would WHERE version_id >= '1.11.2' AND version_id < '1.11.9' work too

quartz kindle
neon leaf
#

okay ill try

#

it should also work if the first is 1.11 right

lyric mountain
#

or at least drivers dont

quartz kindle
neon leaf
#

oh wow it works perfectly

quartz kindle
#

so "aaa" is smaller than "aab", and any more characters that are appended to that will always be bigger than "aaa" and smaller than "aab"

neon leaf
#
 
SELECT id, project_version_id, rehash
FROM builds
WHERE type = "SPONGE" AND version_id >= 1.11.2 AND version_id < 1.11.2.9
 
(rows read 91, rows written 0)
 INF  18.07.2024, 20:34:14 Found 90 builds for version 1.11.2 (SPONGE)
 DEB  18.07.2024, 20:34:15 Database Query
 
SELECT id, project_version_id, rehash
FROM builds
WHERE type = "SPONGE" AND version_id >= 1.12 AND version_id < 1.12.9
 
(rows read 499, rows written 0)
 INF  18.07.2024, 20:34:15 Found 498 builds for version 1.12 (SPONGE)```
lyric mountain
#

btw, if u want to match a pattern in LIKE but dont want to allow 2+ characters u can use _

#

like 1.__.3 would match any version that has major version 1 and build 3, and 2 digits for minor version

#

tho it requires the number of chars to be exact

quartz kindle
neon leaf
#

but its only normal semver in this case

quartz kindle
#

then do 1.12 to 1.13

#

although there is a caveat

#

it will not work with 1.9 and 1.10 for example

#

because 1.9 is bigger than 1.10

#

the characters 1.9 are bigger than the characters 1.1 in lexicographiical order

eternal osprey
#
    let endTime = new Date().getTime() + duration * 60 * 60 * 1000;
    let endString = `<t:${endTime}:F>`;```
why does this show me something utterly crazy
#

november 19th, 523523 or something tf

neon leaf
#

discorrd uses seconds

surreal sage
#

ya

neon leaf
#

js dates use ms

eternal osprey
#

bomboclat

quartz kindle
#

discord is dumb

eternal osprey
#

tyy

surreal sage
#

discord doesnt care about ms!!!

lyric mountain
#

then cast it to float

#

oh wait nvm, 9 is still bigger than 10

eternal osprey
#

huh tf

#
    let endTime = new Date().getTime() + duration * 60 * 60;
    let endString = `<t:${endTime}:F>`;```
pretty sure it's seconds rn
lyric mountain
#

well, u can substring from the first period till the second

#

and cast to int

eternal osprey
#

omg

lyric mountain
#

it's not like mojang will ever release minecraft 2

eternal osprey
#

yooo chat forget what i just did

#

๐Ÿ—ฃ๏ธ

neon leaf
lyric mountain
#

nobody plays on alphas

neon leaf
#

well ye sponge only has full semvers

#

no snapshots or alphas

lyric mountain
#

but well, u can WHERE substring(version_id, 0, 1) > 0

quartz kindle
#

to deal with 1.9 - 1.10 you will need to do 1.9 - 1.: to match everything 1.9.x

lyric mountain
#

also mojang doesn't honor semver

#

they use it but it doesn't work in the same way at all

neon leaf
#

nvm there are snapshots

sharp geyser
#

suspicious link

#

no click

lyric mountain
#

you can use regex too mmLol

#

\d\.12\.\d+

neon leaf
#

or i stick with tims solutions because I think thats enough

#

this only runs every hour

#

no need to optimize row reads to infinity

lyric mountain
#

inb4 query takes 1h and 1 minute to complete so they overlap and crash the server

neon leaf
#

have protection against that

#

sometimes the cron took 2 weeks

#

so had to do that lol

lyric mountain
#

the what

neon leaf
#

yes

#

it takes quite a bit starting a server on each mc version of each software of each build ever

quartz kindle
#

or just abuse the lexicographic order:
WHERE (a >= '1.9' AND a < '1.:') OR (a >= '1.10' AND a < '1.12')
= match everything from 1.9 until 1.12

neon leaf
#

or I do select * from builds

quartz kindle
#

:^)

eternal osprey
#

wait how do i create an actual timer in djs?

lyric mountain
#

setTimeout()

eternal osprey
#

Like one of the formatting did that but i forgot it's format

neon leaf
#

setTimeou = setTimeout

lyric mountain
#

or do u want the discord "in X seconds"?

eternal osprey
eternal osprey
#

arigato ox7d8 kun

sharp geyser
#

what the fuck

quartz kindle
#

oeksusevandeeito-kun

neon leaf
#

first 4 rewritten ๐Ÿ”ฅ

lyric mountain
#

you're hereby nicknamed "lime"

quartz kindle
#

raimu-desu!

lyric mountain
#

sasuga timu-sama

quartz kindle
lyric mountain
#

lmao loved that part

quartz kindle
#

just watched it yesterday xDD

neon leaf
#

waiting for the day pnpm adds an option to automatically add the @types/ package when the package ur installing does not include ts types and you use ts

sharp geyser
#

Hey haku

#

I found java in anime

quartz kindle
sharp geyser
#

probably hired a programmer just for this scene

#

as its the only scene that shows code

quartz kindle
#

getKurata new Rectangle

sharp geyser
neon leaf
#
SELECT jar_url, jar_size, version_id, config_id, config_value_id
FROM builds
INNER JOIN buildConfigs ON builds.id = buildConfigs.build_id
WHERE type = "VANILLA"
LIMIT 1
#

what happens when buildConfigs has no match

#

is config_id null?

lyric mountain
#

tho it might be some other framework too, idk what Kurata is

sharp geyser
#

its probably part of the game that the code was about

#

How do you know its swing tho

lyric mountain
#

Region

#

he's dealing with either swing or java2d in general

#

tho getInstanceKurata might mean that's a class from his game

quartz kindle
#

is Kurata a relevant thing in the anime? is it a character?

sharp geyser
#

Its not relavent at all tbh

#

The only thing relevent is his programming background

#

He literally dies 3m later in the anime

#

๐Ÿ’€

#

His programming background makes it easy to pick up the magic in the world he is transported to though

lyric mountain
#

is that death march?

#

yeah no, that's definitely swing

#

region might not be, but the rest is without doubt

#

actually, not swing, AWT

sharp geyser
lyric mountain
#

ah the one with mechas

sharp geyser
#

Yup

#

Pretty lit stuff

#

I watched it ages ago back in 2018

#

rewatching it

neon leaf
#

oh no

#

I need to write a somewhat complex query again

sharp geyser
#

or

#

just dont

#

:)

neon leaf
#

no

sharp geyser
#

yes

#

you can make it simpler

#

by breaking it up

neon leaf
#

not when I have 1s db latency

sharp geyser
#

1s is too much

neon leaf
#

ok somehow I got it working first try

sharp geyser
#

nice

neon leaf
frosty gale
#

2-3 business days per query

neon leaf
#

yea

solemn quest
#

hey, maybe a dumb question? but if I want to add/change some code to my bot that's already on top.gg, and restart it -- will current/future users see these new changes?

#

on discord

lyric mountain
#

yes, the bot is just listed on topgg, it doesn't "clone" your bot

#

all processing is done on your side

surreal sage
sharp geyser
#

Looks like you fucked up

surreal sage
#

idk how

#

@sharp geyser

#

dockerfile

#

FROM xxx as xxx

#

or

#

FROM xxx AS xxx

#

yea capitalized

#

sorgy for ping

sharp geyser
#

anything dockerfile the keynames will always be capitalized

surreal sage
#

it worked before

#

so im confused why this is happening

#

i didnt change anything and now it's ๐Ÿ˜•

#

okay... downgrade to 21 worked

quartz kindle
surreal sage
sharp geyser
#

Ofc not

#

thats for the people who use node to do

surreal sage
#

push now fix later

sharp geyser
#

which is why its called beta

#

๐Ÿ’€

#

Its not ready for use

surreal sage
#

22.5.0 is stable branch i think

quartz kindle
#

its not LTS yet

surreal sage
#

ya

quartz kindle
#

it will be in a couple months or so

surreal sage
#

but still Please_Begging

sharp geyser
#

Once its LTS you know its stable enough

#

Anything not marked as LTS is usually still in the works

#

Meaning bugs are expected

#

You can't expect them to have EVERYTHING working

#

Nodejs is a vast ecosystem

#

Granted even LTS still has bugs, but they are mainly flukes that are happenstance

quartz kindle
sharp geyser
#

Right

quartz kindle
#

smh bad devs failing at their job

#

:^)

sharp geyser
#

As if a big ass runtime that adds new features every major update is going to be stable right out the box

#

๐Ÿ˜

#

Most of those new features require other things being reworked

#

Which just so happens to cause bugs

#

ngl tim

#

make your own runtime

#

you have the knowledge

quartz kindle
#

says who

sharp geyser
#

says your conversations in this dev channel for the past 4-5 years

#

Okay 6 years

quartz kindle
#

its all superficial knowledge

sharp geyser
#

Buddy

surreal sage
#

does your <@&1016059109130375168> role blacklist you from all channels but #development? xd

sharp geyser
#

Your knowledge is immense

quartz kindle
#

my only deep knowlege is how to sleep and eat

sharp geyser
#

nah

#

cap

quartz kindle
#

:^)

sharp geyser
#

Wait

#

Did they actually lock you to development only

#

We been joking about it for years

quartz kindle
#

nah xd

sharp geyser
#

it finally happened

#

Im honestly tempted to work on my website a bit

#

but I dont have the patience

quartz kindle
#

i figured out what im gonna do to make this exercise that cant be easily solved by chatgpt

sharp geyser
#

I want to try and make my portfolio again

#

but do I have the patience to sit there and do it

#

when I can watch anime instead

quartz kindle
#

gonna make it use mapbox api v6, which is new, and chatgpt doesnt know about it, it only knows about v5

surreal sage
sharp geyser
#

I hate twitter rn

#

I cant go on there without seeing some shit about donald trump getting shot

frosty gale
#

has access to internet

#

so it can pull documentation

#

but it struggles with complex enough questions

#

it starts to outright make up parameters

#

("hallucinations" is the buzzword for this)

quartz kindle
#

so i wont

#

:^)

lament rock
#

check bing ai

#

its actually pretty damn good

solemn latch
#

Nah, run your own ai.
Custom RAG, so you can just make it check the top 10 results on Google instead of the first 2 or 3 ^-^

But yeah, bing does great with it.

surreal sage
#

what src/xxx folder should I use for classes

pearl trail
#

src/classes Troll

neon leaf
#

/tmp/src/classes

spark flint
#

/dev/null

green kestrel
surreal sage
#

runners didnt bother ๐Ÿ’”

quartz kindle
surreal sage
quartz kindle
#

:^)

solemn latch
#

How would I de-bounce re-rendering a component?
I have a form with a field with an image URL which I'm displaying in a child component.
My main issue is that the image URL is fetched EVERY time a character is typed, so someone typing a URL would send a request every time a character is typed.

"use client";
import { ChangeEvent, useState } from "react";
import DisplayFormData from "./someRenderedComp";

export default function Home() {
  const [formData, setFormData] = useState({
    description: "",
    image: "",
  });

  const handleDescriptionChange = (e: ChangeEvent<HTMLInputElement>) =>
    setFormData((prevState) => ({ ...prevState, description: e.target.value }));

  const handleImageChange = (e: ChangeEvent<HTMLInputElement>) =>
    setFormData((prevState) => ({ ...prevState, image: e.target.value }));

  return (
    <main className="flex min-h-screen flex-col items-center p-24">
      <form className="flex flex-col">
        <label htmlFor="description">Description</label>
        <input
          name="description"
          value={formData.description}
          onChange={handleDescriptionChange}
          placeholder="some fancy description"
          className="text-black"
        />
        <label htmlFor="image">Image</label>
        <input
          name="image"
          value={formData.image}
          onChange={handleImageChange}
          placeholder="imageURL"
          className="text-black"
        />
      </form>
      {/* Dont re-render unless the user hasnt typed in the 'image' field for 500ms */}
      <DisplayFormData {...formData} />
    </main>
  );
}
"use client"; // in my real example this has to be a client component, here it doesnt.
import React from "react";

function DisplayFormData({ description, image }: { description: string; image: string }) {
  return (
    <div>
      <div>{description}</div>
      <img src={image} alt={"Cant load"} />
    </div>
  );
}

export default DisplayFormData;
#

React - nextjs ๐Ÿ‘€

#

(ignore the bad practices, I let AI write most of this becuase its just an example)

#

useDeferredValue seems okay, but it has limited control.
I wouldn't mind using it, but it doesn't appear to have any way to control it.

lyric mountain
#

only update inside the timeout

#

whenever they type, cancel current timeout and restart it

solemn latch
#

setTimeout would be a throttle.... never mind, yeah

#

Can I do that from within the child component?
I'm not exactly sure how re-rendering works.

#

Honestly, I'm just going to try just to learn.

#

Thanks

lyric mountain
#

simply make a timeout that calls it, instead of calling it directly

#

in your case setFormData

solemn latch
#

hmm, I'm doing something wrong.

  let timer: NodeJS.Timeout | undefined;
  const handleImageChange = (e: ChangeEvent<HTMLInputElement>) => {
    console.log("Image change: ", e.target.value);
    clearTimeout(timer);
    timer = setTimeout(() => {
      setFormData((prevState) => ({ ...prevState, image: e.target.value }));
    }, 500);
  };
#

It almost feels like I need a seperate hook to do this right

#

I just typed a, waited, then bc

#

Or a buffer for the input.

But then it would look awful, the input wouldnt show typed characters for 500ms

#

Something like this
But this wont work either,

const useDebounceInput = (ms: number, value: string): string => {
  let timer: NodeJS.Timeout | undefined;
  const [debouncedValue, setDebouncedValue] = useState(value);

  useEffect(() => {
    clearTimeout(timer);
    timer = setTimeout(() => {
      setDebouncedValue(value);
    }, ms);
  }, [value]);

  return debouncedValue;
}

But timer will be lost each re-render

neon leaf
#
#
import debounce from 'debounce';

const [value, setValue] = useState()
const debouncedSetValue = debounce(setValue, 500)```
solemn latch
#

I try to avoid libraries unless I understand how they work

#

Especially for relatively small things like this

neon leaf
#

this is actually quite complex in react

#

since there is no proper proper way to do this

solemn latch
#

React sometimes notlikenoot

solemn latch
neon leaf
#

this actually works fine

#

I use it myself

solemn latch
#

I'll try it ^-^

#

so: No inputs are received at all


export default function Home() {
  const [formData, setFormData] = useState({
    description: "",
    image: "",
  });

  const debouncedSetValue = debounce(setFormData, 500);

  const handleDescriptionChange = (e: ChangeEvent<HTMLInputElement>) =>
    debouncedSetValue((prevState) => ({ ...prevState, description: e.target.value }));

  const handleImageChange = (e: ChangeEvent<HTMLInputElement>) => {
    debouncedSetValue((prevState) => ({ ...prevState, image: e.target.value }));
  };

  return (
    <main className="flex min-h-screen flex-col items-center p-24">
      <form className="flex flex-col">
        <label htmlFor="description">Description</label>
        <input
          name="description"
          value={formData.description}
          onChange={handleDescriptionChange}
          placeholder="some fancy description"
          className="text-black"
        />
        <label htmlFor="image">Image</label>
        <input
          name="image"
          value={formData.image}
          onChange={handleImageChange}
          placeholder="imageURL"
          className="text-black"
        />
      </form>

      <DisplayFormData {...formData} />
    </main>
  );
}
#

I goofed around with it for awhile

neon leaf
#

I think you are understanding wrong

solemn latch
#

Always ๐Ÿ˜‰

neon leaf
#

you are debouncing the input field currently

#

so input will never arrive

lyric mountain
#

it's cuz when the timeout runs, it'll grab the stale value

#

make smth like let val = "", then update it normally

#

inside the debouncer, you get that variable's value

solemn latch
lyric mountain
#

yes

solemn latch
#

Yeah, okay I think I understand it.

It doesn't work great, but it works.

lyric mountain
#

in what way?

solemn latch
#

No matter what, this system inputs wont be shown in the field until 500ms after the user stops typing.

If I just use:

  let timer: NodeJS.Timeout | undefined;
  let value: string = "";
  const handleImageChange = (e: ChangeEvent<HTMLInputElement>) => {
    value = e.target.value;
    console.log(value);
    clearTimeout(timer);
    timer = setTimeout(() => {
      setFormData((prevState) => ({ ...prevState, image: value }));
    }, 500);
  };

It will only ever take the last character typed

If I wanted to fix that I'd probably need a second variable to track what was there before the debounce, and add only things after that to value.

Its just fiddling with the logic.

#

I think I understand enough to get to a working example, or at least struggle with it until I do ^-^

lyric mountain
#

it's annoying to get right, but aint too hard

surreal sage
#

not sure if it's your use case

solemn latch
#

In the end, I'll probably use https://www.npmjs.com/package/use-debounce

A hook just seems like the best way to do this.
But I'll look into usehooks-ts too

solemn latch
#

Playing around with my embed builder again ^-^

#

This is what was happening

quartz kindle
#

i would be able to help if it wasnt react

#

:^)

frosty gale
#

do you want to wait before sending a request while the user types?

solemn latch
#

If I was smart I would just make it a modal for images

#

I'm not sending a request, just updating the value inside an image element. Which auto sends a request when it updates.

frosty gale
#

same thing basically

solemn latch
#

Use debounce works fine, I still want to implement it myself in the end

#

But for now, I at least understand it enough to do so

neon leaf
#

export default function Home() {
  const [formData, setFormData] = useState({
    description: "",
    image: "",
  });

  const [image, setImage] = useState('')
  const debouncedSetImage = debounce(setImage, 500);

  const handleDescriptionChange = (e: ChangeEvent<HTMLInputElement>) =>
    setFormData((prevState) => ({ ...prevState, description: e.target.value }));

  const handleImageChange = (e: ChangeEvent<HTMLInputElement>) => {
    setFormData((prevState) => ({ ...prevState, image: e.target.value }));
    debouncedSetImage(e.target.value)
  };

  return (
    <main className="flex min-h-screen flex-col items-center p-24">
      <form className="flex flex-col">
        <label htmlFor="description">Description</label>
        <input
          name="description"
          value={formData.description}
          onChange={handleDescriptionChange}
          placeholder="some fancy description"
          className="text-black"
        />
        <label htmlFor="image">Image</label>
        <input
          name="image"
          value={formData.image}
          onChange={handleImageChange}
          placeholder="imageURL"
          className="text-black"
        />
      </form>

      {image /* use this for the actual image */}
      <DisplayFormData {...formData} />
    </main>
  );
}
frosty gale
#

youve tied the input to the formData state

solemn latch
#

That's a controlled input

frosty gale
#

so until that updates the text that you type wont reflect until that timeout runs which then sets the data using setFormData

solemn latch
#

I need it controlled

#

Yeah

neon leaf
#

you need a seperate state for the debounced value

frosty gale
#

i would do 2 different states in this case

#

yep

solemn latch
#

Isn't two states just causing multiple re-renders?

#

But a hook wouldn't? Idk do hooks cause re-renders?

frosty gale
#

first one will always keep up to date with the formData, the second will set the typed in text after the timeout, which is tied to the image src

neon leaf
frosty gale
#

tbf you could also do this with just one state

#

the formData state isnt strictly needed since you can detach it from that and just get the value from the onChange event anyways

#

faster as well

#

but if you want to do it the "react" way, sure

neon leaf
solemn latch
#

๐Ÿ‘€ my render is way slower than that right now.

Quite a lot is going on behind the scenes

neon leaf
#

I think thats something that you need to optimize then

#

every keypress will rerender

solemn latch
#

Which is part of the reason I am debouncing

#

I'm also using react-hooks-form for their isolated rendering

#

^-^

Trying to implement all of the custom elements Discord supports, and user facing variables.

As usual, this whole thing is too much work.

#

Auto complete almost killed me too.

sharp geyser
#

๐Ÿ‘€

frosty gale
#

tbf if youre using any framework youll get some performance loss anyways

#

if you dont want any you have to use vanilla js

#

but that doesnt matter too much you just need to make sure long or blocking code is async where possible

#

so it doesnt delay any painting or ui

surreal sage
#

i don't completely get why all the blame is being placed on crowdstrike

#

like okay they published a bad driver

#

but shouldn't there have been checks/automatic undo by Microsoft on clients?

sharp geyser
#

It had hype when it first launched

#

but svelte and react are still the most used along with vue

surreal sage
#

vue is just horrible to read

sharp geyser
#

vue is similar to svelte

neon leaf
#

vue is just horrible to read

sharp geyser
#
<script setup>
import { ref } from 'vue'

const count = ref(0)

function increment() {
  count.value++
}
</script>

<template>
  <button @click="increment">Count is: {{ count }}</button>
</template>
#

Doesnt look too bad

#

Similar to svelte in a way

digital swan
#

svelte >

frosty gale
#

apparently the svelte team isnt completely happy with the svelte 5 syntax either

#

they agree its very react-like

#

but they had many many other potential syntaxes proposed but none of them really worked out

#

i still think theyre taking away what made svelte svelte, with svelte 5 i might as well use vue.js honestly

digital swan
#

i dont like the $props thing about svelte 5

#

it seems more difficult

neon leaf
#

@quartz kindle worker deployment to production has been without issues so far, generally faster too

surreal sage
#

where the states at

frosty gale
#

value++ will cause anything using count to rerender

#

or well any mutation to it

sharp geyser
#

thats the point of ref yes

#

ref is similar to reacts useState

#

except it doesn't have a getter and a setter separately

#

its combined

frosty gale
#

what were they even thinking

#

did they think const [something, setSomething] = useState(); was a good ieda

eternal osprey
#

what's going on here?

#

are embeds not possible

surreal sage
#

[link](url)

#

not [link]('url')

#

@eternal osprey

surreal sage
#

refs are supposed to not rerender components on change

sharp geyser
#

Ask vue team

eternal osprey
#

arigatoo

sharp geyser
#

Refs do cause re-renders

surreal sage
sharp geyser
#

Which is why when using state management libraries you pass a ref

surreal sage
#

refs dont rerenderrr ๐Ÿ˜ญ๐Ÿ˜ญ

sharp geyser
#

So you can pass it down to all the children components and re-render as needed

#

Yes?

#

They literally do

surreal sage
sharp geyser
#

I've already tested this

surreal sage
#

then u did something wrong because they dont rerender

#

โค๏ธ

sharp geyser
#

Tell that to redux

#

You have to pass in the state as a ref

surreal sage
sharp geyser
#

else it wont re-render any of the changed values

#

Then dk what redux does

#

As you pass in a reference of the state when using it

surreal sage
#

weird stuff is what it does โค๏ธ

sharp geyser
#

redux makes heavy use of refs

proven lantern
#

zig is so cool. i can build the binary on my windows machine for arm linux so easily. now my "builds" take less than 30s

.PHONY: build-DiscordSignatureVerifyZig clean

build-DiscordSignatureVerifyZig:
    @if [ ! -f bootstrap ]; then \
        echo "Bootstrap binary not found, building..."; \
        zig build -Dtarget=aarch64-linux-musl -Dcpu=baseline -Doptimize=ReleaseFast; \
        cp zig-out/bin/bootstrap $(ARTIFACTS_DIR); \
    else \
        echo "Bootstrap binary found, skipping build"; \
        cp bootstrap $(ARTIFACTS_DIR); \
    fi

clean:
    rm -rf zig-cache zig-out
sharp geyser
#

Okay

frosty gale
#

is the only good thing about zig is that it builds fast

sharp geyser
#

Pretty much

#

Lmao

frosty gale
#

rewrite chromium in zig

sharp geyser
#

zig offers very little other benefits from what i can tell

#

ig if you want to write something in C use zig

#

because its the "better c"

#

other than that idk what else it is useful for

proven lantern
#

zig is really good for cold starts compared to Rust. rust inits a lot of stuff for the borrow checker

sharp geyser
#

You can't compare zig to rust

#

Its dumb

proven lantern
#

they both compile to binary

sharp geyser
#

Ah

#

So

proven lantern
#

so they both are good for lambda

sharp geyser
#

C, C++, Java, And basically any other compiled language then

#

I guess they all are alike

proven lantern
#

not java but yea

#

C is really good too

sharp geyser
#

Java can compile to binary

proven lantern
#

C++ has too much junk

sharp geyser
#

right

proven lantern
#

makes it a bit slower for cold starts

sharp geyser
#

you are missing the point

#

Rust and Zig are nothing alike

proven lantern
#

the binaries aren't

sharp geyser
#

The only thing they share is some similarities with syntax

proven lantern
#

zig makes faster binaries for the lambda environment

sharp geyser
#

zig is like C

#

rust is like C++

proven lantern
#

yeah, rust and c++ both are slow for lambda

sharp geyser
#

trying to compare zig and rust is the dumbest thing anyone can ever do

proven lantern
#

guess which one is zig and which is rust

sharp geyser
#

are you talking about AWS lambda?

proven lantern
#

yeah

sharp geyser
proven lantern
#

cold starts and all

sharp geyser
#

So you are comparing two languages that are unrelated based on one service hardly anyone uses

#

Well if zig is better for using aws lambda then use it

proven lantern
#

i am

sharp geyser
#

but comparing zig and rust based on that alone is idiotic at best

proven lantern
#

rust has it's use cases too

#

but for aws lambda zig is better

#

That's why every month AWS Lambda has over a million monthly active customers who generate over 10 trillion invocations.

#

lol

sharp geyser
#

A million is nothing

#

Also, AWS lambda sounds useless

#

Literally sounds like cloudflare workers

proven lantern
#

it has use cases i promise

frosty gale
proven lantern
#

there are tools that will make binary from java

frosty gale
#

doesnt sound like an intended use for java

#

"write once run anywhere"

sharp geyser
#

but there are other jdks you can use to compile to binary

frosty gale
#

by that logic i can say python is a compiled language too

sharp geyser
#

howd you know

proven lantern
#

the binaries that you get from java and python would be even slower than rust

frosty gale
sharp geyser
#

they use cranelift

proven lantern
frosty gale
#

blazingly slow ig

proven lantern
#

ยฉโ„ข

#

zig doesn't use LLVM anymore

sharp geyser
#

likely uses cranelift

proven lantern
#

they wrote their own toolchain in zig

sharp geyser
#

I know

#

I was kidding

proven lantern
#

lol

sharp geyser
#

It bootstraped from c++

#

then wrote its compiler in itself from there

proven lantern
#

yep, and it(stage 1 compiler) started off using llvm

past field
#

just an update, i had one of my staff make bingo balls for it ๐Ÿ˜ฌ they look good!

#

@real rose

quartz kindle
past field
past field
#

/clickwar

#

damn it

sharp geyser
#

Hey tim

sharp geyser
#

I dont necessarily want to use a lib

#

and all I get online is apps for it

quartz kindle
quartz kindle
sharp geyser
#

Tim

#

You are supposed to know these things

#

Who am I to ask but you

past field
#

he does know it

sharp geyser
#

I knew it

past field
#

itโ€™s somewhere in his brain

sharp geyser
#

he lied

past field
#

he just has to find it behind the rest of his knowledge

sharp geyser
#

cant believe Tim lied to me

past field
#

but whatever you asking, itโ€™s somewhere in his brain

proven lantern
#

it's super old though

sharp geyser
#

ew java

proven lantern
#

theres some c# in there too

#

some cpp

sharp geyser
#

Bro

#

The cpp file for ios is 11k lines

#

Im not reading all that

proven lantern
#

lol

#

dont you want to write a barcode scanner?

sharp geyser
#

11981 lines

#

no ty

sharp geyser
proven lantern
#

lol

past field
quartz kindle
#

im managing to partially decode these damn proto buffers

#

still a god damn awful format

sharp geyser
#

bro can decode proto buffers

#

but not barcodes

#

smh

quartz kindle
#

imagine

#

protobuf encoded barcodes

#

seriously, why do we not have encrypted barcodes/qrcodes

#

sounds like something that absolutely should exist

sharp geyser
#

Why

#

Would that

#

ever exist

quartz kindle
#

why not

sharp geyser
#

You know how painful that would be for businesses

#

Not to mention fact checking

#

You'd have to have the key to decode it to know what it is

quartz kindle
#

exactly

sharp geyser
#

meaning businesses can scam the fuck outta you

#

Oh what you bought is a bar of soap????

quartz kindle
#

nah its specifically so you can print barcodes and be sure only your target recipient can scan them

sharp geyser
#

Nope it turns out its actually a rolex

sharp geyser
#

But still a bad idea

quartz kindle
#

i mean

sharp geyser
#

There are standards to barcodes so you can track the product down to who made it

quartz kindle
#

you can just encryopt the text yourself and then print a barcode for it

#

lel

sharp geyser
#

what

#

barcodes dont hold text afaik

quartz kindle
#

qrcode

sharp geyser
#

They only hold a sequence of numbers

#

which in turn tells you about the product

quartz kindle
#

barcode barcode ye, but i mean more the general printed code tech

#

like all the qr code variants

sharp geyser
#

I mean ig

#

Encrypted qr codes are a thing afaik

quartz kindle
#

brb encoding all my passwords into an encrypted qr code and tattooing it on my arm

sharp geyser
#

As in you encrypt the data

#

then you decrypt it when decoding the qr code

quartz kindle
#

ye

#

changing subjects

#

i find this amusing

#

CrowdStrike Engineering has identified a content deployment related to this issue and reverted those changes.
Workaround Steps:

  1. Boot Windows into Safe Mode or the Windows
    Recovery Environment
  2. Navigate to the
    C: Windows/System32|drivers/CrowdStrike
    directory
  3. Locate the file matching "C-00000291*sys", and delete it.
  4. Boot the host normally.
#

also, why brazil was not affected

sharp geyser
#

wtf is crowdstrike

quartz kindle
#

they are like a security company responsible for updating shit for other companies

#

they pushed a bad update and broke millions of pcs, including airports, banks, and shit

sharp geyser
#

rip

#

Sounds like a skill issue on their part

quartz kindle
#

yup

sharp geyser
#

but nah

#

I didnt hear about the outage

quartz kindle
proven lantern
#

wasn't the binary a bunch of 0s?

quartz kindle
#

Crowdstrike is known for producing antivirus software, intended to prevent hackers from causing this very type of disruption.

#

lmfao

proven lantern
quartz kindle
#

also, i found this comment on reddit

#

Fun fact: I'm a former Firefox dev. The leading cause of headaches was anti-viruses that just linked themselves to Firefox and started doing arbitrary things in memory, instead of using the APIs dedicated to let anti-viruses do their job properly. In my experience, all the crashes were attributed to Firefox by users who (of course) had no way of knowing better.

So this fiasco feels extremely familiar.

Perhaps now people will start being cautious about security software and realize that some of them are actually more dangerous than the harm they're supposed to avoid

sharp geyser
#

all 0's is a good thing

proven lantern
#

very true

#

the problem was actually the code that referenced this code didn't check for null before dereferencing

sharp geyser
#

bah

#

how could that cause issues

proven lantern
#

null causing all the problems again

sharp geyser
#

that sounds like every developer ever

#

I never check for null

#

I just let shit happen

#

I go with the flow yknow

proven lantern
#

that works

#

people with that mindset work on the kernel now

#

sad times

quartz kindle
#

people be doing if(!var) on C and ASM

#

:^)

sharp geyser
#

Ah yes

#

bools in C

#

Love it

neon tusk
#

if im developer and i submitted a new bot is it going to be quick than before or the same ?

sharp geyser
#

Depends on the queue size

#

If you are asking if you get special treatment because you already have a bot on the site the answer is no.

#

You wait just like everyone else

civic scroll
#

@quartz kindle question: are dropped frames "saved frames" or "lost frames"

small tangle
#

should be the latter

civic scroll
real rose
frosty gale
#

thing is if it wasn't for windows following good osdev practices this bug probably would've went unnoticed

#

the driver is still bound to page tables so when it tried to deref 0 that area of memory was unmapped which caused the blue screen

#

otherwise it would've just allowed it

#

since well the driver runs in kernel mode (probably) so it can do anything

#

including deref 0

quartz kindle
#

@green kestrel why are so many people running D++ on windows @_@

radiant kraken
#

why not

quartz kindle
quartz kindle
#

yes

civic scroll
quartz kindle
#

xD

frosty gale
#

its always linux this linux that

#

maybe some people want their trusted corporate overlord microsoft to run their app

quartz kindle
radiant kraken
green kestrel
#

most bots are run directly on peoples desktops not on a VPS

#

(unfortunately)

#

can tell that from what percentage of bots are offline when reviewed here on top.gg

radiant kraken
#

is that a bad thing because i use windows

green kestrel
#

if it works for you

#

im planning on getting rid of windows 10 on this laptop and moving to kde

#

im fed up of upgrade to 11 by buying new hardware nags

quartz kindle
#

iirc they removed those checks there

green kestrel
#

but no

#

lol

#

im not running a crippled windows 11

quartz kindle
#

understandable have a nice day

green kestrel
#

i do actually use bitlocker and stuff, it cripples them

quartz kindle
#

i mean, is it really crippled when all the stuff it removes is useless?

green kestrel
#

bitlocker isnt useless

quartz kindle
#

it is for me :^)

green kestrel
#

so youre ok with id someone steals your device, they have all your data?

quartz kindle
#

sure

green kestrel
#

do you use online banking? buy anything online?

quartz kindle
#

not on the pc no

green kestrel
#

but the accounts you pay for are on your pc?

quartz kindle
#

some i guess, like facebook and shit

#

but my pc doesnt even have a password

#

it has literally zero security on it

green kestrel
#

youre a hackers dream

quartz kindle
#

because i dont care :)

green kestrel
#

its because of people with machines like yours that stuff like crowdstrike exists.

quartz kindle
#

its my personal machine, not a business machine tho

green kestrel
#

you not caring affects everyone else

quartz kindle
#

i dont need security on my personal stuff

green kestrel
#

you can easily become part of some botnet, or otherwise end up participating in things that are detrimental to the stability of the internet as a whole

quartz kindle
#

yeah im not that dumb

green kestrel
quartz kindle
#

i dont run random software downloaded from strange websites

green kestrel
#

your house is just your personal stuff, doesnt matter

#

doesnt need a lockpassword

quartz kindle
#

lmao

#

thats not really a good analogy but ok

#

irl houses dont have firewalls and network systems in front of it

green kestrel
#

sure it is

#

the stuff on your pc has value, the resources of your pc have value

#

just as your tv, your phone, your clothes etc have value

green kestrel
quartz kindle
#

the only value the pc has is resale value for the thief

green kestrel
#

no

quartz kindle
#

nobody cares about data

green kestrel
#

thats an ignorant assumption

quartz kindle
#

i live in brazil

green kestrel
#

your pc still can run code

#

thats what a haker wants it for

#

they dont give a shit about what you do on facebook

quartz kindle
#

why would they steal it and then run code on it

green kestrel
#

they want to make it part of a botnet to do criminal activities, or to mine coins, or send spam

quartz kindle
#

they only steal to sell

green kestrel
#

no, they dont need to STEAL it

#

beause you dont encrypt it, you dont password it, you have left it wide open

quartz kindle
#

that doesnt leave it open from the internet

#

only from the physical use

green kestrel
#

no, but not passwording and encrypting it does weaken it massively, it only takes one zero day remote exploit, and there are no protections on the accounts

#

i bet you even run as administrator

quartz kindle
#

yes i do

green kestrel
#

smh

quartz kindle
#

its my machine, i own it

green kestrel
#

its the hakers machine too, they own it

#

๐Ÿ˜„

quartz kindle
#

i dont need to have any software running on it with higher permissions than mine

quartz kindle
green kestrel
#

do you install ALL windows updates the day they are released?

quartz kindle
#

no

green kestrel
#

then how can you say youre secure and wont get hacked

quartz kindle
#

i have windows update disabled

#

only update every once in a while

green kestrel
#

really, im done talking about this with you

#

as far as security goes, youre a n00b

quartz kindle
#

i dont have hacker paranoia

green kestrel
quartz kindle
#

i've literally never had any problem

#

i've had wayyyy more problems with windows update and with microsoft shit

green kestrel
#

then dont complain the day someone takes down all your bots and steals your token, from your un-updated dev machine via a key logger or trojan

quartz kindle
#

yeah never gonna happen

neon leaf
green kestrel
#

making a note of this conversation for later

quartz kindle
#

lmao

#

this kind of paranoia is what makes machines swlo af

#

antiviruses cause more problems than they solve

#

all security does

green kestrel
#

i dont run an antivirus

quartz kindle
#

the whole crowdstrike problem is proof

green kestrel
#

or security software

#

but i do have a firewall (hardware), i do have a password, i do have my drives hardware encrypted, and i dont run all my stuff at highest privilege

quartz kindle
#

explain to me how does hdd encryption protect from hacking

green kestrel
#

because an intruder cant just read raw sectors off your device

#

bypassing the OS security

quartz kindle
#

if they hack into the machine, the machine is already running

green kestrel
#

thtas one reason

quartz kindle
#

so the hdd is already decryteed

green kestrel
#

yes, but they dont have the key, just because its running

#

the key is stored in the TPM

quartz kindle
#

they have access to the running machine

green kestrel
#

you know, that chip you said to bypass

#

you cant just query the TPM for the key

quartz kindle
#

why need the key when the hacker can run remote commands on the already running machine?

green kestrel
#

because youre not running as administrator right? so they can only run commands as YOUR user

#

which means they cant read or change those OS files that arent accessible to your user...

quartz kindle
#

thats just user privilege, not directly related to hdd encryption

green kestrel
#

this is the default in linux, NOBODY runs everything as root

quartz kindle
#

if they get admin access, they can use the running machine anyway, regardless of hdd encryption

green kestrel
#

still

#

encryption costs you nothing in terms of cpu

#

it doesnt slow down your pc

#

you should use it if you have it

quartz kindle
#

i costs a lot in terms of being recoverable

frosty gale
green kestrel
#

eh what, how? you going to forget your password?

#

oh wait you dont use one kekeke

frosty gale
#

but its the worst thing you could do

quartz kindle
#

a damaged encrypted drive is hell for data recovery

green kestrel
#

whats your facebook password, an empty string?

quartz kindle
#

i've had to deal with that way mroe times than with hacking

green kestrel
#

i think youre confusing hardware encryption that is part of the SSD firmware, with shitty software encryption

quartz kindle
#

i am talking about hardware encryption

#

i'll never use that crap

frosty gale
#

i would never use hardware encryption either

quartz kindle
#

the only thing it protects again is from unauthorized physical access

frosty gale
#

it probably has 50 different backdoors

quartz kindle
#

and if anything bad happens, yeah good luck getting your data back

frosty gale
#

my bitlocker doesnt use the tpm, only a strong password i type in on boot

green kestrel
#

windows 11?

frosty gale
#

yeah but its because i disabled it explicitly

green kestrel
#

btw if any of you have a phone youre basically forced to use all this security stuff you all profess to hate

quartz kindle
#

well, google did try to encrypt my phone, i pressed no tho

frosty gale
#

thats why it kills me when i see people using their phones for OPSEC of any type

#

unless its some off brand with a custom OS you cant trust it for anything

green kestrel
quartz kindle
#

my phone didnt even have a lock screen for a long time, i was forced to add one because of an app that doesnt work without it

green kestrel
#

so if someone steals your phone theyd have had everything?

#

all your accounts, your photos, possibly a 2fa app?

quartz kindle
#

not right now because it has a lock screen

green kestrel
#

ability to send texts and whatapp as you?

#

but they could before?

quartz kindle
#

before they could yes

green kestrel
#

thats awful

#

lucky you put a lock screen on it now

#

ever had your phone stolen? i have

quartz kindle
#

i have yes

#

and you know what they do?

#

they instantly shut it down and remove trhe battery to prevent tracking

#

then they facgtory reset it

#

and resell

green kestrel
#

i know what they did with mine, because i got it back ๐Ÿ˜„

frosty gale
#

the tim we see here now might be some random Brazilian thief from having his phone stolen