#development

1 messages · Page 171 of 1

neon leaf
#

following the long notation

#

eh fuck ips

#

I still need to somehow allow checking whether a subnet or ip is contained within a subnet

#

I have lost too many brain cells for that today though

#

provides an api for selfhosted language models

hidden gorge
#

Anyone know why my code is giving a 403 On axios.get

code:

app.get('/admin/dash', isAuthenticated, async (req, res) => {
    try {
        const response = await axios.get('https://games.roblox.com/v2/groups/15960731/games?accessFilter=1&limit=10&sortOrder=Asc', {
            headers: {
                'Accept': 'application/json'
            }
        });

        const games = response.data.data;

        res.render("panel/admin/dashboard", { user: req.user, games })
    } catch (error) {
        console.error(error);
        res.status(500).send("Error Fetching Game Data");
    }
})
sharp geyser
#

You are doing something wrong when fetching from whatever that is

#

Likely not giving an api key

#

Typically means the request body is wrong

hidden gorge
sharp geyser
#

Okay so it seems to be that the api is just down or something else

#

Its not a you issue

#

Even roblox's swagger ui returns a 403

hidden gorge
sharp geyser
#

and I used a group id that 100% has games

hidden gorge
sharp geyser
#

It says not authorized for me

hidden gorge
#

weird

sharp geyser
#

It is likely a roblox issue

hidden gorge
sharp geyser
#

I dont see anywhere that it asks for a api key

#

so you dont seem to be doing anything wrong

hidden gorge
#

its actually returing a 501 during testing on the site

sharp geyser
#

Yea

#

Roblox's api is just borked rn I guess

#

give it a day or two

#

they might fix it depending on how fast they are

hidden gorge
#

Seems i have found a working URL

sharp geyser
#

I am getting 500's and 403's on any one of their endpoints

hidden gorge
#

https://games.roblox.com/v2/groups/15960731/gamesV2?accessFilter=2&limit=10&sortOrder=Asc Returns a 200 status

sharp geyser
#

Odd

#

Anything that has a filter set to 1 returns a 500/400 code

#

anything higher returns a 200

hidden gorge
#

changed it to 2 and it fixed

#

4 returns a 501

sharp geyser
#

Ah wait its accessFilter

hidden gorge
#

YO IT WORKED

sharp geyser
#

I wonder if it means what I think

hidden gorge
#

it passed through auth and let me login it

sharp geyser
#

good

#

keep it at 2 it seems to work

hidden gorge
#

ok

hidden gorge
#

Cannot read properties of undefined (reading 'forEach')

sharp geyser
#

Show code

hidden gorge
#
      <div id="games" class="section">
                    <h2>Games</h2>
                    <% games.forEach(game => { %>
                        <div>
                            <p><strong>Name:</strong> <%= game.name %></p>
                            <p><strong>ID:</strong> <%= game.id %></p>
                            <p><strong>Description:</strong> <%= game.description %></p>
                        </div>
                    <% }); %>
                </div>
                
            </div>
sharp geyser
#

games is undefined

#

make sure the data is being passed correctly to ejs

#

also make sure the data is what you think it is

hidden gorge
#

req.games?

sharp geyser
#

most likely

#

unless you have something called "games"

hidden gorge
#

ok

sharp geyser
#

like a variable or smth

hidden gorge
sharp geyser
#

oh

#

console log games

#

make sure its not undefined

hidden gorge
#

defined it gonna test now

#

ok games passes as undefined

sharp geyser
#

What is response

#

is it the axios.get?

hidden gorge
sharp geyser
#

nice you figured it out

hidden gorge
#

It was response.data.data

sharp geyser
#

Yep

#

axios nesting their objects

hidden gorge
#

lol

sharp geyser
#

typical axios

hidden gorge
#

yep

sharp geyser
#

which is why I use native fetch now

hidden gorge
wheat mesa
#

Or just don’t use js 😏

sharp geyser
#

or dont listen to waffle

#

:)

wheat mesa
#

Go is nice for building APIs

#

Much better experience than express

sharp geyser
#

yea

#

I enjoyed go ages ago

#

but no need now since i dont really make apis

spark flint
#

or auth cookie

stone bloom
#

Does anyone know how I can make the commands the same as the image, so that when someone clicks the command appears written?

spark flint
#

</commandname:commandid>

stone bloom
#

What would the commandid be like? How do I get this?

spark flint
#

</snipe message:874407167594213394>

#

</snipe message:874407167594213394>

#

oop doesn't work here

stone bloom
#

hahah

spark flint
hidden gorge
stone bloom
#

@spark flint

const discord = require("discord.js");
const { readdirSync } = require('fs');
const path = require('path');

module.exports = {
    data: new discord.SlashCommandBuilder()
        .setName("ajuda")
        .setDescription("🔨 | Veja todos os comandos disponíveis"),

    async execute(interaction) {
        const scriptDir = path.resolve(__dirname);
        const commandDir = path.join(scriptDir);
        const commandFolders = readdirSync(commandDir);
        
        const embed = new discord.EmbedBuilder()
            .setTitle(':redewhosh: Comandos')
            .setDescription(`
Adicione \`/\` antes de qualquer comando
            `)
            .setColor('#ffd700');

        let commandsDisplayed = 0;

        for (const folder of commandFolders) {
            const module = require(path.join(commandDir, folder));

            if (module.data instanceof discord.SlashCommandBuilder) {
                const commandData = module.data.toJSON();

                if (commandsDisplayed < 25) {
                    embed.addFields({ name: `/${commandData.name}`, value: `\`\`\`${commandData.description}\`\`\``, inline: true });
                    commandsDisplayed++;
                } else {
                    break;
                }
            }
        }

        interaction.reply({ embeds: [embed] });
    },
};

How do I implement it here? Or would I have to do a manual for each command?

spark flint
#

It won’t as you don’t have the command ID there

#

You’ll have to store the commands somewhere when you register them

#

I’m heading offline now so can’t help any further

stone bloom
#

tnks

deft wolf
#

You can also right-click on the dark box after entering the command above chat textbox and copy the id

#

Of course, it only works on PC

broken pawn
#

hello so im using @top-gg/sdk but for some reason its only picking up on my name and when others vote its not doing anything even though the test works and myself voting works

broken pawn
#

This only seems to wanna console log if its a test or myself voting as soon as its someone else it fails

const express = require('express');
const Topgg = require('@top-gg/sdk');

/**
 * @param {Client} client
 */
module.exports = async (client) => {
    const app = express(); // Your express app
    const webhook = new Topgg.Webhook('topGG');

    app.post(
        '/votebot',
        webhook.listener(async (vote) => {
            console.log(vote);            
        }),
    );

    app.post(
        '/voteserver',
        webhook.listener(async (vote) => {
            console.log(vote);
        }),
    );

    app.listen(9091);
};
broken pawn
#

this is hurting my head 😦

earnest phoenix
quartz kindle
#

im having some weird issue, i got access to a client's brand new hetzner vps to set up a server for them, and i cant seem to get it work

#

