#development

1 messages · Page 2062 of 1

boreal iron
#

Scroll up a little bit

proven lantern
#

all the commands in leaderboard are nested in a type:1 object. so i just needed to make a container for those two options

eternal osprey
#
let r = {"test": {"first" : [], "second" : [], "third" : [], "fourth" : [], "fith" : [], "sixth" : []}}

    fs.writeFileSync("./hall.json", (JSON.stringify(r)), (err) => {
      if (err) console.log(err)
    });```

Hey why is this code not updating my json file properly?
#

For some reason if i log the first key, it still returns as the previous set value

ancient nova
#
app.get("/clearTable", function(request, response) {
  response.setHeader("Content-Type", "application/json"); 
  
  var removeDatabase = db.prepare("DELETE FROM messages");
  removeDatabase.run();
  
  var createDatabase = db.prepare("CREATE TABLE messages (message TEXT NOT NULL, user TEXT NOT NULL)");
  createDatabase.run();

  response.json({ success: true });
});

``` anyone knows why it doesn't delete the table?
pine nova
#

and ig to delete table its

DROP TABLE <TABLENAME>
lyric mountain
#

Use let please

pine nova
lyric mountain
#

Also use VARCHAR for user instead of text

#

Unless ur using sqlite

#

TEXT takes way too much space for something that small

#

I'd even say message can be a varchar, people don't type stuff that big in a single msg

#

Oh and last but not least, add an id column

#

Non-indexed tables are awful (natural search is many orders slower than indexed search)

#

The difference can be like 15s vs 6ms

sharp geyser
#

I wonder what this guy is even making

lyric mountain
#

a chat for his game

sharp geyser
#

But...isn't his game in discord?

lyric mountain
#

I don't ask questions, all I do is deliver the package

sharp geyser
lyric mountain
sharp geyser
#

So if I tell you to deliver something for me across the border will you question it?

wheat mesa
#

My UPS driver when I ask him where my 30 Amazon packages went

lyric mountain
#

when u buy a a book but instead receive 30 1TB hdds

sharp geyser
#

I wouldn't be mad

sharp geyser
#

50$ per hdd roughly

sharp geyser
#

I'd sell em

#

make bank

lyric mountain
#

when life gives u hdds, you make a server

sharp geyser
#

Nah fuck that

#

you make bank

#

60 hhds

ancient nova
#
        // Fetching our messages
        let fetchResult = await fetch("https://transparent-speckle-door.glitch.me/getMessages", {
            method: "GET",
        }).then(res => res.json());

        // Lets now structure the messages we fetched. :)
        fetchResult = await Promise.all(fetchResult.message.forEach(message, user => `${user}: ${message}`));
``` anyone know how to fix this?
sharp geyser
#

sell most of em

lyric mountain
#

also, yes, user and message are objects not string

ancient nova
sharp geyser
lyric mountain
ancient nova
ancient nova
ancient nova
#

yes I fixed that

lyric mountain
#

u added an index?

ancient nova
#

wdym index?

lyric mountain
#

then u didn't fix it

#

unless u want to make your users wait several seconds after each message sent, use an index

wheat mesa
lyric mountain
sharp geyser
ancient nova
sharp geyser
#

Adding an index would be the first thing i'd do before "making sure it works"

lyric mountain
#

it's not about optimizing, it's about basic sql structure

sharp geyser
#

lest you have to go back and change the code anyway to fetch by index

lyric mountain
#

u don't go to italy and break a pasta

#

u don't sql without indexes

sharp geyser
ancient nova
#

I finished my discord V2 😭

#

it's awesome

sharp geyser
#

is that just grabbing messages from discord?

ancient nova
sharp geyser
#

You should make it so when someone is typing it says {user} is typing.. kinda like discord no reason really just something to do to practice socket.io

ancient nova
#

🤷‍♂️

#

I may

#

I wanna

#

space up the GUI a bit though

sharp geyser
#

There really is no actual reason to do so, it is literally just for aesthetics

ancient nova
#

I may make it look like my tool does

#

hold on

#

let me

#

show u

#

this one communicates with the same backend

#

so it will be easy to integrate some features

#

like the logo display

sharp geyser
#

I wanna make a terminal version of discord but on a smaller level

ancient nova
#

that'd be cool

#

we could fight to see who mades better discord

#

😭

sharp geyser
#

just some simple shit

ancient nova
sharp geyser
#

scratch that

#

not even making a terminal chat app too boring

#

ima go all out

ancient nova
#

I made it look a little bit better

#

and fixed all the issues with the CLI

sharp geyser
#

all about desktop applications

ancient nova
#

alr

sharp geyser
#

not even using electron

ancient nova
#

what are u gonna use then :0

wheat mesa
#

inb4 “wpf is too hard”

sharp geyser
#

thank you very much

radiant kraken
#

Tauri is so promising

#

like finally i have a purpose in learning Rust ia_lul_haha

sharp geyser
#

they dont even have their github linked to discord

#

😔

pale vessel
#

who does that anyway

sharp geyser
#

people who like showing off their shit code

wheat mesa
#

it's the only thing I have publicly linked

radiant kraken
#

instead of just using about me

#

or status

wheat mesa
#

yeah

ancient nova
#

unfortunately not

#

@sharp geyser

#

added role colours and some other improvements

#

how is it going for u?

sharp geyser
#

my g I am using something completely new to me going to take a while

wheat mesa
#

he is using a real men's programming language

sharp geyser
wheat mesa
#

actually no that's C

sharp geyser
#

and I am loving it

#

I am now a spokesperson for tauri

ancient nova
#

what are you doing now? need help?

sharp geyser
#

Nope

#

I am good

#

I am reading the documentation on tauri

ancient nova
#

gl with it

#

send me a pic once u start making some UI

sharp geyser
#

lovely UI

ancient nova
#

are you making a program to communicate with the discord's API or are u making ur own chatting server?

sharp geyser
#

I have not decided on everything ima use yet

ancient nova
#

alr

#

I'm using my own server if that helps

sharp geyser
#

I am likely going to implement voice calling so I will probably use something like webrtc (unless there is something better)

ancient nova
sharp geyser
#

as for the basic communication between each other it will be a websocket implementation of some sort unless there is a better way

ancient nova
sharp geyser
#

I am going for an actual chat app kek

wheat mesa
#

that's not raw socket...

ancient nova
sharp geyser
#

holy shit just burnt my tongue lovely

ancient nova
#

after the post request it sends data back to the front end to display what I sent

wheat mesa
#

that's just called a backend lol

#

socket usually implies websocket

ancient nova
sharp geyser
#

Probably not right away

#

but I will have dms and group chats

ancient nova
sharp geyser
#

doing too much at once will be a pain to handle

sharp geyser
#

Ima just start out with making users and shit first and getting the login and signup working

ancient nova
#

my chat is a one big chat for now and a one big DB with messages

#

which isn't very scalable

sharp geyser
#

loading messages will be an interesting thing

ancient nova
#

it's pretty fast actually

#

I optimized it as much as I could

#

takes around 10ms to send a request to retrieve messages

sharp geyser
#

I am probably just going to go with the approach of loading the messages once you enter that dm and then just add messages onto it after once they are sent.

ancient nova
#

plus optimized it to only send if you hear back from the API that the chat needs upating

#

very efficient

sharp geyser
#

Loading all messages for everything your apart of seems inefficient

ancient nova
sharp geyser
#

yes and they still manage to use twice the ram they need 😔

ancient nova
#

Imma dip for today

#

gl with ur project

#

cya

radiant kraken
earnest phoenix
#

What is right image size for description in topgg

sharp geyser
boreal iron
#

You can use css to resize the image based on the clients resolution

#

Within the limits of the site

feral aspen
#

When it comes to scientific numbers, in a floating point number, is there a difference between e and E?

public class Main {
    public static void main(String[] args) {
        float f1 = 35e3f;
        double d1 = 12E4d;
        
        System.out.println(f1);
        System.out.println(d1);
    };
};
pale vessel
#

man please stop putting semicolons after everything pain

pale vessel
#

The format of scientific notation in Java is exactly the same as you have learned and used in science and math classes. Remember that an uppercase 'E' or lowercase 'e' can be used to represent "10 to the power of". Scientific notation can be printed as output on the console if it passes a certain number.

wheat mesa
#

Yeah those semicolons on the braces are completely unnecessary

radiant kraken
#

class definitions in C++ requires semicolons in the braces

wheat mesa
#

yeah

split hazel
#

let them do what makes them happy

#

semicolons bring me joy

feral aspen
#

Waaat, there is no Strictly Equal to operator on Java?

#

I believe Java handles type comparison, true?

wheat mesa
#

Wdym?

#

Java does not have ===, there's no point

#

You can't compare two different types like that

#

Like 1 == "Something" is just invalid

#

You can do like 97 == 'a' but that's because chars are represented by numbers

#

it'll throw

feral aspen
#

Fair enough. 👍

radiant kraken
split hazel
#

but what would bring me more joy is if @earnest phoenix leaked me the secret of writing a program in TQ instead of js

fervent moss
split hazel
#

javascript is so slow

#

i bet tq is like 1000x faster

#

its like the assembly of java

turbid geyser
#
         let moderations = await this.container.client.db.moderations.findMany({ where: { id: `${message.guild?.id}`}})
         await this.container.client.db.moderations.create({
            data: {
                id: `${message.guild?.id}`,
                user: member.id,
                mod: message.author.id,
                case: `${moderations.length}`
            }
         })
         let e = new MessageEmbed()
         .setColor('RED')
         .setAuthor({ name: `${message.author.username}`, iconURL:`${message.author.avatarURL({ dynamic: true}) || message.author.defaultAvatarURL}`})
         .setFooter({ text:`Case #${moderations.length}`, iconURL:`${this.container.client.user?.avatarURL()}`})
         .setDescription(`› **Action**: Ban\n› **Offender**: ${member.user.tag} (${member.user.id})\n› **Moderator**: ${message.author.tag} (${message.author.id})`)
          message.channel.send({ embeds:[e]})