i went into the hetzner panel, added a firewall to the instance, allowed port 3000, ssh'ed into it, installed UFW, allowed port 3000

#

and i still cant access the server thats running there via ip:port

#

just says "couldnt connect to server"

#

am i missing something? i dont remember doing anything else on my own server to make it work, and this one just refuses to work

peak drum
#

lol

#

just remove the firewall on the hetzner vps

#

and only use ufw

#

maybe that works

#

and make sure it works if all firewalls are disabled

earnest phoenix
peak drum
#

^ xD

earnest phoenix
#

btw use pterodactyl its gonna make your client's life easier

quartz kindle
earnest phoenix
quartz kindle
#

i guess im just gonna open a suport ticket with them lol

wheat mesa
#

(Tim is also a wizard and does not need a pterodactyl interface to set up a server)

sharp geyser
broken pawn
neon leaf
flat copper
#

is there any way to autoplay the video without mute in next js

magic sonnet
neon leaf
lyric mountain
#

good thing they enforced that

sharp geyser
lyric mountain
#

I'm fine and ya

sharp geyser
#

pretty good myself

#

relearning typescript but properly this time

#

Not gonna bs my way through it trollface

lyric mountain
#

lmao gl

sharp geyser
#

thanks man

#

So looking at this code I notice that before giving anything to the function its type is unknown and never, what exactly do those mean? I can already tell it says such because I have yet to supply it a type for it to know what to look for in the second argument as its constrained to only grab what exists in the object provided. I just have never seen those keywords used in ts before.

lyric mountain
#

tf never

#

unknown is likely because a type wasn't given

#

idfk what never is supposed to be tho

wheat mesa
#

You haven’t supplied a type to either of them

sharp geyser
#

Thats what I fugured

#

but never heard of never

#

I know that waffle 😭

wheat mesa
#

Never is just compiler shenanigans that aren’t used in many places

sharp geyser
#

I was just confused at the sight of seeing never

wheat mesa
#

It’s saying “this type is never known because it depends on the type of the first type you passed in which is unknown because you haven’t passed it in”

sharp geyser
#

Also just learned you can constrain generic types by making an interface and extending like that

#

I always knew it was possible

#

but didn't know it was a constraint

wheat mesa
#

If you like type systems, rust has an extremely interesting type system as well

#

Very powerful

sharp geyser
#

Let me first understand ts please

#

One of the reasons I stopped programming is because I was going no where with it and I didn't really understand what I was doing,

wheat mesa
#

Type systems and type theory is extremely interesting

#

Lots of powerful things you can do with it

#

Rust has an awesome type system because it took the mistakes of its predecessors (java, C++, C, etc) and improved greatly upon them

sharp geyser
#

I want to fully understand typescript as much as possible

#

Though in actuallity I wont ever use typescript for what I want to do so shrug

wheat mesa
#

What do you want to do

sharp geyser
#

I want to use programming for robotics

#

Use it alongside engineering

lyric mountain
#

that'd be C no?

sharp geyser
#

Please dont tell me that

#

I've seen what C code looks like

#

😭

lyric mountain
#

ts/js are way too slow and big for robotics

sharp geyser
#

I know

#

I just wanted to step back into programming with familiar grounds

#

But while my mind is still somewhat fresh I feel it'd be a waste of time

lyric mountain
#

C isn't thaaaat bad tbh, people are the ones to make it an unreadable mess

sharp geyser
#

C is wayyyyyy into the unknown for me

lyric mountain
#

it's closer than u think

sharp geyser
#

If C is what I have to learn I have no idea where to even start to do it properly

lyric mountain
#

start with hello world, then console calculator, then smth else

sharp geyser
#

I don't want to make the same mistakes with another lang as I did with js

lyric mountain
#

like, it's one of the starter languages used in colleges

#

if you follow a course you can understand it pretty quickly

#

ofc you'll miss most of js' syntax candy, but nothing prevents you from implementing it yourself

sharp geyser
#

I wonder if there is any public college courses for it

#

I know sometimes colleges release their coursework on outdated courses

#

Now to be clear is Objective-C something entirely different?

#

or is it another name

lyric mountain
#

yes, really different

lyric mountain
sharp geyser
#

Oh okay

lyric mountain
#

just start slowly, dont try to jump into complex projects yet

sharp geyser
#

Thats the mistake I did with js

#

I jumped into trying to make some elaborate discord bot

lyric mountain
#

also remember C has no oop

sharp geyser
#

Didn't know shit

#

C is entirely functional is it not?

lyric mountain
#

yes

#

you can ofc implement oop yourself if you want

#

which is what cpp did

#

but for robotics you'll not use oop anyway

sharp geyser
#

Yea

#

Also when it comes to robotics I am also talking about using like Machine Learning and sensors, cameras, etc

wheat mesa
#

It’s so simplistic, but that also comes at a cost of being tedious to work with sometimes

sharp geyser
#

When I get home ima follow those codeacademy courses

#

Ima try my hand at it

#

Hopefully I can accomplish my goal with it

wheat mesa
#

Tbh C is just pointers, loops, casts, and allocation

#

Can pretty much do anything with it after you know those

sharp geyser
#

I see

#

Sounds like it will be fun

#

And once I know C I know all other languages /s

wheat mesa
#

Since C is so simple though, you’ll be causing UB in a lot of places

#

That’s the hardest part of C, debugging

sharp geyser
#

Looks like ima finally learn how to use a debugger Thumbsup

vivid fulcrum
#

c lets you do whatever but for that exact reason it's so easy to shoot yourself in the foot

#

i'll stay over here with my high level langs 🙃

sharp geyser
#

Lmao

#

Also hello cry

#

haven't seen you in a while

radiant kraken
#

you just have to know how the computer stores bytes in the memory, and that's pretty much the basics onesieKEKW

#

C is good if you want full control on everything

#

i can help you if you have any questions about C poggythumbsup

surreal sage
#

what sheet protection?

south kiln
#

can i get the code for take my bot vote count

sharp geyser
#

We aren't in the business of doing it for you

earnest phoenix
# sharp geyser C is wayyyyyy into the unknown for me

I would really recommend that you learn C++ instead of just plain old simple C if you ever do so, C is extremely basic and most of the time you'll spending a lot of your time writing stuff from scratch that should've already been there

#

Once you know C++, you basically know 95% of C

#

(Difference being the absence of some keywords, semantic behaviors, rule changes, and similar, which is not much)

sharp geyser
#

I tried learncpp before but I don’t learn well by simply reading

#

I lose focus

earnest phoenix
sharp geyser
#

I know it’s an amazing resource

#

But reading is just not the best way for me to learn

#

Putting it into practice is the best way but in my experience with learncpp it’s hard to do so as it gives you code examples that already work

#

It’d be nicer if they included examples that obviously error but you have to fix with the knowledge from that chapter or along the way

earnest phoenix
#

They have questions in the bottom of every page

sharp geyser
#

I’ve never noticed em

earnest phoenix
#

Telling you to fix things or solve stuff related to the current page

sharp geyser
#

I see

#

I’ll check it out after I wake up

#

For now I sleep

radiant kraken
#

C++ may have more features built-in yes, but it's a literal hell

earnest phoenix
#

Not at all

#

C++ just provides a lot more language and standard library features but you don't have to use them, it's not forcing you to use everything, it's way better than writing everything yourself from scratch

radiant kraken
earnest phoenix
# radiant kraken it's learning curve is quite steep imo, it's also hell to do things like buildin...

Depends on the person, there are lots of incredible learning resources for C++ that are very easy to understand and follow (e.g. https://learncpp.com/)

Building it is the easiest part, making a program cross-platform is also not so hard and can vary depending on what dependencies/libraries you use (same case in Rust)

Installing, setting, and linking third-party libraries aren't hard if you use an actually good/smart build system, such as CMake, gn, Meson, etc etc

lament rock
#

What should I name this abomination

#

JSON has application/json, but I wanna be haha funny

#

Forgot to showcase that it does support Arrays and doesn't have a max depth. Also supports circular references

radiant kraken
#

application/buttons

lament rock
#

idk if I like that since sure it is used for Discord buttons, but I'm gonna use it for more should the need ever arise because of the fact it can encode BigInts and circular references

pale vessel
#

tinyjson or something

radiant kraken
lament rock
#

I also tried it with Discord buttons and it didn't work

deft wolf
#

Tyson

pale vessel
#

if its not bson it must be cson /s

#

name it kson for the memes

lament rock
#

what does the k mean

pale vessel
#

it's a youtuber/vtuber name

lament rock
#

idk them

radiant kraken
#

what does yours do to optimize size? @lament rock

#

besides removing things that makes a stringified JSON readable (e.g: ",")

lament rock
#

removes extraneous characters like strings are just a single double quotes and the character to delimit entries is the null character.
Some constant values are replaced by single character values like null is n and undefined is v. booleans are f and t
keys dont have their double quotes

#

the downside is that nowhere in the entire Object can the null character appear

sage bobcat
#

One message removed from a suspended account.

neon leaf
#

application/jsonn't

#

does it work with arrays

lament rock
#

I thought about also supporting Sets and Maps, but other languages don't have Sets or Maps

neon leaf
#

2d arrays too?

lament rock
#

Yup

#

no depth limit except the stack call size limit

neon leaf
#

how does [['💯','💻','🔐'],['💯','💻','🔐'],['💯','💻','🔐']] look

lament rock
neon leaf
#

nice

radiant kraken
lament rock
#

Tho this character is used so infrequently that I don't really care

radiant kraken
#

icic

#

how does it escape characters?

#

like what if i try btn.encode(['"', '\'', '[', ']'])

lament rock
#

Haven't tested

#

The decoder has a few issues I'm working on

queen needle
#

I'm a bit dumb but what is it doing?

lament rock
#

The intention is to encode info into discord button custom IDs. Space is everything

#

100 characters max

queen needle
#

Ohh that's awesome

lament rock
#

In the future, I might use it for other stuff

neon leaf
radiant kraken
#

honestly javascript generators are so underused

#

and overlooked

neon leaf
#

❤️

sharp geyser
#

Honestly forgot you can even await interators

radiant burrow
#

I tried hosting a second (single server) bot on my digital ocean droplet, and that did not go over well. I'm considering switching hosts, and as someone who's not great about servers and hosting I have two questions:

  • I feel like I see DO get clowned on a little. Is it a not great host?
  • I was looking and found pebble host. Does anyone have experience with that? It seems like a pretty good price and nice that they're actually made for discord bot hosting.
neon leaf
deft wolf
#

I have a mixed opinion about such hosting

radiant burrow
#

oh hey that's way better than some discord bot hosts ive seen haha

neon leaf
deft wolf
#

They are cheap as hell

neon leaf
deft wolf
#

And good tbh

#

I had 1 issue for like 5-6 months

radiant burrow
#

yeah ill look around for good vps' to host on, thanks for the tip

#

that eu site isn't loading for me but ill find some good ones im sure

spark flint
#

pebble is meh

radiant burrow
spark flint
#

mainenance

radiant burrow
#

oh interesting

#

but yeah these vps plans seem pretty good so ill have to figure out how to migrate them

neon leaf
#

llama2 moment```>>> hi
Hello! How can I help you today?

whats 69*69
The result of 69 multiplied by 69 is:

69 x 69 = 4761

wrong
My apologies! The correct answer is:

69 x 69 = 4769```

radiant burrow
#

thx again for the help bradyd5Salute

deft wolf
#

It's worth the effort. Once you learn how to use and set up a VPS, you will be able to do it from memory

radiant burrow
#

yeah it was mostly just transfering all the packages i use

#

like its not that many but it was a proccess for me to get them all lol

surreal sage
#

how do i give a user on ubuntu full access to a drive

#

cuz im using plex

#

and it cant create folders, delete anything

#

"/media/hdd2/Plex" user "plex"

#

sudo chown -R plex:plex /media/hdd2/Plex "Operation not permitted"

lament rock
#

You may need to be logged into root to chown

surreal sage
#

I am

lament rock
#

Never heard of an instance where root couldnt do something

#

lol

surreal sage
#

it's a mounted drive

plain coral
#

guys, who help cloduflare SSL use hestiacp please?

lyric mountain
#

also yeah, "made for bot hosting" is basically seilling snake oil, bots are just regular programs that run 24/7, nothing special in it

#

anything that claims to be special for that purpose is just trying to add value to their prices

surreal sage
#

(unless it's your own servers and you want a nice dash)

digital swan
#

how come you can get a contabo vps for so cheap compared to digitalocean/vultr for the same memory? do they just massively cheap out on cpu or oversell or what

deft wolf
#

Actually, it's interesting that the cheapest VPS come from Germany. There are probably no cheaper ones in Europe than German ones

#

Datalix, contabo and hetzner look like totally German hosting

neon leaf
#

Frankfurt is just really cheap for servers

#

And hetzner is cheap cuz they have their own dc

#

Datalix is good for kvm, hetzner for dedi

surreal sage
sour stream
#

guys i need help

#

when i used this code for embed is give me this error

#

embed code : const { Client, GatewayIntentBits, MessageEmbed } = require('discord.js');

#

error: const { Client, GatewayIntentBits, MessageEmbed } = require('discord.js');

SyntaxError: Identifier 'Client' has already been declared

wheat mesa
#

You’re using Client somewhere before that

sour stream
#

yeah

wheat mesa
#

Imports should be at the top of your file always

sour stream
#

so what i do ?

#

i do random name ?

wheat mesa
#

Can you show more code

#

That line alone doesn’t really have much to do with your error

#

You’ve defined Client somewhere above that line

sour stream
wheat mesa
#

Yeah you see how you have multiple Client definitions

#

You can’t do that

sour stream
#

so i cant do embed ?

wheat mesa
#

Just replace the first line with your 4th line

#

That’ll fix it

sour stream
#

wym

#

like

wheat mesa
#

Erase your first line of code there

sour stream
#

Client = client ?

#

or like

#

client1

wheat mesa
#

Then put the 4th line in its place

#

Actually just erase the first line entirely

sour stream
#
const { Client, GatewayIntentBits, MessageEmbed} = require('discord.js');```
#

here

#

edit it

wheat mesa
#

I’m not going to spoonfeed you code

sour stream
#

and give me i t back cuz i dont know what you mean

wheat mesa
#

I literally just spoonfed you the solution

deft wolf
#

Delete first line of your code

wheat mesa
#

Literally just delete the first line of code in that file

#

That will fix your issue

sour stream
#

ok 1 sec

neon leaf
sour stream
#

?

#

@wheat mesa @deft wolf

deft wolf
#

First line

#

Entire line

sour stream
#

const ?

deft wolf
#

Not first letter of Client

sour stream
#

of what ?

#

gateway ?

wheat mesa
#

my lord

strong python
#

💀

wheat mesa
#

Go to the first line of code

deft wolf
#

Delete this line

wheat mesa
#

And hold your backspace key

#

Until it’s gone

sour stream
#

delete

neon leaf
sour stream
#

done

wheat mesa
neon leaf
sour stream
#

what now

#

@wheat mesa

wheat mesa
#

That was the solution

#

That is the entire solution for that issue

#

You don’t need to re-import things when you’ve already imported them

sour stream
#

hello

#

but is still error

#

i runed it

wheat mesa
#

What’s the error

deft wolf
#

What error

sour stream
#

const Client = new Client({ intents: [GatewayIntentBits.Guilds] });
^

SyntaxError: Identifier 'Client' has already been declared

#

again

wheat mesa
#

🤦‍♂️

sour stream
wheat mesa
#

Rename that variable to be client = new Client

neon leaf
wheat mesa
#

Client is a class, you should not be naming variables the same way classes are named

wheat mesa
sour stream
#

const { NewClient, GatewayIntentBits, MessageEmbed} = require('discord.js');

#

?

wheat mesa
#

dude

neon leaf
#

...

wheat mesa
#

Please learn javascript before making a bot

sour stream
#

bro i dont you mean guys

deft wolf
wheat mesa
#

This is why you need to learn the language before doing projects in it

sour stream
#

just tell me

wheat mesa
#

Look up “how to use require in javascript”

#

It’ll solve all of your issues here

neon leaf
wheat mesa
#

We don’t spoonfeed code here, as if we did, you wouldn’t learn anything and just copy paste it

#

We only usually give code itself if we know you understand what it does

sour stream
#

bro tell pls

#

just tell or

#

ss

#

do like "change name of ad

#

like that

wheat mesa
#

No

#

I’m not going to give you code

deft wolf
#

But he wrote you what to do, just do it

sour stream
#

bro not code

wheat mesa
#

You’re just going to copy paste it and someone else is going to end up writing your bot for you

sour stream
#

omg like tell

wheat mesa
#

I did tell you

#

3 or 4 times now

sour stream
#

bro i dont know what you mean

wheat mesa
#

I even literally gave you code which I’m not meant to do

#

This is why I always recommend learning js (or whatever language you prefer) before writing a bot in it

sour stream
wheat mesa
#

especially if it’s your first language

#

no

#

You’re just guessing at this point

strong python
#

can we post links here?

sour stream
#

bro what i do

surreal sage
#

known sites only plz

wheat mesa
#

It would take you 5 minutes to look up “how to use require in javascript” and read a tutorial

sour stream
#

i did

strong python
wheat mesa
#

You obviously did not

#

If you did, you would not have this issue

sour stream
#

alr

wheat mesa
#

Your require was fine at first, you’re just throwing random things into it now

#

Your issue lies within the line that says const Client = new Client({…});

#

Try to figure out what’s wrong with that line

green kestrel
neon leaf
#

yes

green kestrel
#

which language/integration you use?

neon leaf
#

nodejs, @sentry/node

green kestrel
#

ah, cool

#

i just had a total pain in the ass day or so trying to make it work in native C mode

#

their C lib is kinda shockingly bad

#

do you do self hosted sentry?

neon leaf
#

yes

green kestrel
#

ah, same, do you have the option performance -> queries? i dont 😦

#

im wondering if they just didnt add it to the open source version yet

green kestrel
#

yeah thats a shame, its really cool... i was using it on cloud instance and got all my instrumentation set up for it, to find it doesnt exist yet in self hosted, but we can hope 😄

neon leaf
#

I think im gonna setup sentry on my crontabs that run every 3 seconds just because I can 🙂

green kestrel
#

to have something email you when your crons are missed is just chefs huge kiss

#

out of curiosity what do you run every 3 secs lol

neon leaf
#

checking pending reminders / giveaways to be sent

green kestrel
#

seems like something most people would do in the bot with a timer

neon leaf
#

eh, reminders can last very long

#

so id rather have it in the db

green kestrel
#

no love for async?

#

or you mean theyre far ahead

neon leaf
#

some are in 2025

green kestrel
#

ah lol

#

i also use cron jobs for similar stuff but mine are never more than 24h ahead and it just signals the bot process to do something

#

i check them once per minute

neon leaf
#

ill prob have to do 1/sec crons soon

#

or maybe even faster

#

or I have to develop something else

#

maybe an internal api

#

for dashboard to talk to bot instances

#

I think api would be better

queen needle
#

cron + internal timer?

neon leaf
#

?

queen needle
#

what if you did a cron that ran like once every hour perse and the reminders that'd go off in that hour are added to an interval timer instead of checking cron every 1/s

digital swan
#

thats what i do

#

way better than checking database every 3 seconds

neon leaf
#

also uh my db ping is 0.4ms

lyric mountain
#

then just use the cron plugin and have the database itself notify your program

#

you can also preemptively execute pancake's suggestion when you start the bot, that way you'll never miss the reminders for that hour

green kestrel
#

i use mysql

#

"mysql was good enough for your grandad and it was good enough for his grandad, its good enough for me and it'll be good enough for you youngin, i dont want to hear about no mongos!" kekeke

lyric mountain
#

then just do pancake suggestion

#

start a hourly cronjob for scheduling reminders that'll happen within that hour

#

then also call that function when you start the bot, making it run at least once

magic sonnet
#

@neon leaf fix your cat sir

#

duck

#

and dog

lament rock
#

I was tired yesterday, sorry. Also was messing with the code a bit so I have a refreshed understanding

#

Will escape null characters to support them in keys and values

lament rock
#

I can always change the delimiter

#

what would you recommend

lyric mountain
#

There are some control characters at the first 32 ascii entries

#

Tho most of them will make that serialized format unsafe for OTW transfer

#

escape character would probably be the safest way

lament rock
#

I theoretically could use any character

lyric mountain
#

There's \u001E, never saw it used but idk

#

Which is a record separator control character

#

Those characters are usually for serial communication, but I doubt anyone would send a fuckin json through one

magic sonnet
#

@neon leaf fix my car

neon leaf
#

internal api done 🔥

#
import axios from "axios"
import env from "@/globals/env"
import { Client } from "discord.js"

/**
 * Execute Code on a Bot Master
 * @since 1.40.0
*/ export async function execute<Return>(serverId: string, code: (client: Client<true>, server: string) => Return): Promise<Return> {
    if (!env.INTERNAL_API_LIST) throw new Error('No API Server found for the requested server')
    let serverURL: string | null = null

    const results = await Promise.all(env.INTERNAL_API_LIST.map((api) => axios.get<{ success: true, data: boolean }>(`${api}/has/${serverId}`)))

    for (let i = 0; i < results.length; i++) {
        if (!results[i].data.data) continue

        serverURL = env.INTERNAL_API_LIST[i]
        break
    }

    if (!serverURL) throw new Error('No API Server found for the requested server')

    const result = await axios.post<{ success: true, data: Return }>(serverURL, {
        code: `async function main() { return (${code.toString()})(client, '${serverId}') }`
    })

    return result.data.data
}```
#

(yes its in an internal network so no outside access to the direct endpoints)

magic sonnet
#

Imagine

sharp geyser
#

What IDE should I use for C++?

neon leaf
#

paper & pen

#

veri good

sharp geyser
#

oh thanks :)

#

While I am at it, let me write the C++ compiler on pen an paper

magic sonnet
#

No

#

Use notebook and pencil sir

sharp geyser
#

I would use Visual Studio but that shit is a pain

pale vessel
sharp geyser
#

See that would be my go to

#

but my license ran out and not trying to pay that price

pale vessel
#

and you're not in school?

sharp geyser
#

Nope

#

I graduated

pale vessel
#

i mean college/uni

sharp geyser
#

Not yet

#

Still looking at what college I want to go to

pale vessel
#

u can always try EAP

#

EAP builds are free

sharp geyser
#

EAP?

pale vessel
sharp geyser
#

I see

#

Honestly the license isn't that much

#

only 10$

#

I thought it was way higher

earnest phoenix
sharp geyser
#

Also I only ended up having to pay 5.94

#

40% discount for having a student license previously

pale vessel
#

what a steal

earnest phoenix
#

That's very good maichi_pat_DNS

sharp geyser
#

Yessir!

#

Also how does one install clang again thonk

magic sonnet
#

If I use water to clean my pc's harddrive, will this fix all problems with my pc?

deft wolf
#

Don't forget about soap

magic sonnet
#

Okay

sharp geyser
#

yea

magic sonnet
#

Windex is good?

deft wolf
#

You have to "clean" the disk and it can't be done with just water

magic sonnet
#

Or bar of soap?

earnest phoenix
# sharp geyser yea

Go to https://releases.llvm.org/ and click on the "download" button of the latest version (in this case 17.0.4), it'll take you to the GitHub release page, you need to download either the win32.exe if you have a 32-bit PC, or win64.exe if you have a 64-bit PC, and then run it as Administrator

magic sonnet
#

I have x86 bit

sharp geyser
#

Okay thanks

earnest phoenix
#

It'll bring up an configuration and installation window, make sure to choose "Add to PATH on all users" (or current user if you want)

radiant kraken
#

@earnest phoenix

earnest phoenix
#

@radiant kraken

sharp geyser
#

@earnest phoenix @radiant kraken

earnest phoenix
#

@sharp geyser

radiant kraken
sharp geyser
#

Also in regards to C++ is it a functional language or is it a mix of functional an oop. So far I have yet to see anything corresponding to normal oop behavior

earnest phoenix
radiant kraken
#

plus Functional and Procedural

sharp geyser
#

What does multi-paradigm mean?

radiant kraken
#

what i said

magic sonnet
#

This what it mean sir

sharp geyser
#

Hey Dusten

#

Kindly go away :)