#

how do i make case in prisma

#

i tried this

turbid geyser
#

no ideas?

sick agate
split hazel
#

the hidden easter egg of javascript

#

the language that is hidden from us

#

because they dont want us to experience the performance of it

#

very selfish

sick agate
#

Kekw

radiant kraken
#

or do you have to set them manually with buf[x] = y

pale vessel
#

Buffer.from()

radiant kraken
#

thanks

sacred aurora
#

can someone explain what is happening in here?

#

its true but doesn't make it to the final array

#

ayo wth

woeful pike
#

your regex probably has a g flag which makes it stateful

#

don't make it global if you want it stateless

sacred aurora
#

ah you're right

#

tyty

quartz kindle
# radiant kraken thanks

also check Buffer.from(ArrayBuffer) if you want to wrap the existing memory and not create a copy of it

dawn vigil
#

Folks any idea how I can get my bot's name & avatar on top.gg updated? I hear my bot needs to be in a bot list server for that to happen, is this said server?
My bot has already been approved fwiw

pale vessel
#

the bot does not need to be in any server, simply press the refresh data button on the bot page

dawn vigil
pale vessel
#

try going to the edit page and save again

dawn vigil
#

Good shout! Yup that fixed it, many thanks!

quartz kindle
split hazel
#

pf efficiency

#

irrelevant but its funny how in c++ if you dont use references or pointers for function parameters everything will be copied

#

even giant structs

quartz kindle
#

working with buffers is fun, because you can have a Buffer, a TypedArray and DataView all work on and reference the same memory

split hazel
#

whats the difference between a uint8 array and a buffer

#

they should be the same thing

quartz kindle
#

node buffer extends uintarray

#

and implements similar methods to dataview

#

plus extra methods for strings

#

so basically node buffer = uint8array + dataview + textencoder/textdecoder

#

arraybuffer is the base for all of them, is what actually contains the memory block

#

everything else extends arraybuffer

quartz kindle
split hazel
#

i mean it has to be the case anyways

#

functions are supposed to be standalone pieces of code

#

they have no perception whether something should be copied or not you have to specify so

#

a single & might just save you a lot of performance

#

tho copying on modern processors is quite fast anyways

#

even faster if the code you're running takes advantage of SSE

quartz kindle
#

ye

pine nova
timber fractal
#

developers help, I've been browser hijacked

#

how do i find what caused this and remove it?

timber fractal
#

i removed 3 extensions and it looks like its gone

#

the thing that made me notice it is gone now

spark flint
#

Chrome has a feature for this too

#

chrome://settings/cleanup

timber fractal
#

what is it? how do i get it?

#

oh thanks

spark flint
#

np

timber fractal
#

i noticed when i googled, every search result would first be redirected to search.bevoci.com

#

so i googled that website and that got me to an article saying it was a browser hijacker fake search engine

#

earlier today everyting i searched would be redirected to bing

split hazel
#

this is why im insane

sick agate
#

Welp

radiant kraken
spark flint
#

turned out

earnest phoenix
#

how long does it take to accept a discord bot

split hazel
#

too long

earnest phoenix
earnest phoenix
# split hazel too long

i coded a bot where you can save your crypto addresses and can be viewed by anyone by running a command which would help to make, payments, donations etc or in a marketplace server

split hazel
#

oh cool

#

does it show the amount in the wallet?

earnest phoenix
#

all transaction to the wallet

#

incoming and outgoing

#

which determines how much cash u got

#