#

You are not contributing to the conversation in a positive way

radiant kraken
earnest phoenix
# sharp geyser What does multi-paradigm mean?

Basically programming languages that support multiple programming styles, concepts, or such, such as Object-Oriented Programming (OOP), Functional, Procedural, Imperative, Declarative, etc etc, like nully said

sharp geyser
#

Ah I see

#

Also I understood what nully said

#

just didn't know the exact meaning of multi-paradigm

#

:p

earnest phoenix
#

Oh alright

sharp geyser
#

Thanks both of you for your explanations

radiant kraken
#

npnp

earnest phoenix
earnest phoenix
sharp geyser
#

Also seems like I am not configuring clang properly in clion

sharp geyser
#

Yea, but I can't seem to remember which clang files to use

#

iirc it was clang.exe for the C compiler and clang++.exe for the C++ compiler

#

but it runs into cmake errors

earnest phoenix
#

What errors?

sharp geyser
#
-- The C compiler identification is Clang 17.0.4 with GNU-like command-line
-- The CXX compiler identification is Clang 17.0.4 with GNU-like command-line
CMake Error at C:/Program Files/JetBrains/CLion 2023.2.2/bin/cmake/win/x64/share/cmake-3.26/Modules/Platform/Windows-Clang.cmake:135 (enable_language):
  No CMAKE_RC_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "RC" or the CMake cache entry CMAKE_RC_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.
Call Stack (most recent call first):
  C:/Program Files/JetBrains/CLion 2023.2.2/bin/cmake/win/x64/share/cmake-3.26/Modules/Platform/Windows-Clang.cmake:244 (__windows_compiler_clang_gnu)
  C:/Program Files/JetBrains/CLion 2023.2.2/bin/cmake/win/x64/share/cmake-3.26/Modules/Platform/Windows-Clang.cmake:262 (__windows_compiler_clang_base)
  C:/Program Files/JetBrains/CLion 2023.2.2/bin/cmake/win/x64/share/cmake-3.26/Modules/Platform/Windows-Clang-C.cmake:2 (__windows_compiler_clang)
  C:/Program Files/JetBrains/CLion 2023.2.2/bin/cmake/win/x64/share/cmake-3.26/Modules/CMakeCInformation.cmake:48 (include)
  CMakeLists.txt:2 (project)


-- Configuring incomplete, errors occurred!

Error code: 1

Oh right its the rc shit again

#

😩

earnest phoenix
#

Oh no KEKW

sharp geyser
#

Man its been so long since I solved this issue

#

I've used C++ with clang on this pc before

#

So whats up now

earnest phoenix
#

You need to install the Windows SDK, that's where the RC compiler is

sharp geyser
#

LUCKILY

#

I think I can install the Windows 11 SDK via Visual Studio Installer

#

:D

#

I pray and hope to god

sharp geyser
earnest phoenix
sharp geyser
#

I dont even remember where it is

earnest phoenix
#

Well you can try to see if it already works

sharp geyser
#

Same error

earnest phoenix
sharp geyser
#

Well now I just have a weird build error where it says it can't find rules.ninja

#
====================[ Build | LearningCPP | Debug ]=============================
"C:\Program Files\JetBrains\CLion 2023.2.2\bin\cmake\win\x64\bin\cmake.exe" --build C:\Dev\LearningCPP\cmake-build-debug --target LearningCPP -j 18
ninja: error: build.ninja:35: loading 'CMakeFiles/rules.ninja': The system cannot find the file specified.