dm me @split hazel

split hazel
#

some random thoughts

#

memory garbage collection is kinda like cleaning your room

#

you leave it until a special time

sick agate
#

Yeah

#

And there is people who take their room automaticaoly

wheat mesa
#

and then if it gets to be too much you lose motivation to clean it

sacred aurora
#

same regex, same input

spark flint
#

its very handy

sacred aurora
#

i mean it works just fine

#

but sometimes they don't

sacred aurora
spark flint
#

odd

sacred aurora
#

to be more specific, the one that didn't work is a string from cheerio

#

i copy the input and test it again.
and it actually works

#

still confused why tho

#

nvm i found the problem, the string contain a weird space.
which doesn't count as a space hmm

lyric mountain
#

\s matches any space-like character

sacred aurora
lyric mountain
#

Also when matching letter "i" remember turkish don't put tittle in "i" mmulu

boreal iron
#

imagine using join when you can implode a string

lyric mountain
#

implode lmao

#

tf is with php

boreal iron
pine nova
boreal iron
#

oops, wrong button

split hazel
#

imagine using implode when you can explode

boreal iron
split hazel
#

wait it makes sense tho

boreal iron
split hazel
#

explode = spread apart violently

#

implode = opposite

lyric mountain
#

php is too aggressive

boreal iron
#

violently

#

lol

split hazel
#

who said php wasnt rough

eternal osprey
#

hey does anyone have some good vsc themes? I just installed a purple one and it's fucking my eyes

wheat mesa
#

One dark pro + JetBrains mono font

split hazel
#

not easy to find one that hits you

fathom sonnet
#

guys, how do I check if bot have higher role than selected user?

earnest phoenix
fathom sonnet
#

discord.js

#

ik that there was part of the code like

.highestPosition

#

something similar

#

but cant find it anywhere

earnest phoenix
#

You can compare the position of the highest role of said guild members to check that, to get their highest role position; you can access the <GuildMember>.roles.highest.position property

fathom sonnet
#

yea i think thats it, now i need to compare it to bots role

#

should that then be something like

me.roles.highest.position

earnest phoenix
earnest phoenix
fathom sonnet
#

thank you verry much

midnight marsh
earnest phoenix
midnight marsh
#

thank you

#

Hey@fathom sonnet , your bot's cleaner has a problem I think

fathom sonnet
#

my bot is i think offline rn

midnight marsh
#

WTH IS GAYMETER 😂

fathom sonnet
#

doing some fixes due to permissions

midnight marsh
fathom sonnet
fathom sonnet
midnight marsh
midnight marsh
fathom sonnet
#

heroku

midnight marsh
#

Like me...

fathom sonnet
#

hehe it is best option if you go for free one

#

🙂

midnight marsh
#

those dynos. you using more accounts to get free hours?

midnight marsh
fathom sonnet
#

lemme see

midnight marsh
#

What? then how you keep your bot alive?

fathom sonnet
#

ahh i should...ammm add my cc dx

#

xd

midnight marsh
#

😂

#

Impossible to keep one alive without a worker

#

I seaeched about 2 days to find it

fathom sonnet
#

worker?

#

wut dat

midnight marsh
#

in Procfile?

fathom sonnet
#

ahhhh

#

ouuu

#

I see

#

xd

midnight marsh
#

wth😂

fathom sonnet
#

xd

#

i need some good leveling bot which can also add roles on levels etc

ancient nova
#

guys so I need a game idea

#

I want to create a short horror game

#

something like max 30 minutes of gameplay and something I can create in max a week

#

cause every project I start gets too big too easily and hard to manage

#

so looking for a short game idea

austere surge
sharp geyser
#

if I do a check for the MANAGE_MESSAGES perm anyone with admin/server owner should still be able to use the command no?

#

I completely forget how discord perms work

ancient nova
#

@sharp geyser how's your discord V2 going?

ancient nova
wheat mesa
#

Ew discord js

#

He’s not a djs user

#

I saved him from it

sharp geyser
#

just forget how discord perms work

ancient nova
# sharp geyser just forget how discord perms work

I'm pretty sure discord checks them based on roles or global permissions, if you have a role with manage channels permission for example then checking for that permission would return true, but if you have a channel that gives you that permission it would return false even if you have that permission

ancient nova
ancient nova
wheat mesa
vivid fulcrum
wheat mesa
craggy pine
#

cursed

sharp geyser
#

What would be the easiest way to make a button collector? (I am not using djs so ye)

quartz kindle
#

create a component listener and apply filters to it

sharp geyser
#

I don't think keeping a constant event listener going is a good idea

quartz kindle
#

you need to stop it once the collector finishes

sharp geyser
#

fair point

quartz kindle
#

thats whats djs does

sharp geyser
#

I tried looking at djs implementation but it was super hard for me to follow

quartz kindle
#

an alternative is to have an always on listener internally

#

and this listener checks for active collectors in a list

#

so your collectors just add/remove themselves from that list

#

instead of creating and deleting a new listener

sharp geyser
#

that isn't very performant tho is it?

quartz kindle
#

there shouldnt really be any difference

sharp geyser
#

mmm I see

#

I think ima just try and make a component listener like djs

sharp geyser
#

yea I fucked up mmLol

#

time to start over

ancient nova
#

is this okay to do every frame?

sharp geyser
#

depends on what UPDATE_BODY does

woeful pike
#

why not run this function when the user does a thing that requires a change instead of constantly polling to see if a change has been made

rocky hearth
#

In ts I want to filter out all the values that is not undefined and get the keys
I just want to keep undefined keys.

type RootParamList = {
  loading: undefined;
  home: undefined;
  dontwant: number;
};

How do I convert above type to just "loading" | "home"

earnest phoenix
cinder patio
earnest phoenix
#

To limit the object to keys with only the value undefined, you can declare it as

Record<string, undefined>
rocky hearth
cinder patio
sharp geyser
#

Maybe I should just fuck with types more than actual coding useful shit

earnest phoenix
#

How to keep setDescription like this ||Track queued - Position 2||

near stratus
rustic nova
# wheat mesa

actually just realized smth

you cant reply to that message since it was deleted before mmLol

#

though am sure that was back when it would just do

ok
@rustic nova

pine nova
#

are websockets necessary to make a music stream/radio website?

spark flint
#

I'd recommend something like Shoutcast / Icecast

#

I personally use Azuracast which provides a web admin GUI for Shoutcast and Icecast

pine nova
#

I see

near stratus
#

I have it even better

earnest phoenix
#

nedd help

split hazel
#

we all do

cinder patio
sharp geyser
wheat mesa
# cinder patio

I mean it makes sense but I don't see why you would ever need this lol

viscid gale
#

hm guys wanna pick your brains real quick.. I just wanna know how JSON knows the object from the array after this

var obj={0:1,1:2,2:3,__proto__:Array.prototype}
Object.defineProperty(obj,'length',{value:3,writable:true,configurable:false})
var arr=[1,2,3] //an equivalent array in terms of the values

let test1=JSON.stringify(Object.getOwnPropertyDescriptors(obj))
=== //literally all properties are the same
JSON.stringify(Object.getOwnPropertyDescriptors(arr))
let test2=obj.toString()===arr.toString() //again, same value
let test3=(obj instanceof Array)&&(arr instanceof Array) //true
let test4=JSON.stringify(obj)===JSON.stringify(arr)
//this test4 result is false but HOW DOES JSON KNOW THE DIFFERENCE
round cove
#

When you stringify an object with JSON it's typically used to make RESTFUL api calls is why.

#

It's different from .toString()

quartz kindle
#

json stringify returns a string, so in the end you are comparing two strings

#

these strings may contain differences that are not visible to the eye, for example invisible characters and differences in encoding

#

if the strings look exactly the same when logged, the only way to find the difference is convert them both to buffers and analyze it byte by byte

#

however in this case the difference is clearly visible

#

nevermind, i understand what you're referring to now

#

looking at it deeper now, im puzzled as well, this is a really interesting behavior

#

its also a v8 specific bug/oddity

#

chrome:

#

firefox:

quartz kindle
# viscid gale hm guys wanna pick your brains real quick.. I just wanna know how JSON knows the...

here's my theory, the js engine creates and manages objects on the c++ level, you cannot change what the object is from js. JSON.stringify is also written at the c++ level for performance reasons, so the function can tap into the object's "true" type. and firefox's engine seems to respect this as well, but for some reason chrome/v8 can actually be tricked into thinking an object is an array just from modifying its prototype, but its "true" type at the c++ level remains unchanged

#

@earnest phoenix what do you think? ^

viscid gale
quartz kindle
#

there is one function that is not fooled either

split hazel
#

pf strings are slow

#

use binary instead

#

a json struct

#

honestly you can do that for something like an API or tcp connection if all your messages have a predefined size and amount of expected entries

#

naming things is such a human thing

#

computers are way superior

viscid gale
quartz kindle
#

honestly this looks more like a chrome/v8 bug than anything else

viscid gale
#

perhaps

quartz kindle
#

interestingly, node is also not affected

#

even though it uses the same v8 as chrome

#

so far chrome's dev tools are the only place where this happens

viscid gale
#

ah.. so even with the same values.. nothing gets fooled

#

so.. then what's the difference between the array from properties and an actual array.. gonna put that up on SO and see some answers..

quartz kindle
#

yeah because there are hidden properties that are not visible from js

split hazel
#

why are y'all turning objects into arrays by abusing __proto__ 💀

quartz kindle
#

this is how objects look like in c++ (with v8)

#

they are much more complex than what is visible from js

#

js cannot change those hidden properties and values

viscid gale
#

for fun

pine nova
quartz kindle
#

abusing js is fun

#

because js lets us do it

#

other langs dont, they fight back

#

so we cant bully them

earnest phoenix
#

currently coping with everyone's favourite library

#

msal!

#

sadly i'm getting 401s if i try to get a bearer token with a code

split hazel
#

write a system driver that runs at ring 0 privilege level and try to make the hardware in the system blow up or something idk

#

now thats fun

vivid fulcrum
#

vanguard

quartz kindle
#

nobody uses ring 0 to try blow things up

#

only to try stealing stuff

#

is it even possible to actually blow something up (i mean like modern computers) from software only?

#

doesnt the hardware have a ton of safety checks and emergency shutdowns?

viscid gale
#

I love it for that ngl

quartz kindle
#

likewise

split hazel
#

other than that not really

#

if a chip does not have sufficient protections against bad code and instructions it can indeed break or do something unexpeced

#

in fact back in the day apparently badly coded os's broke certain monitors because they displayed color in an unexpected way

#

like completely bricked them

quartz kindle
#

lmao

#

well yeah but bricking is not exactly the same as blowing up xD

#

i mean, these days you can pretty much blow up a battery if you do something bad with its charge controller i guess

#

idk if you can even access that from the os tho

split hazel
#

you wish

#

i thought the os would have more control but not really

#

the os doesnt have much control over hardware

#

its really only up to the bios i think

quartz kindle
#

yeah

#

most components have their own tiny os'es controlling them

#

and everything is wired by ultra fast usb's

#

lmao

split hazel
#

it can send bytes and receive bytes from certain IO ports and thats it

quartz kindle
#

kind of

split hazel
#

do not mention usbs

#

i have no idea how i'll add them to my os

quartz kindle
#

have you ever messed up with RWE?

split hazel
#

they all use stupid communication lanugages

#

whats that

quartz kindle
#

read & write everything

split hazel
#

wot

quartz kindle
split hazel
#

dont even know what that is

#

looks like a vintage windows 7 program

round cove
#

lmao

quartz kindle
#

if anything can access the darkest corners of your pc, its this thing

split hazel
#

yea it does look low level

#

but why

quartz kindle
#

why not

#

i used it once to override a laptop's fan speeds

#

following strict instructions i found online of course, i couldnt have figured it out by myself

split hazel
#

those shouldnt be controllable via software 💀

quartz kindle
#

some are

split hazel
#

most laptop fans are only controllable by the bios firmware

pine nova
#

confusing chat fr

quartz kindle
#

well this little program can access and overwrite even that

#

even bios stuff

pine nova
#

imagin os

#

🏃

split hazel
#

that means my os can 😮

#

tim you need to make an os it just seems like your end goal in life

#

its not as bad as it sounds

quartz kindle
#

fan speeds are normaly stored in the EC, and you can access and override it

split hazel
#

i willguide you towards your hello world program

split hazel
#

just dont go too deep and you'll be fine