include CMakeFiles/rules.ninja
                              ^ near here
earnest phoenix
#

Your build configuration seems to be using the Ninja build file generator, try changing it

sharp geyser
#

I don't know to what

#

This is my second time using clang and I dont even remember my config last time

sharp geyser
#

Yes I know

#

I just don't have any clue what to actually set it to

#

as only ninja is the option

#

Solved the issue

#

All I did was delete CMakeFiles and CMakeCache and rebuilt cmake

#

Runs fine now

#

Good ol chatgpt

earnest phoenix
sharp geyser
#

Also noticed clang-tidy is a thing

#

is that like C++ prettier

earnest phoenix
#

It's a linter

sharp geyser
#

I see

earnest phoenix
#

Clang-Format is the formatter

sharp geyser
#

Should I get in the habit of using clang-tidy?

#

or is it not really needed

earnest phoenix
#

CLion already leverages clangd powered by Clang Static Analyzer (CSA), which is what Clang-Tidy uses as well so you don't need to

sharp geyser
#

Oh cool

#

Well back to learning C++

#

chatgpt can teach me :)

sharp geyser
radiant kraken
sharp geyser
#

I was joking

radiant kraken
#

ChatGPT is not 100% reliable

sharp geyser
#

But it did introduce me to something interesting

#

I thought about copying a class from it and it introduced me to const

#

No idea what it is though

radiant kraken
sharp geyser
#

I see

#

Is it good to use it then?

radiant kraken
#

ye

#
thing() const {
  this->b = 2; // bad
}
sharp geyser
#

So does this tie into mutable/immutable terminology or am I thinking about this all wrong

radiant kraken
#

yes

#

i always spam const noexcept everywhere sdTroll @earnest phoenix

sharp geyser
#

Also does classes in C++ have the concept of constructors?

radiant kraken
#

yes

sharp geyser
#

or is that what public: is?

radiant kraken
#

thats a section for public properties and functions/methods

sharp geyser
#

How do you define a constructor in c++ then?

radiant kraken
#
class Misty {
public:
  int a;
  Misty() {
    this->a = 69;
  }
}```
sharp geyser
#

Ah

radiant kraken
#
Misty misty;
cout << misty.a;
#

if your constructor has arguments then its ```cpp
Misty misty(a, b, c);

sharp geyser
#
#include <iostream>

class Rectangle {
public:
    int length{};
    int width{};
    int area;
    int get_area() const {
        return this->area;
    }
    Rectangle() {
        this->area = length*width;
    }
};

int main() {
    Rectangle rect;
    rect.length = 10;
    rect.width = 20;
    std::cout << "Area of Rectangle: " << rect.get_area() << std::endl;
}
#

Well I am obviously doing something wrong cause it outputs 0

#

Do constructors in C++ not work like I think they do?

#

Where it runs whatever is inside it as soon as its instantiated

radiant kraken
#

not treat it like a struct

#

just like how you would define a JavaScript class

earnest phoenix
#

You're zero-initializing the length and width properties of int type which gets initialized to 0, and since you're assigning them after calling its constructor, it does this->area = 0 * 0 basically

sharp geyser
#
#include <iostream>

class Rectangle {
public:
    int length;
    int width;
    int area;
    int get_area() const {
        return this->area;
    }
    Rectangle(int length, int width) {
        this->length = length;
        this->width = width;
        this->area = length*width;
    }
};

int main() {
    Rectangle rect(10,20);
    std::cout << "Area of Rectangle: " << rect.get_area() << std::endl;
}

like this?

radiant kraken
#

yes

#

exactly

sharp geyser
#

Looks so weird with the ->

#

lol

radiant kraken
#

-> is for pointer destructuring and property access

earnest phoenix
#

this is technically an object pointer, so you'd need to use the -> accessor, -> is the equivalent of (*T).t

sharp geyser
#

I am doing this. by habit

#

luckily it auto corrects to ->

radiant kraken
#

its kind of like this

struct Misty {
 int a;
}

Misty misty;
Misty * ptr = &misty;

(*ptr).a;
ptr->a; // same thing
sharp geyser
#

I see

radiant kraken
#

this in methods in C++ will always be a pointer to the object's instance

sharp geyser
#

So it is like js in that aspect

radiant kraken
#

ye

sharp geyser
#

this will always be relative to the scope

#

Also clion keeps giving me a warning about using nodiscard

#

is that a compiler thing?

earnest phoenix
sharp geyser
#

Thanks

#

So its more proper to do it the way null showed me

#

gotcha

radiant kraken
#

glad to help

sharp geyser
#

So its basically telling the compiler to not ignore it?

earnest phoenix
#

It's telling the compiler to issue a warning when you discard a value that shouldn't be discarded

sharp geyser
#

Hm

#

I see

#

Is it important to use?

radiant kraken
#

no

#

i mean you're just learning the basics now

sharp geyser
#

I am basically just trying to figure out the differences/simularities between C++ and js rn

#

Use a lang I already know better to try and learn another

#

:p

earnest phoenix
#

We're here to help you know the differences whenever you need to

radiant kraken
sharp geyser
#

Right now ima try and figure out how to make a calculator app

#

I know how to make a basic one

radiant kraken
#

as you came from a higher lang such as JS, it might get quite hard to get used to

sharp geyser
#

so ima start there first

#

and see if I can improve on it with different concepts

magic sonnet
#
const { SlashCommandBuilder } = require('@discordjs/builders');
const { Permissions } = require('discord.js');
const { prisma } = require("../../database");

async function fetchNoteOptions(interaction, { value }) {
    const notes = await prisma.note.findMany({
        where: {
            note_id: {
                contains: value
            }
        },
        take: 25
    });

    return notes.map(note => ({
        name: `Note ID: ${note.note_id}`,
        value: note.note_id.toString()
    }));
}

module.exports = {
    data: new SlashCommandBuilder()
        .setName('deletenote')
        .setDescription('Delete a note for a user')
        .addUserOption(option => option.setName('user').setDescription('The user to delete a note from').setRequired(true))
        .addStringOption(option => option.setName('note_id').setDescription('The ID of the note to delete').setRequired(true).setAutocomplete(true).setAutocompleteHandler(fetchNoteOptions)),
    async execute(interaction) {
        if (!interaction.member.permissions.has(Permissions.FLAGS.MODERATE_MEMBERS)) {
            return interaction.reply({ content: 'You do not have the proper permissions to use this command.', ephemeral: true });
        }

        const targetUser = interaction.options.getUser('user');
        const noteId = interaction.options.getString('note_id');

        try {
            const note = await prisma.note.findUnique({
                where: { note_id: parseInt(noteId) }
            });

            if (!note) {
                return interaction.reply({ content: `Note with ID ${noteId} not found.`, ephemeral: false });
            }

            if (note.target_id !== BigInt(targetUser.id)) {
                return interaction.reply({
                    content: `Note with ID ${noteId} is not associated with user ${targetUser.tag}.`,
                    ephemeral: false
                });
            }

            await prisma.note.delete({
                where: { note_id: parseInt(noteId) }
            });

            interaction.reply({ content: `Note with ID ${noteId} deleted successfully.`, ephemeral: false });
        } catch (error) {
            console.error('Error deleting note:', error);
            interaction.reply({ content: 'There was an error while processing your request.', ephemeral: true });
        }
    },
};
#

Where did I screw up auto complete?

earnest phoenix
sharp geyser
#

or some other bin

magic sonnet
#

K

radiant kraken
sharp geyser
#

So can you split strings in C++?

radiant kraken
#

yes

sharp geyser
#

I know you can do substr

#

but that is similar to splice in js no?

earnest phoenix
earnest phoenix
#

On my way to propose it

sharp geyser
#

I see

#

Now this might be too advanced of a topic so let me know if I am getting way in over my head at the start, but I want to split a string based off mathmatical tokens e.g +, -, /, ``*` and so on so forth

#

Implementing full on pemdas is probably too much for me but something basic is what I want to try and achieve, but I need to first get each thing individually.

earnest phoenix
sharp geyser
#

Oh?

#

What is required to make one?

#

I'd like to try and figure it out myself if I can with a little guidance

earnest phoenix
#

You basically just go through every character in the input, tokenize them, and then parse it into an Abstract Syntax Tree (AST), and finally execute it

sharp geyser
#

So should I make a map/some kind of list of tokens?

earnest phoenix
#

Take input -> split all characters -> tokenize (1/111/1.758 as number, +/-///* as operator, sin as identifier, ( as (, ) as )) -> parse into an AST, example:

(Just pseudocode-like example)

AST {
  type: ASTTypes::BinaryExp,
  op: Operators::Plus,
  left: Operand {
    type: ASTTypes::Number,
    value: 9
  },
  right: Operand {
    type: ASTTypes::FunctionCall,
    name: "sin",
    arguments: Vector {
      type: ASTTypes::Number,
      value: 1.79
    }
  }
}
radiant kraken
#

Congratulations! You are now a true C/C++ developer!

earnest phoenix
#

And finally execute

radiant kraken
#

You made complex wrappers to do simple things

sharp geyser
#

I haven't made anything yet

earnest phoenix
radiant kraken
#

like how complex it is to do simple things

#

i mean i understand since C/C++ is meant to be as close to the bare metal as possible

earnest phoenix
#

What simple things?

radiant kraken
#

like this?

#

a simple calculator app went to writing an entire AST

sharp geyser
#

Would it be wise to make a list of possible tokens or something else?

earnest phoenix
#

You don't have to make a parser to make a simple calculator application, what I was suggesting is to make the calculator as capable as it can be

radiant kraken
#

but he's just a beginner atm

earnest phoenix
#

There are many other much simpler ways to make one

radiant kraken
#

you should keep it as simple as you can since he is still new to the language

sharp geyser
#

Don't argue you two wah

earnest phoenix
#

What I said was merely a suggestion/recommendation to make it good, didn't say it's simple/so easy

radiant kraken
#

once he's more proficient on the language, he can improve on his calculator app later as he learns more and more about the language poggythumbsup

#

that's how i learn at least

sharp geyser
#

Yes I agree

rain stream
#

its like learning vanilla JS before touching a framework to make life easier

sharp geyser
#

Which is why a calculator app with an AST is my end goal

earnest phoenix
#

Otherwise you can make it absolutely sucky and only take two operands or something

#

Or take as many as long as operators match, by splitting the string with the operators as delimiters

radiant kraken
#

that's how i made my calc app at first

#

it's okay if you want to touch upon topics like string splitting, string parsing, switch/if-else statements, etc

sharp geyser
#

My original plan was to just split the string based off its delimiters

#

and use basic pemdas

earnest phoenix
#

That's absolutely fine, you can use the StackOverflow solutions on how to split strings with delimiters

sharp geyser
#

ignore the p and e part

#

cause parentheses and exponents are annoying

#

For now I just want to allow adding,subtracting,division and multiplication or a combination of any of those 4

earnest phoenix
#

Make sure to implement operator precedence as well, certain operators should run before the others

sharp geyser
#

Yea which is why I mentioned pemdas

radiant kraken
#

split the string by whitespace first, then parse each token to a number/operator

sharp geyser
#

I notice in some examples they make use of vector's and streams

earnest phoenix
#

Yes that's good (for now)

radiant kraken
#

yes u would have to do that

sharp geyser
#

Yea I must be doing something wrong cause I am only getting the numbers and not any operators

sharp geyser
#
#include <iostream>
#include <string>
#include <vector>
#include <sstream>


int main() {
    std::string expression;

    std::cout << "What would you like to evaluate?\n";
    std::cin >> expression;
    std::cout << expression;

    std::vector<std::string> tokens;
    std::istringstream stream(expression);
    std::string token;


    while (stream >> token) {
        tokens.push_back(token);
    }

    for (const std::string& token : tokens) {
        std::cout << token << std::endl;
    }

}
#

This is what I got so far

#

and it does split it

#

just incorrectly

#

I think I am missing something

earnest phoenix
#

What are you entering as input?

sharp geyser
#

2 + 2

#

it outputs as 22

radiant kraken
#

that's probably how JavaScript evaluates math operations under the hood

#

Voltrex can confirm

earnest phoenix
sharp geyser
radiant kraken
#

that's what stopped me from using C++ at first

#

i hated the fact that std::cin stops at whitespace

#

and quit from learning C++ for about a year or two

sharp geyser
#

I didnt even know

radiant kraken
sharp geyser
#

What should I do instead

earnest phoenix
#

To get the whole line

sharp geyser
#

I see

#

Was just about to ask what getline does

#

Okay now it works

#

Thanks <3

#

So getline just gets the entire input from cin?

earnest phoenix
#

Yes

sharp geyser
#

or whatever is passed to it ig

earnest phoenix
#

It gets an entire line out of something that implements the extraction operator (>>), in this case std::cin does

radiant kraken
#

honestly i rarely use C++'s std:: functions because of this ambiguity

sharp geyser
#

Oh I see

radiant kraken
#

most of the times i would parse the string character-by-character

sharp geyser
#

const std::string& token : tokens what exactly is this doing btw

radiant kraken
#

it's like for (const token of tokens) {} in JS

sharp geyser
#

Yea I am more talking about the thing that looks like a borrow in rust

#

the &

radiant kraken
#

std::string is the type the tokens iterator yields

#

the & represents a reference

#

its like a pointer but higher level

sharp geyser
#

Is that so I can use the tokens vector somewhere else without it being locked to the for loop?

radiant kraken
#

wdym?

sharp geyser
#

Like how rust has ownership rules, where you would need to "borrow" it so it isn't just locked there

#

is that similiar here?

radiant kraken
#

C++ has no concept of borrowing

#

everything is NOT memory-safe by default

sharp geyser
#

So what exactly is a reference then

#

What would happen if I dont use & there

earnest phoenix
sharp geyser
#

Hm

radiant kraken
#

wdym?

#

pointers dont make a copy too?

sharp geyser
#

I am not quite sure I fully follow

earnest phoenix
#

It's always recommended to work with large objects by taking references from them, to optimize memory usage

earnest phoenix
radiant kraken
#

i know

#

whats the diff between a pointer and reference then

sharp geyser
radiant kraken
#

ik the former stores the memory address but thats it

sharp geyser
#

Okay so

#

Actually nvm

#

I don't really understand what a reference is

#

I know its kinda like an alias for something but it doesn't make a copy correct?

radiant kraken
#

yes

sharp geyser
#

So that means std::string& token : tokens in the for loop is basically saying token is a reference of whatever is looped over?

radiant kraken
#

pointers are the memory address, but you can dereference them to get their value at that address

#

with the (*thing) or thing->

sharp geyser
#

Okay so after reading some more

#

std::string& token is a reference of all the strings in the token vector so that its not making a copy of them and using up more resources?

radiant kraken
#

technically

void increment(int * a) {
  (*a)++;
}
// increment(&smth);

void increment(int & a) {
  a++;
}
// increment(smth);
``` does the same thing, no? @earnest phoenix
earnest phoenix
# radiant kraken whats the diff between a pointer and reference then
  1. A reference must always be initialized, it cannot be empty, and the value of a reference variable cannot be changed to point to another value while pointers can do so
  2. To access the value of a pointer, you need to deference it using the deferencing operator (*) and to assign a value to a pointer, you need to get its address using the address-of operator (&), meanwhile this is done implicitly in references
  3. To dynamically allocate memory or use nullptr/NULL, you need to use a pointer
  4. Pointers allow something called pointer arithmetic which allows changing the address incrementally or decrementally, or completely changing it
  5. Function and void pointers