spark flint
#
server{

    listen 80;

    server_name http.capy.pics;

     location / {
        try_files $uri $uri.png @redirect;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;

        proxy_pass http://localhost:9000/httpcapy/;
    }
    location @redirect {
        return 301 https://capy.pics/;
    }
}```
this isn't working ![wahhh](https://cdn.discordapp.com/emojis/690952466602262559.webp?size=128 "wahhh")
#

its meant to allow both filename and filename.png to be allowed to be accessed

#

all files are pngs and that isn't going to change

split hazel
#

the stay away zones for a good fun experiences are the ACPI, networks and other stuff like that

#

dont know about disks i wanna try them soon

#

i really wanna write persistent data to the disk soon

quartz kindle
spark flint
#

its stored in a Minio bucket tho

quartz kindle
#

is the bucket accessible from the OS as a regular drive?

spark flint
#

uHH

#

i guess so yeah

#

lemme try find it

quartz kindle
#

then set the root dir to the correct path

#

try_files will check the disk and try to read the file

#

so the files have to be found and accessible on disk

#

and the path has to be correct

spark flint
#

ah ok

quartz kindle
#

if you just want to check if the url contains a png file, then you need to do something else

spark flint
#

how would I do that sus

quartz kindle
#

you can use something like if ($request_uri ~ .*.png) {}

#

inside the location block

spark flint
#

what does that do

quartz kindle
#

$request_uri is a variable that represents the url you're trying to visit

#

without the host name

#

the rest is some nginx specific way of doing pattern matching, i dont know much about it either

#

you can try looking up more examples

earnest phoenix
# quartz kindle <@456226577798135808> what do you think? ^

The JavaScript engines does create and manage objects at the C++ level (or whatever programming language it's written in, but in this case V8 is written in C++, so going off of that), it's not just objects but almost every primitive type is created and managed at that level for performance and memory concerns, JSON.stringify() is also indeed written in C++, almost every native method is; most operations do have access to the object's actual type on the user-land, but to a certain extent to not break things and so the same case with many other types, about the object prototype modification to "trick" the engine, some things depend on the prototype of primitives, and since arrays are also considered objects, that's why it thinks that way

#

Arrays are just objects with indexes as properties and elements as values

forest drift
#
{
    "command": {
        "roles": [],
        "blacklistchannels": [],
        "arguements": {
            "args1": {
                "roles": [],
                "arguements": {
                    "args1_1": {
                        "roles": [],
                        "args1_1_1": {
                            "roles": []
                        },
                        "args1_1_2": {
                            "roles": []
                        }
                    },
                    "args1_2": []
                }
            },
            "args2": {
                "roles": [],
                "arguements": {
                    "args2_1": {
                        "roles": []
                    },
                    "args2_2": {
                        "roles": []
                    }
                }
            }
        }
    }
}
#
{
    "mute": {
        "roles": ["player","moderator","admin","owner"],
        "blacklistedchannels": [],
        "arguements": {
            "add": {
                "roles": ["moderator","admin","owner"],
                "arguements": {
                    "type_pingid": { //any @ or id (@user)
                        "roles": ["moderator","admin","owner"],
                        "arguements": {
                            "type_input": { //any input (time)
                                "roles": ["moderator","admin","owner"],
                                "arguements": {
                                    "type_input": { //any input (reason)
                                        "roles": ["moderator","admin","owner"]
                                    }
                                }
                            }
                        }
                    }
                }
            },
            "remove": {
                "roles": ["moderator","admin","owner"]
                "arguements": {
                    "type_pingid": { //any @ or id (@user)
                        "roles": ["moderator","admin","owner"]
                    }
                }
            },
            "list": {
                "roles": ["player","moderator","admin","owner"],
                "arguements": {
                    "type_pingid": { //any @ or id (@user)
                        "roles": ["player","moderator","admin","owner"]
                    }
                }
            }
        }
    }
}
#

Ive been trying to solve this for a few days and ive finally given up. Basically its a permission handler, the bot goes through this before executing the command. im trying to make this system infinitely expandable. Basically itll only check the perms needed as far into the file as it has to, like for the "mute" example, if you just type "/mute @user 5h" itll stop before checking if perms are needed for the (reasoning)
Idk anymore, brain fried lmao

#

sorry for lack of stuff, again brain fried, can barely think rn

quartz kindle
#

where the chrome dev tools can be tricked into thinking an object is an array

#

but the same trick doesnt work on node nor firefox

earnest phoenix
# quartz kindle but the same trick doesnt work on node nor firefox

Hmm, I suppose the implementation of the JSON.stringify() method in the V8 engine actually looks into the internal slots rather than the prototype, I'm not exactly sure if this is a bug or if the other JavaScript engines are following the specification incorrectly, I found this pretty interesting as well

forest drift
#

im curious, will javascript die out? Like i know it will someday, but theoretically how far is that 'day'?

earnest phoenix
#

It'll never die out

quartz kindle
#

the other engines correctly differentiate between object and arrays in their repl environment

#

the chrome dev tools environment is the only one that is tricked

forest drift
# earnest phoenix It'll never die out

but something cant live forever, like (i dont have much knowledge on this) binary, its still alive in some sense, but its been sortof replaced/refaced with newer and faster languages

quartz kindle
#

i mean, the bases are never gonna be removed

#

people will just use tools that work on top of those bases because they are easier

#

but you're free to still use those bases if you want

forest drift
#

so in that sense, javascript will always have its roots intertwined in code forever, in at least some form?

quartz kindle
#

pretty much yes

earnest phoenix
earnest phoenix
#

This is actually amazing, I never saw anybody figure out this bug in the chrome dev tools

quartz kindle
#

never seen this before

forest drift
#

oh talking about chrome, whats up with the new javascript limit in chrome? like sometimes when ive accidentally pushed one of my scripts too far chrome just kills it and pops up an error?

quartz kindle
#

there are no hard limits, just protections against problems like infinite loops and memory leaks, where it crashes the process on purpose to avoid crashing the browser and the pc

forest drift
#

there were some javascript based games i used to play on chrome after flash died, now when i try play them a lot of them have come up with things like chrome no longer supports certain memory javascript or smt like that, generally they say to run the game on firefox

quartz kindle
#

@earnest phoenixbtw i dont recall if i've ever mentioned to you about the performance issues for the this keyword inside a Proxy object

quartz kindle
forest drift
earnest phoenix
forest drift
#

gimme a few min, ill try to find one of the games

quartz kindle
#

the only change is using this directly or putting this in a local var beforehand

#

this produces equal performance

#

but if you put it in a Proxy object, like any of these

#
let a = new Proxy(obj, {
    get(target, key, receiver) {
        return Reflect.get(target, key, receiver);
    }
})

let b = new Proxy(obj, {
    get(target, key, receiver) {
        return target[key];
    }
})

let c = new Proxy(obj, {
    get(target, key, receiver) {
        return target[key].bind(target);
    }
})

let d = new Proxy(obj, {
    get(target, key, receiver) {
        return obj[key];
    }
})

let e = new Proxy(obj, {
    get(target, key, receiver) {
        return obj[key].bind(obj);
    }
})
#

then the this variant is 50-100x slower

forest drift
#

oh wait nvm u were right, it was to do with the engine the games running on, its using renpy, its one of those timekilling anime decision making games etc, runs off renpy, apparently they dont render properly in google chrome v 100.0 and above

#

and now its going on to say that half of the time the game still runs if u have the console open??? wait so the console can influence an engines performance in some way even by being open?

quartz kindle
#

i havent heard of the renpy engine

earnest phoenix
# quartz kindle ```js let a = new Proxy(obj, { get(target, key, receiver) { return R...

Well there is actually logic behind this, the reason the direct usage of the this keyword is slower in case of proxies is because the this keyword kinda also depends on the proxy methods you provide to override the native behavior and work with the things it returns, which can significantly affect the performance, but I'm not exactly sure if this is the case with 50-100x slower performance but it might be

forest drift
#

https://www.renpy.org/

it seems like a kinda old engine hastily upgraded to run on newer systems, but thousands of old and new games still run on it

its a visual novel engine

quartz kindle
#

first two are the normal access

#

then the proxy accesses in pairs, this version, no this version

spark flint
#
server{

    listen 80;

    server_name http.capy.pics;

     location / {
        try_files /home/ubuntu/capy/$uri /home/ubuntu/capy/$uri.png @redirect;
    }
    location @redirect {
        return 301 https://capy.pics/;
    }
}```
always returns to `@redirect` ![wahhh](https://cdn.discordapp.com/emojis/690952466602262559.webp?size=128 "wahhh")
quartz kindle
#

and for some funny reason, the .bind() versions are the fastest

#

and the Reflect version is the slowest

forest drift
#

is there any way to successfully run javascript functions "simultaneously"

quartz kindle
forest drift
#

mkay, so in a sense its impossible to run it in parallel without using 'seperate' workers?

quartz kindle
#

yes because js is single threaded

forest drift
#

damn the day a multi threaded version of js is released someone will take over the world lol

quartz kindle
#

i believe the v8 devs said at some point it would be near impossible to accomplish that

earnest phoenix
quartz kindle
# earnest phoenix Interesting, also I love the one with just ***9***

this is the full script ```js
const obj = {
str: "a",
test1() {
for(let i = 0; i < 9999999; i++) {
this.str + this.str;
}
},
test2() {
let str = this.str;
for(let i = 0; i < 9999999; i++) {
str + str;
}
}
}

let a = new Proxy(obj, {
get(target, key, receiver) {
return Reflect.get(target, key, receiver);
}
})

let b = new Proxy(obj, {
get(target, key, receiver) {
return target[key];
}
})

let c = new Proxy(obj, {
get(target, key, receiver) {
return target[key].bind(target);
}
})

let d = new Proxy(obj, {
get(target, key, receiver) {
return obj[key];
}
})

let e = new Proxy(obj, {
get(target, key, receiver) {
return obj[key].bind(obj);
}
})

t = performance.now(); obj.test1(); console.log(performance.now() - t);
t = performance.now(); obj.test2(); console.log(performance.now() - t);

t = performance.now(); a.test1(); console.log(performance.now() - t);
t = performance.now(); a.test2(); console.log(performance.now() - t);

t = performance.now(); b.test1(); console.log(performance.now() - t);
t = performance.now(); b.test2(); console.log(performance.now() - t);

t = performance.now(); c.test1(); console.log(performance.now() - t);
t = performance.now(); c.test2(); console.log(performance.now() - t);

t = performance.now(); d.test1(); console.log(performance.now() - t);
t = performance.now(); d.test2(); console.log(performance.now() - t);

t = performance.now(); e.test1(); console.log(performance.now() - t);
t = performance.now(); e.test2(); console.log(performance.now() - t);

forest drift
#

so i guess you can only make the illusion of running parallel javascript, reality being its running on separate workers or worker threads?

forest drift
#

and thats why most people including me prefer to live in an illusion, so much better than reality

quartz kindle
#

its not much different from what other languages do, just that workers are more complex and more expensive for js

#

since they need an entire new engine environment

forest drift
quartz kindle
#

depends on the job

forest drift
#

so for something thats just registering things, it can just queue them up during a high and reduce that queue during a low, but for things that have to do smt instant on a large scale, its worth it?

quartz kindle
#

if the job is big enough that it blocks the main thread for more than a few ms, then yes it would be worth it

#

also if you have many jobs like that, its preferable to keep a thread always alive

#

instead of creating and destorying them

forest drift
#

so a project thats constantly getting an input that needs to be checked by pinging a server, you couldnt have it running while waiting for the ping to return so itd back up unless you had multiple workers running?

quartz kindle
#

i/o does not block js

#

files and network requests are not handled by js itself

#

so while js is waiting for a ping to return, its actually idle, not blocked

#

so it can run other things

forest drift
#

but for example

await dns.lookup("google.com");

depending on the latency could back it up?

earnest phoenix
quartz kindle
#

and the binded versions are also faster than the non binded versions for got knows why

quartz kindle
forest drift
#

so with something like a script that you input names into and it checks if any of 702 domain extension of that name exist, would take quite a while

forest drift
quartz kindle
#

check the cpu usage

#

if its not using 100% of one core, its not blocked, its idle

forest drift
#

hmm, so how would one un-idle it?

quartz kindle
#

awaiting promises does not block the whole program, it just pauses the execution of the current context

forest drift
#

so for example, this uses promises. All it does is check if google.* exists for any of the 702 domain extensions added

#

when monitoring it by the added console.log(hostname) in the dns.lookup, i noticed that certain domain extensions froze the entire script for upwards of 10seconds

#

most likely just my shoddy coding skills or ive missed smt

quartz kindle
#

hmm

#

well for dns.lookup specifically it has the following conditions:

#

Though the call to dns.lookup() will be asynchronous from JavaScript's perspective, it is implemented as a synchronous call to getaddrinfo(3) that runs on libuv's threadpool. This can have surprising negative performance implications for some applications, see the UV_THREADPOOL_SIZE documentation for more information.

forest drift
#

ok running it now it holds up for at most a second at certain points, so most likely wifi issues when i last tested it, but still a small noticable buffer on certain domain extensions

forest drift
quartz kindle
#

no you're not using it wrong, but your code could be greatly simplified

forest drift
#

i mean makes sense, im still a newbie to javascript

quartz kindle
#
const dns = require('dns');
const domainextensions = [...];

Promise.all(domainextensions.map(domain => new Promise(resolve => dns.lookup(`google.${domain}`, error => resolve({hostname, exists: !error}))))).then(listOfStatuses => console.log(listOfStatuses));
``` well technically its an exagerated one liner lol
quartz kindle
#

but using Promise.all is not a good idea when doing network requests

#

because it can be considered/confused with a DOS attack

#

basically you're flooding google with hundreds of requests at once

forest drift
#

;-;

quartz kindle
#

so a more correct approach would be this, even if slower ```js
const dns = require('dns');
const domainextensions = [...];
const results = [];

for(const domain of domainextensions) {
const test = await new Promise(resolve => dns.lookup(google.${domain}, error => resolve({hostname, exists: !error})));
results.push(test);
}

console.log(results);

forest drift
#

ah ok

#

so slower, but i dont need to worry about being put on a watchlist lol

quartz kindle
#

yeah

spark flint
#

oh for domain extensions use tlds package

#

i use it for domain scanning

quartz kindle
#

if performance becomes too bad, you can try grouping multiple requests together, for example 5-10 at a time

forest drift
#

so its entire documentation is

Usage

const tlds = require('tlds');

console.log(tlds);
//=> ['aaa', 'aarp', 'abarth', 'abb', 'abbott', 'abbvie', 'abc', ...]
#

dafuq am i meant to get from that

#

so like what does it do...

#

@spark flint

#

oh wait im dumb

spark flint
#

it just returns all possible tlds

forest drift
#

it gives a list of all domain extensiuons

#

yeah sorry its 1am, im slow XD

spark flint
#

yeah

#
const dns = require('dns');
const tlds = require('tlds');

const results = [];

for(const tld of tlds) {
  const test = await new Promise(resolve => dns.lookup(`google.${tld}`, error => resolve({hostname, exists: !error})));
  results.push(test);
}

console.log(results);

forest drift
#

i just went onto name.com or smt and just copied their domain list XD

spark flint
forest drift
#

cant remember the site

#

long story short it gave me 702 after i removed the non english alphabet ones

forest drift
#

and preferably not attempt a ddos attack accidentally XD]

spark flint
#

I use it for scam domain checking

#

lol

forest drift
#

i was working on at one point a bot thatd try to retrieve the websites code and check it for anything malicious and i mean it worked but missed 50% of the malicious code lmao

spark flint
#

best antiscam api

forest drift
#

so any malicious site has a 50/50 chance of bypassing lol

forest drift
quartz kindle
# spark flint bump

do you have a file.png in your /home/ubuntu/capy/ folder and you went to http.capy.pics/file.png?

spark flint
#

yeah

#

well i went to 404.png because thats deffo there

#

ay what

#

why does it work now I ask for help

#

wtf

forest drift
#

lol

quartz kindle
#

lel

spark flint
quartz kindle
#

you made http cats into http capybaras?

spark flint
#

time to add caching too

quartz kindle
#

lmao

spark flint
#

yeah

#

lmao

forest drift
#

and thats asking for help in a nutshell

quartz kindle
#

10/10

spark flint
#

made 65 capybaras

forest drift
#

its broken till you try to show someone

spark flint
earnest phoenix
#

When your issue gets resolved on it's own

forest drift
#

tho in most cases it works till u try to show it off

spark flint
#

i think its just CF caching too

earnest phoenix
spark flint
#

lmao

forest drift
spark flint
#

10 doesn't exist

forest drift
#

dafuq did i type

quartz kindle
forest drift
earnest phoenix
#

418 best HTTP code

forest drift
#

i give up

quartz kindle
spark flint
forest drift
#

ik i realised that after failing twice lol

#

so i managed to put together a basic ai that my friend talked to for an hour before realizing its an ai... now the problem is i dont know if i made a good ai or if my friends just oblivious

quartz kindle
#

he probably dumb

#

:^)

forest drift
#

eh i mean he spoke to a ended phone call for 2min before realizing it had ended just yesterday so i mean...

quartz kindle
#

xD

forest drift
#

i need a new friend, this ones broken

#

naa but hes that fun friend, the one u know u can talk to without it getting serious, a good dude to just chill and have a blast with

#

whats ur view on selfbots? like theyre bannable but still possible in v13

spark flint
#

bad

#

just don't self bot lmao

forest drift
#

but now comes the puncher, it depends on its usage lmao

spark flint
#

also for any anti-scam people, new scam name

forest drift
#

i laugh it was just a dude who liked emails

spark flint
#

lmao

#

its deffo a scam

#

the username matched API filters

#

wait no pfp

#

not username

forest drift
#

or again, a dude who loves emails a lot and uve just crushed his dreams of becoming an emailer

spark flint
#

💀

forest drift
#

lol

spark flint
earnest phoenix
#

Looks like they're about to kiss

spark flint
#

lmao

#

homies alright

forest drift
#

That one fateful day, the day I joined the nightmare of discord...

All I was was an email lover, ever since the first time my grandfather sent me an email, I've always been fascinated with them! What better to name and use as a profile picture for my discord account than an email! Both my love and social lively hood would be on the line but whatever, I loved it!

I had barely logged in before being banned... They accused me of horrible things, all because of my email love... Discord, a nightmare of email haters! I shall never step foot in that hellhole again

#

lol

earnest phoenix
#

Amazing story, cried at the end

forest drift
#

XD

#

how do u plead @spark flint? After crushing this poor childs dreams of being in love with an email?

spark flint
forest drift
#

I rest my case judge

#

he deserves to be locked up

#

bloomin' email hater

#

what a cruel man

spark flint
#

lol

round cove
#

Interesting API errors to see for one thing lmao.

lyric mountain
#

that's uh...a terrible thing to have

#

still

spark flint
#

Still braking TOS

#

Lmao watch ur discord account get termed

#

Still not a good thing to have

#

Why do you even share accounts

#

You’ll get banned on valid and too

#

Valorant

#

"You can't share your account or Login Credentials with anyone. You must keep your login credentials secret."

#

Yeah but you can’t really style it well on Disxord

quartz kindle
wheat mesa
#

no, very different

quartz kindle
spark flint
#

Lol

boreal iron
sharp geyser
quartz kindle
#

call the poopooleeheece

boreal iron
#

Meop meop

ancient nova
#

sooo any ideas why it still gets input from other people?

#

Istg that's how you do a collector I repeated what voltrex told me

earnest phoenix
ancient nova
earnest phoenix
#

The option is literally called filter...

#

For example you can do filter: f

ancient nova
#

okay that makes sense

#

thanks

sharp geyser
ancient nova
#

what is that?????

#

failed, reason: connect ENETUNREACH

#

that shit leaked my VPS's IPv6

lyric mountain
#

Error NETwork UNREACHable

#

means address could not be resolved

#

so u probably mistyped something

#

or the other side is closed to the world

earnest phoenix
#

Can you help me do this?

earnest phoenix
modern olive
earnest phoenix
#

You can also use Discord-RPC but it's deprecated, so it's recommended to use the GameSDK

modern olive
#

okay thank you very much

earnest phoenix
earnest phoenix
earnest phoenix
modern olive
earnest phoenix
#

Yes

modern olive
#

okay thanks

ancient nova
#

I wrote a script for rich presence that works on any platform even android

rigid maple
#

Can I trigger an event every time a message comes on youtube live streams? Or should I check periodically and check incoming messages in the meantime?

#

I guess I can't check incoming messages simultaneously

last bison
#

When i write interaction.component. I get this result

#

how do i pull the value

pine nova
#

interaction.component.value?

last bison
#

not working

pine nova
#

what does it say

last bison
#

but i will try again

pine nova
#

o is that an array?

#

of objects

#

if thats an array of objects

const d = array.find(data => {
  return data.label == "Dota2"
});
console.log(d.value)
last bison
#

there is no single option

pine nova
#

christmasthink wym

pine nova
last bison
#

i have 10 options

pine nova
#

yea?

last bison
#

how do i get the value of all

last bison
pine nova
last bison
#

interaction.component.forEach is not a function

pine nova
#

is interaction.component just an object or an array?

pale vessel
#

components

pine nova
#

💀

last bison
#

i am trying to make a react role system with select menu.

pine nova
#

hmm

last bison
#

actually prints the selection menu completely

pine nova
#

can u show the whole output

#

like just copy paste fr

last bison
pine nova
#

bruhga

#

just use forEach in interaction.component.options

last bison
#

okay

#

Thank you

#

my problem is solved

pine nova
split hazel
#

for each users realising it has a ton of overhead and there's no way to stop it other than setting some closure variable

median tulip
#

Hello

near stratus
#

Hello

vivid fulcrum
split hazel
#

no

#

too fucking slow

vivid fulcrum
#

i.e. the entirety of the node ecosystem

split hazel
#

yeah

#

if only @earnest phoenix told me how to unlock the tq compilation in node

earnest phoenix
split hazel
#

I can't read

#

I only read discord messages and code blocks

earnest phoenix
# split hazel I only read discord messages and code blocks

The Torque compiler is located at https://chromium.googlesource.com/v8/v8.git/+/refs/heads/main/src/torque/

You can have a look at https://v8.dev/docs/test on how to build the cctest executable to test out your Torque code, as well as compiling them

It's also pretty important to notice how Torque generates code (https://v8.dev/docs/torque#how-torque-generates-code)

split hazel
#

generates c++ same thing as assembly

split hazel
#

This python tutorial aims to teach you python as fast as possible. This python speed course will cover all the fundamentals of python and give you a quick overview of all of the main python features.

⭐️ Thanks to Simplilearn for sponsoring this video and giving you all a 10% discount on their Data Scientist Master's program by using the code: Y...

▶ Play video
thorn spruce
#

Someone know if in sql we can do a where on all column value like Where *=1 ?
In the facts i would get all column where the bit is at one

pine nova
#

or idk try adding * in bracket prolly not work

split hazel
#

do you mean do bitwise operations in where queries?

lyric mountain
#

no, they probably mean matching all columns against a value

#

like, if all columns are equal to something

#

ik in postgres u can, but idk what database it is

split hazel
#

thats just where x = y no?

lyric mountain
#

yes but for all columns at once

split hazel
#

cant you just do and and and and

lyric mountain
#

that'd be the sensible answer

#

tbh the true question here would be why they have a scenario where all columns hold the same value

#

IDs people? where IDs?

split hazel
#

yeah its a pretty common query type

#

for example if you store emails in a table and you want to only fetch emails that are archived or active

lyric mountain
#

but that wouldn't be comparing ALL columns to a single value

split hazel
#

oh all columns

#

no real reason then

thorn spruce
thorn spruce
#

That what i want or something which act like that

lyric mountain
#

mind to explain your exact scenario?

thorn spruce
#

Sure let me 15min time to i get back at home

thorn spruce
#

So as i said previously i have a tables as :

                CREATE TABLE `model_hl7` (
                    `idModel_hl7` int(8) NOT NULL PRIMARY KEY AUTO_INCREMENT,
                    `ACK` BIT NOT NULL DEFAULT 0,
                    `SRR_S06` BIT NOT NULL DEFAULT 0,
                    `SRR_S07` BIT NOT NULL DEFAULT 0,
                    `SRR_S08` BIT NOT NULL DEFAULT 0,
                   -- 300 mores bit  
                )ENGINE=InnoDb DEFAULT CHARSET=utf8;

I have ~350 column of bit type. but if every time i do a request like ```sql
SELECT * FROM tables

it's not very optimizing so its why i need to select ONLY column where the bit it as 1 but i won't do a request of 35000 line cause i have ~350 column
#
  • Nodejs/Javascript is going to cache all of them so it going to be bad
#

that why i said i need to made a where on value and not on specific column

lyric mountain
#

what in unholy fuck

#

why don't u just use a single bitfield column?

thorn spruce
#

cause its different types of events

#

i'm using them to create a Model

lyric mountain
#

with your current structure you're wasting 7 bits for each field

lyric mountain
thorn spruce
#

mysql set by default at 8 bits?

#

i thought it was like a boolean true / false

lyric mountain
#

any data must be represented by at least 8 bits

thorn spruce
#

okok

lyric mountain
#

booleans use 8 bits too

#

0000 0000 for false and 0000 0001 for true

thorn spruce
#

So how could I do it? properly

slender wagon
#

i gotta implement a error and message handler on my site

#

worked with ejs

#

any suggestion

lyric mountain
#

lemme check what's the biggest mysql integer type

#

ok bigint it is

#

first of all, do you need 150 fields?

#

what are they for?

thorn spruce
#

currently i have 353 event

lyric mountain
#

ok, what are they?

thorn spruce
#

so 353 fields

#

For my app i just need to know if the user is going to use them

#

So yes = true no = false

lyric mountain
#

ok, bigint has a size of 64 bits

#

that'd mean 6 columns

thorn spruce
#

so i have to make a function who's decoding the bits?

lyric mountain
#

not really, mysql has means to do bitwise ops

#

doing bitwise is basically treating a number as an array

#

0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000
this a bigint

thorn spruce
#

yep

lyric mountain
#

for bits it's always right to left, so first index would be the rightmost bit

#

to get it, you do (bits >> index) & 1

#

>> moves the bits to the right by specified number

#

so let's consider number 0100

#

if I do (0100 >> 3) it'll move the bits 3 places to the right, resulting in 01

#

when we do bits & 1 we're doing an AND operation to get bits that exists on both sides

#

so 01 & 1 (leftmost bits are irrelevant) will result in 1

#

which u can consider as true

split hazel
#

since mysql has a bit field it most likely means they automatically do this kind of thing in the background

lyric mountain
#

10 & 1 results in false, because first bit is false in one of the sides

split hazel
#

dont know tho

lyric mountain
#

although I'm a bit skeptical on letting mysql "handling" stuff

split hazel
#

but it would make sense since the smallest realistic type is a byte

thorn spruce
#

but how im supposed know the 64em bits equals to "DKT_848"

lyric mountain
#

you don't, you'll check if the index is 1 or 0

#

bitfields shouldn't be treated as a whole, they're just another form of array

#

an efficient array at that

#

you just need to map each event into an index

thorn spruce
#

okok that what i would know so with this now i'm not losing bits anymore

lyric mountain
#

you'll be wasting a few bits since the count isn't a power of 2

thorn spruce
#

yep

lyric mountain
#

31 bits to be exact