earnest phoenix
#

Also a tip, always use std::string_view over std::string if you're not gonna do dynamic/mutation operations on the string

radiant kraken
#

not as better, memory safe, blazingly fast™️ as Rust!!!!!

earnest phoenix
#

It's much more lightweight, basically a non-owning, read-only view of a string

sharp geyser
#

I see

#

Thanks

radiant kraken
#

or just use a char * like a true chad

sharp geyser
#

I tried that

#

Clion yelled at me for doing something useless trollface

radiant kraken
#

the code was too chad for the ide to handle sdTroll

sharp geyser
#

Anyway I’ve noted all this down in my brain

#

But now I sleeep

radiant kraken
#

good night buddy

sharp geyser
#

Thanks you have a good night as well

earnest phoenix
#

Goodnight Misty

radiant kraken
neon leaf
#

11:33am trol

radiant kraken
neon leaf
#

M

surreal sage
#

gitgud

neon leaf
#

M

magic sonnet
#

N

eternal osprey
#

heyy

neon leaf
#

Hi

magic sonnet
#

Hi

green kestrel
#

actually got a reasonable site now 😄

#

problem is doing web dev as day job, means i really cant be arsed with it at home and it drags

#

and yeah this design might look familiar 😉

magic sonnet
#

👀

#

Very nice sir

sharp geyser
radiant kraken
#

@sharp geyser how's cpp been going btw

wheat mesa
#

yes I would like to know as well @sharp geyser

sharp geyser
#

@wheat mesa @radiant kraken I haven't touched C++ since last night as I had work all day

#

Ima code some more later I just got off work tho so ima take a rest

#

As of right now I am able to split the expression, but I can't seem to get it to do any kind of math, it just adds it back together as one string. Ima start over from the splitting and go from there

lament rock
#

expression evaluation is tough

sharp geyser
#

I can tell

lament rock
#

only gets worse with syntax complexity

sharp geyser
#

I am not even touching that yet

#

Right now I am just hoping to get it to do any math, even if its wrong

lament rock
#

I almost got roped into making a language of sorts with someone

#

bad idea

sharp geyser
#

I would love to try and make a language

lament rock
#

interpreted

sharp geyser
#

but that is a very very far into the future goal

lament rock
#

yeahhhh

#

I'm not at all confident in my abilities

sharp geyser
#

I am not even confident in making a simple calculator

lament rock
#

I mean, you just started no?

sharp geyser
#

Yea, but I dont seem to be making any progress

lament rock
#

I think the biggest slow down is trying to understand language specific stuff since I'm certain you already understand data types

sharp geyser
#

yea data types are easy

lament rock
#

It took me like a week to get a grip on C#

sharp geyser
#

I just don't know where to start

lament rock
#

basic C#

sharp geyser
#

but I already know the basics of c++ in terms of datatypes and functions

#

classes are still a bit iffy with me

lament rock
#

I think nobody is expecting you to just be good at it off rip

sharp geyser
#

I know, but I just don't know what to do

lament rock
#

in terms of learning or what to do with the knowledge

sharp geyser
#

The knowledge I know is helpful, but not enough to really make anything

#

So I need to focus more on learning

lament rock
#

What would you want to make ideally

sharp geyser
#

I think as my first project, something simple like a calculator app

#

Then I can improve on it or work on something else

lament rock
#

And you're just tackling the expression part for now?

sharp geyser
#

Yea, just doing any basic math evaluation

lament rock
#

How complex are you trying to make it?

sharp geyser
#

Like 2+2, 2*2, 2+2 * 4

lament rock
#

I don't think calculators parse strings

#

the windows calculator isn't terribly complex

sharp geyser
#

the input is a string, but I need to parse the input into ints

lament rock
#

Oh cli

sharp geyser
#

Thing is if I loop through the tokens vector and try and do that, it trips up on any operators

#

and I could just use a if statement to see if its an operator but I dont think thats the best way to do it

lament rock
#

I think the best thing to do is to consider the operator first and then look at the left and right hands

sharp geyser
#

Oh?

lament rock
#

Yeah. If it isn't gonna be chained operators in a single input, then you can easily distinguish each side if you have the index of the operator

#

Even if it is chained, the challenge then becomes distinguishing boundaries between expressions as a whole

neon leaf
sharp geyser
#

What if I dont want to

neon leaf
#

I will force you

green kestrel
#

only difference is those are made from scratch with no backend framework, ive had to redo it all in laravel for the new one

green kestrel
#

64 bit machines have a 64 bit time_t value, which wont overflow until December 4th, 292,277,026,596

#

i think it wont be a problem we care about nearly 300 billion years from now kekeke

pale vessel
#

someone should edit the sticker to say December 4th, 292,277,026,596

lyric mountain
neon leaf
pale vessel
#

when there's a will there's a way

neon leaf
wheat mesa
# sharp geyser Like `2+2`, ``2*2``, ``2+2 * 4``

I would highly recommend looking into recursive descent parsing for these expressions. It’ll teach you how to build an AST from these tokens (which is kinda overkill for a calculator but still worth learning) which makes these expressions trivial to evaluate

lyric mountain
#

I recommend antlr

#

found it quite easy to use once it "clicks in"

wheat mesa
#

Ehhhhh