#ot2-the-original-pubsta

652 messages · Page 58 of 1

daring jay
#

It uses Postgres

grim seal
#

I'm always hesitant about recommending free hosting and free databases

#

it never ends well

daring jay
#

But if you're already hosting a modmail bot

grim seal
#

supabase is the exception actually, lol, I do like supabase

daring jay
#

Why not host a postgres db in the same place?

viral hare
#

even if the goal is for everybody to use for free i think u only really need to start looking for good hosting options once u start getting lots of users

#

like how many users are currently using the app now

grim seal
wide totem
#

^

daring jay
#

I'm using Supabase just cause I know I'll be the only one ever using my app

grim seal
#

the idea is that ARU provides the source code and then users can set it up however they want

wide totem
#

And 9k people use the kyb3r modmail

viral hare
#

oh ic

steel eagle
#

Are we talking about databases

grim seal
#

so obviously designing it to be low cost is appealing

viral hare
#

y dont just let the users decide how they want to store their data or sth

grim seal
#

but yeah, personally I'd fork out the few bucks/mo for hosting a VPS w/ PSQL

grim seal
steel eagle
#

I need to learn the basics and intermediates of SQL. I'm not really employable without that. I've avoided it for so many years because I hate it so much

viral hare
#

like give them a range of options

wide totem
viral hare
#

which is what most orms do

wide totem
#

But to interface with different databases, I have to write code for that

viral hare
#

does it use a orm

#

or are u actually writing query strings

wide totem
#

what is an orm?

grim seal
#

you can't abstract mongodb vs postgres behind an ORM

#

they are completely different databases

#

postgres is relational sql, mongodb is document & nosql

viral hare
#

like typeorm apparently supports some nosql and lots of sql

wide totem
#

what is an orm?

#

@daring jay looking into supbase rn

grim seal
daring jay
grim seal
#

I've yet to see a fully compatible mongodb/postgres ORM in Python

#

and... frankly I don't want there to be one

#

it would lead to some really horrible database setups

daring jay
lime drum
#

mongo and sql arent much compatible

wide totem
#

hm

grim seal
#

yeah

#

for good reason

#

lul

lime drum
#

tho if you do an orm for sql databases you still have lots of options

viral hare
#

well i guess if ur just using sqlalchemy or pymongo u cant mix

grim seal
#

yeah, but mongodb generally does have the best free hosting offerings

wide totem
lime drum
#

additionally you could bundle an sqlite database

daring jay
#

It has it's own uri that it gives you I think

wide totem
#

ngl i can't even find the supabase pricing

daring jay
#

It's pretty cheap, and it's free tier is good

wide totem
#

#

wtf

#

that's on par with mongodb cloud

#

as in pretty equal

daring jay
#

Is that a good thing or a bad thing?

wide totem
#

good thing

#

the one little problem i have with this is this line

#

and this is for an important reason

daring jay
#

That just means the database pauses iirc

#

So the first query might take a little longer

wide totem
#

and you have to restart it from the portal

daring jay
#

Oh, idk

wide totem
daring jay
#

Oh, I see

#

Well in my thinking, if you're not getting one thing in a week, then you don't need a modmail bot

wide totem
#

and this is a small problem since heroku gives only 550 hours a month which doesn't cover the entire month

viral hare
#

welp thats kinda what happens with free tier

wide totem
#

but i think its okay to live with that slightly friction imo

viral hare
#

cuz its their electricity that u r using

grim seal
wide totem
#

I'll have to ask the other people who I'm working with

daring jay
#

I would think you would just message a mod

#

But if you have error handling in the bot, it shouldn't really be a problem

#

Or just use Mongo

wide totem
#

the issue is you have to open the dashboard when that goes down

#

a small solution would just be set up a ping on uptime robot lmao

#

depending on their terms of service

daring jay
#

Or just have the bot get data from the database every day

#

And gather data that it does nothing with

wide totem
#

bot might be off for a week

daring jay
#

Ah

wide totem
#

there's 750 hours a month

daring jay
wide totem
#

yeah

daring jay
#

But it's up to you

wide totem
#

and its possible to get heroku to host for the whole month for free anyhow

#

also can just add a tip to the setup guide

daring jay
#

Is the clone open source?

#

If so, link?

wide totem
#

there isn't any db support yet

daring jay
#

You should add a README

wide totem
#

soon, its on my list

daring jay
clever salmonBOT
#

modmail/config-default.toml lines 30 to 32

[emoji]
# sent_emoji = "white_heavy_check_mark"
# blocked_emoji = "\\N{NO ENTRY SIGN}"```
wide totem
#

that file shouldn't even be commited atm

daring jay
#

Oh lol

wide totem
#

will fix

#

tl;dr if i can figure out how to get a db connection uri for the databases on supabase

#

we'll use it

#

since i want this to be compatiable with not just supabase

#

afk

daring jay
wide totem
#

Dope

#

@grim seal i talked with the team and postgresql on supabase all the way

#

so no more mongodb

#

now i gotta redo a portion of the config system for the nth time

wide totem
#

asyncpg or aiopg?

daring jay
#

@wide totem Google says asyncpg

#

By like, a lot

wide totem
#

lol

#

went with it

daring jay
#

Nice

languid osprey
#

Rice sure is entertaining

echo fern
#

read it as "Rust", had no questions

languid osprey
#

haha

daring jay
#

I swear I saw that as Rust

indigo nest
#

help, my laptop is lagging even though i have about 50gbs left of space and 3.79 ram that is still usable out of 4.00 ram

daring jay
#

How do you test a programming language you're making? Simple question, but for some reason it's stumping me

languid osprey
#

Well

#

You can give a test input, and have it evaluate it

#

Or for seperate parts, have each of the parts of the language do its own thing with a given input

#

And see what the output is

tranquil ridge
#

if its somewhat like python make a repl

#

that makes it easier to test

languid osprey
#

Mhm

#

If you can, implement a simple debug repl

daring jay
#

I see

#

Interesting

normal pumice
#

Since this channel is called rice

languid osprey
#

oooHHH

paper snow
#

How can I run exe files on mac, on big sur?

viral hare
#

when windows thinks drscheme installer is a virus

dim root
#

@grim seal you here? need some help

wide totem
#

@dim root I replied in the discord-modmail guild but does it work locally?

dim root
wide totem
#

!pypi poetry

clever salmonBOT
wide totem
#

Need to open docs since on mobile lmao

#

Hm

#

Oh

#

The package itself seems to be installed

#

Idk

#

poetry remove piston-cli?

dim root
wide totem
#

Uh

#

poetry install --remove-untracked

dim root
#

what it works now, did a relock

wide totem
#

Ah lol

wide totem
dim root
#

🤞

#

running

#

nooo

#

it works locally tho

wide totem
#

The working directory possibly?

#

Since poetry installs the local project by default

dim root
#

i am using tokens and they are correct

#

boom it worked

odd sphinx
#

epic

tranquil ridge
#

nice

proper python
#

what's some good essay writing music?

#

got a long night ahead of me

#

lofi is a bit too sleepy for me

slender echo
#

who plays fall guys

odd sphinx
#

not me

grim seal
dim root
#

debugging workflows is hell lot of work

#

you cannot do it locally ig

grim seal
median blade
#

ah yes, dometimes

cerulean panther
#

dometimes. lol

grim seal
#

Lol

odd sphinx
#

yes

dusky cliff
cerulean panther
#

lol

odd sphinx
#

what

#

?

cerulean panther
#

dome times

#

/dōmtīmz/

odd sphinx
#

oh

#

lol

jovial island
tranquil ridge
#

lol

cerulean panther
#

lol

tranquil ridge
#

editing OX_1000

jovial island
#

no 1 billion

dusky cliff
#

cry about it

odd sphinx
#

lol

jovial island
#

Thicken is a good cad tool

#

So is extrude

jovial island
#

no u

#

don't crosspost

indigo nest
#

sorry

jovial island
#

@indigo nest This isn't a place to advertise your minecraft server, please also read our off-topic etiquette if you haven't already

indigo nest
#

no regrets

#

but ok sure

clever salmonBOT
#

Hey @midnight perch!

It looks like you tried to attach file type(s) that we do not allow (.7z). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a.

Feel free to ask in #community-meta if you think this is a mistake.

odd sphinx
#

L

rigid echo
#

O

cerulean panther
#

L

woven hornet
#
    static int program1(int n, int[] arr) {
        int val = 0;
        for (int i = 0; i < arr.length; i++) {
            val *= arr[i];
        }
        if (n==0) return val;
        return program1(n-1, arr);
    }
#

what does this program do?

#

i was thinking if u set val = 0 wouldnt 0 multiplied by anything give u 0?

dusky cliff
#

yes

#

this will always return 0

#

where'd you find this

#

they probably meant to set val = 1

woven hornet
woven hornet
#

lemme thinking abt it again

round moss
#

Depending on how java defines signed overflow, it may also be infinite/undefined in some cases

dusky cliff
shrewd lance
#

Wait, why would there be overflow on multiplication by zero?

woven hornet
#

btw this function gives out an integer right?

dusky cliff
#

and you're supposed to answer 0

woven hornet
#

cuz after static it's int

round moss
#

n-1 doesn't tend towards 0

dusky cliff
shrewd lance
#

Oh, right

woven hornet
woven hornet
# dusky cliff yes

can i check for this function, all it does is to return the product of the integers in an array?

#

i feel the n is abit unnecessary? like even if it starts of n>0, it's gonna keep -1 till it reaches n== 0

dusky cliff
#

ye, the recursion thing does seem useless to me

#

not like arr changes at each recursive call

woven hornet
#

it wont be a few values?

dusky cliff
#

?

#

it'll return just one int

woven hornet
#

yeah cuz before n reaches 0, it will keep returning the arr

#

i see ok so it jus returns the last value when n==0

#

thanks

#

@dusky cliff i realise when the qn asked find the recursion relation, they were finding T(n) = ...

#

the efficiency

#

which was T(n) = O(x) + T(n-1)

dusky cliff
#

hmm

plucky shale
#

Yes Rice is good

jovial island
#

riceing

languid osprey
#

ricing good

#

I have a question

#

A, well, inquiry

#

shall I use arch or openSUSE

#

I can't decide

#

fuck it im using arch

tribal tinsel
#

well, one of the rules of ot is to respect ongoing discussions. so people in other channels just continued their topics

#

and yes, one can make their own operating system

languid osprey
#

I mean I wrote a kernel once

#

But I'm not sure how I would go about ricing that

#

or using it

#

uh

#

somewhere in my files

#

all it does is print hello world to the screen :P

#

It was just to see if I could do it

tall temple
#

just a question, why do many pythoners prefer to write json data instead of python data format?
does it offer efficiency benefits?

#

For pure python projects, I tend to just write python literals to the data file and import it as a module

#

Am I losing any efficiency doing this?

sinful sun
#

Wdym json data and python data

#

json is a serialisation format, whats python data format

idle comet
# tall temple Am I losing any efficiency doing this?

json is literally the same as you would write in python, but limited to the following datatypes: list, dict, int, float, str
it has the advantage of easily being writable from python code, which a python file does not have, at least not with this little effort.
you're most likely not loosing efficiency (or actually, a json parser is a lot easier to run than a python parser but both are negligible in most cases)
but you're loosing persistance of changes.

wide totem
#

Like if it does, that's almost certainly a bug in python itself

#

Python parsing with ast has good potential to crash the compiler

idle comet
#

well, yes but actually no. you can still wrap a import in a try except block to continue after it fails, which is the same as handling the errors raised by the json parser

wide totem
#

Yeah

#

Wait

#

I meant literally using {!d ast} to parse python lol

idle comet
wide totem
#

Idk why I did that

#

!d ast

clever salmonBOT
#
ast

Source code: Lib/ast.py

The ast module helps Python applications to process trees of the Python abstract syntax grammar. The abstract syntax itself might change with each Python release; this module helps to find out programmatically what the current grammar looks like.

An abstract syntax tree can be generated by passing ast.PyCF_ONLY_AST as a flag to the compile() built-in function, or using the parse() helper provided in this module. The result will be a tree of objects whose classes all inherit from ast.AST. An abstract syntax tree can be compiled into a Python code object using the built-in compile() function.

wide totem
#

Inline commands plus1

idle comet
#

THATS GENIOUS

#

please submit a issue for that

#

i wanna see what others think of it

wide totem
#

99% it's already been submitted which is where I saw it

#

!src

clever salmonBOT
wide totem
#

Lemme check

#

bot#1604

rustic harborBOT
wide totem
#

@idle comet

idle comet
#

ofc it was vco's idea

#

i shoulda known

#

@soft quiver good idea you got there, inline commands, now i deperately want that

soft quiver
#

lolll

idle comet
#

this will be in every bot i make from now on. just need a decent implementation

#

its one of those things

#

once you realise its a possiblity, once the idea even comes up, you cant stop thinking about it

soft quiver
#

just need a solid regex for it really

#

the rest is pretty simple

median blade
#

Afaik some bot already has this

#

But ig it uses discord.js

wicked hollow
#

@hidden rose I think you're looking for:

typedef struct s_info
{
    int *num_array;
    int size;
}   t_info;

int main(void)
{
    t_info *info;

    info = malloc(sizeof(t_info));
    info->size = 16;
    info->num_array = malloc(info->size * sizeof(int));
}
austere oak
#

A utf-16 txt file shouldn’t ever have an odd number of bytes, right?

tall temple
#

I do believe you are right

austere oak
#

Good, thank you

median blade
#

@wide totem

#

you have experience with poetry i guess?

wide totem
#

Some ye

median blade
#

ok so

#

do i push the entire proj with the pyproject.toml to git or just the main proj itself

wide totem
#

Ooh, pr 2 was just merged

#

Push pyproject.toml

median blade
#

alright

languid osprey
#

Yes

wide totem
#

discord-modmail/site#1

rustic harborBOT
languid osprey
#

Pyproject is necesarry

median blade
#

deps

#

and stuff

#

yeah

languid osprey
#

Push your .lock file too

daring jay
#

You should also push poetry.lock

languid osprey
#

Yep

wide totem
#

^

median blade
#

aight

wide totem
#

Look at the repo linked above to see about it

median blade
#

ok so next thing, is there a pipenv run like feature with poetry

wide totem
#

We just set that repo up, so you can see most of the stuff used

daring jay
languid osprey
#

Mhm

median blade
#

but like can i set it up

#

so that i just do poetry run

#

and it runs the filei want

wide totem
#

"poetry run something"
I use taskipy as a dev dep so I can define scripts in the pyproject file

#

Ex poetry run task lint

#

Runs pre-commit

median blade
#

hmm

wide totem
#

Fwiw if you look at the pr linked above

#

All of that code in the repo at that point was just linting and workflows

median blade
#

nice

#

thanks :)

dim root
#

you can also use poet

#

it would then be poe lint

hidden rose
#

And the proper way to free would be to first free info->num_array and then info struct:

free(info->num_array);
free(info);
jovial island
#

is it expected that a 8 core last gen cpu cannot playback 8k 60fps video from youtube?

median blade
#

No

jovial island
#

hmm

#

interesting

#

i have other stuff running too tho

#

And like

#

It's 60 gbit s of data

#

each second

median blade
#

Ok you need a good gpu

#

Which GPU do you have

#

...

jovial island
#

3060

#

mobile

#

(sorry i am late)

odd sphinx
#

@median blade the mans replied

jovial island
#

it uses like %975 cpu

#

that's like 10 threads

#

fully working on playbacking one youtube video

#

i think the problem is chrome not doing hardware acceleration

#

bcos gpu only draws 30W max

#

nvm it draws up to 70W

#

but still

#

it drops like %30 of frames

#

I found the issue

#

hardware acceleration off actually turns it on lmao

small depot
#

||JsOn Is A dAtAbAsE||

hazy laurel
#

yes

median blade
#

aight

#

whats the difference between .rst and .md files

#

can i just replace the .rst with a .md which was pregenerated by poetry

sinful sun
#

They use different syntax afaik
If theyre equivalent then yea, idk why people use rst instead of md

round moss
#

it is similar enough that it may just work, but they are slightly different languages

sudden swallow
daring jay
#

Mods and admins can add them

crude trail
#

What a coincidence.

I am currently thinking about saving my ISO-639-1 JSON as a model in my DB and feel called out

idle comet
round moss
#

that example is almost the same

#

but yeah, maybe not enough to just use one as the other

idle comet
#

its definitely not supposed to be transferrable. be aware, my example here was VERY basic for what rst can do

delicate lion
#

ok who named this channel it makes me angry

idle comet
#

have a more advanced example that i had to link shortenbecause the URL is longer than 2k chars https://u.nu/rsttomd

#

wait

#

oof i think i broke the link shortener

dusky cliff
#

because the URL is longer than 2k chars
sorry what

idle comet
dusky cliff
#

tf

tawdry salmon
#

I love the channel name

jovial island
#

json is a db wtf

sinful sun
#

breh

sinful sun
#

breh

#
class ItemBase(BaseModel):
    title: str
    description: Optional[str] = None
    calories: int

why does this post request go through

{
    "title": "water",
    "description": 10,
    "calories": 0
}
#

shouldnt it error because i gave it an int

round moss
#

it seems to have an implicit conversion

sinful sun
#

whats the point of pydantic if its gonna convert things without me telling it to lmao

#

theres a strictstr type apparently

sinful sun
#

travis ci is having an aneurysm with build configs

#

automate your testing they said

#

im trying to use the trigger build feature and its running duplicate commands and then failing the build

#

fun times

jovial island
#

It got deleted?

slow valve
jovial island
#

NO

#

I do not know why they will match the json format to be a database, I think we would optimize the database if we did not unnecessarily transform a python dictionary to a json dictionary

#

also if I would create my own database I would use a compression algorithm, I imagined your database has many but not so much to match BIG or MEDIUM Data, the encoding is utf-8, your file will have a size of 80mb while with compression we will have 3kb and very fast when reading and writing.

#

this has the bad databases in pypi
import json,
open("database", "r+")

good databases:
import lz4framed
import ast
_io

round moss
#

I mean, it is hard to beat sqlite3 when it comes to easy databases

jovial island
#

i think sqlite3 has over 100000 lines of code (7mb)

round moss
#

Yeah

#

But it is still the best option that is a meaningful improvement over json

#

It's part of the standard library, and even on platforms where you link it dynamically, enough things depend on it that you likely need it anyway

jovial island
#

it is good for small projects or that do not require big data

round moss
#

Yup

#

Or well, tasks that aren't write bound

#

It is pretty ok for even sizable datasets when reading

jovial island
#

I mean to have 6tb of data

round moss
#

Yeah, sqlite3 is not the tool there

#

You need specialized stuff

wispy wave
#

I hate the channel name so much

woven stag
#

same

idle comet
#

but obviously json IS a database, DUH

lime drum
#

laundmo, you ok?

idle comet
lime drum
#

nope, obviously UDH

tall mural
#

json is the best

#

lucas tutorials are too.

oblique grove
#

what is a .json file?

#

csv files for js?

cerulean panther
oblique grove
#

what is it?

cerulean panther
cerulean panther
tall mural
#

looks like this for example

{
    "x": "y"
}
``` ||![yert](https://cdn.discordapp.com/emojis/832277526809149461.webp?size=128 "yert")||
hidden kernel
#

@ancient summit en taro adude, my dun

wide totem
clever salmonBOT
#

4. Use English to the best of your ability. Be polite if someone speaks English imperfectly.

cerulean panther
#

waht

#

bruh chill its a joke lmao, or i think it is

dusky cliff
median blade
#

Ha

woven hornet
#

would the big O for line 2 and 3 be O(n)?

#

since it's iterating from i = 0 to i = (2^x)n

viral hare
#

i mean if ur just ignoring x then yeah

#

well n halves each time and x increases by 1 each time

#

which means it cancels out in the n*2^x cuz (n/2) 2^(x+1) = n/2 * 2 * 2^x

#

and since ur basically dividing n by 2 each time, u call program4 log(n) times

#

and u get overall of log(n) * n * 2^x (not sure if u can simplify this further) if u want to account for the effect of both variables.

woven hornet
#

Thanks!

somber belfry
#

O(n) is the same as O(n/2)

#

did you del- guess you figured it out 😄

woven hornet
oak flume
#

hey

jovial island
#

hey

#

.topic

rustic harborBOT
#
**What is the most satisfying thing you've done in your life?**

Suggest more topics here!

jovial island
#

Set arson

magic atlas
jovial island
#

In games

magic atlas
#

Riight... ok.

plain forge
#

can you update windows 10 32 bit too 64 bit without deleting any files

#

aaaaaaaaaaaaaaaaaanswer

#

please

jovial island
#

Be patient bruh

plain forge
jovial island
#

No I'm god

plain forge
plain forge
odd sphinx
jovial island
#

Ik

languid osprey
#

Fuck

#

I just did an assignment for half an hour

#

and guess what

#

its fucking gone

lament kestrel
#

F

#

That Feel when you Forget to save

drifting venture
#

That blows

hybrid basin
#

F

hot pulsar
#

lol @pastel nest

pastel nest
hot pulsar
#

yes

gaunt jacinth
#

pinged for the hell of it

hot pulsar
#

@idle raptor its like he ignores everything we say lol

idle raptor
#

i think he just copied the code from somewhere

tall mural
#

.topic

rustic harborBOT
#
**If you could be anyone else for one day, who would it be?**

Suggest more topics here!

tall mural
#

amogus

#

impostor

fresh reef
#

ipmaosata

jovial island
tall mural
#

trust me

tall mural
#

.topic

rustic harborBOT
#
**What is your favourite food?**

Suggest more topics here!

tall mural
#

eggs

#

no one care.

#

.topic

rustic harborBOT
#
**What is your favourite color?**

Suggest more topics here!

tall mural
#

cyan.

shy oracle
#

.topic

rustic harborBOT
#
**What is the most satisfying thing you've done in your life?**

Suggest more topics here!

shy oracle
#

.

#

.topic

rustic harborBOT
#
**If you could travel anywhere in the world, where would you go?**

Suggest more topics here!

shy oracle
#

amreica

#

.topic

rustic harborBOT
#
**What is your favorite movie?**

Suggest more topics here!

shy oracle
#

.

#

.topic

rustic harborBOT
#
**What is the best scenery you've ever seen?**

Suggest more topics here!

shy oracle
#

why u asking mr questions that can go totaly wrong

#

.topic

rustic harborBOT
#
**If you could have any superpower, what would it be?**

Suggest more topics here!

shy oracle
#

main character

#

.topic

rustic harborBOT
#
**What is your favourite Easter candy or treat?**

Suggest more topics here!

shy oracle
#

chocolate

#

.topic

rustic harborBOT
#
**What book do you highly recommend everyone to read?**

Suggest more topics here!

shy oracle
#

dont read books kids

#

.topic

rustic harborBOT
#
**What is your favorite media genre?**

Suggest more topics here!

shy oracle
#

.topic

rustic harborBOT
#
**Would you rather fight 100 duck sized horses or one horse sized duck?**

Suggest more topics here!

shy oracle
#

horse sized duck

#

im not getting any points whats the point

odd sphinx
#

lol

patent elbow
#

@knotty anvil giv all frog emotes

knotty anvil
patent elbow
odd sphinx
#

pepe*

knotty anvil
#

yea lmao, wtf frog

patent elbow
#

More

knotty anvil
#

peepowut bro how many u need

patent elbow
#

depends

knotty anvil
#

peeposus ok

tranquil ridge
knotty anvil
#

yo that actually bumps time to yoink

patent elbow
#

@tranquil ridge you look familiar jam_cavedude

tranquil ridge
patent elbow
#

Hata best

knotty anvil
#

touhou EMOJIS

#

PepeBruh YOINK

patent elbow
#

Switch to hata andy

#

Like real men

knotty anvil
#

no :/

patent elbow
#

😔

knotty anvil
patent elbow
#

😔

knotty anvil
#

Ok ill send all

patent elbow
#

In the dm Or they will mute

pliant trench
#

what's the fastest way to exit vim ?

tranquil ridge
#

isnt :q fast enough for you

pliant trench
#

that's just for fun

round moss
#

ZZ

tranquil ridge
#

map it to some other keybinding

pliant trench
#

I remember lak cheated last time lol

#

or was it someone else...

round moss
#

I think I did cheat

pliant trench
#

lol

round moss
#
[adam@DESKTOP-319402F ~]$ echo exit >> .vimrc
[adam@DESKTOP-319402F ~]$ time vim

real    0m0.005s
user    0m0.000s
sys     0m0.005s
```I think I got a worse result than this sol though
pliant trench
#

did you use this one last time ?

round moss
#

I think I piped :q to vim

pliant trench
#

oh

round moss
#

bash

pliant trench
#
[pouridev@pouridev-pc ~]$ time vim --noplugin --cmd ":q" & killall -9 vim

real    0m0.004s
user    0m0.004s
sys    0m0.000s
#

here you go

#

I don't think I can make it faster

keen burrow
pliant trench
#

that's beyond cheating

keen burrow
#

:P

soft quiver
#

hey @blissful pollen you mentioned that pablo galindo said I should use soft keywords in yeethon, i dont suppose you'd know how I could achieve that? I've looked around and found something called _PyPegen_expect_soft_keyword but it doesn't seem to appear in Python.gram so I'm not quite sure how match and case actually define themselves as soft :D

blissful pollen
soft quiver
#

haha no wonder i didnt find that, it's a pretty subtle change, thanks!

blissful pollen
#

@soft quiver not sure why the soft keyword wouldn't work

#

I haven't tried adding any myself in PEG and my LL1 experience is useless now 😉

soft quiver
#

yeah, its odd, the keyword should definitely be there, and its listed in keyword.softkwlist, so my best guess is that having ('del' | "yeet") rather than just yeet is somehow messing it up

keen quarry
#

So some random account DMed me from here.

sinful sun
#

Report it through @vapid maple

woven hornet
#

ive asked this before but i still dont get it

#

i get the intention is to reduce any duplication of values calculated so u create a memory array to store the value then check if the value has been calculated before, if it isnt then calculate the new one

#

but in line 7 when u set memoryArray[i] = -1 does it replace all the values in the array to -1

#

so if u r returning memory[n] afterwards, would it return the previous fib value or -1

viral hare
#

lol its a dp problem

#

those are kinda intresting but not always trivial

#

essentially u set them all to -1 cuz u havent "visited" the numbers yet

#

hence y in that helper function there is a check if the number is -1

woven hornet
#

would it return an array of -1

viral hare
#

u only return memory[n] if the value isnt -1

#

which means u return it if u visited it before

#

and the else happens if u get -1 from memory which it does a computation for it

woven hornet
viral hare
#

u know how u set them all to -1 in the beginning

woven hornet
#

isit like u create a memory array with all the values u have, then u set all of them to -1

#

yeah

viral hare
#

-1 means u havent visited it

#

honestly if i had to implement this i would use a hashmap and do like a get

#

on an index

woven hornet
#

yeah so let say u input n as 5

#

then it would give [0, 1, 1, 2, 3, 5]

#

right

#

then what u doing is

#

creating a memory array of [0, 1, 1, 2, 3, 5]

#

then afterwards setting them as [-1, -1, -1, -1, -1, -1]

#

?

viral hare
#

oh no u first create an array of 6 elements

#

they are not initalized which means its a compiler default value

#

and then u set them all to -1

#

before u compute any fib number

woven hornet
#

ohhh

#

i get it

#

omg

#

i see

viral hare
#

the -1 is the "initalization" of the array

woven hornet
#

thankss!

#

yeah

viral hare
#

imo a cleaner way would to be use a dict

#

u still get constant lookup

#

and u dont need to initialize -1

woven hornet
#

oh yeah

#

true

jovial island
#

I agree webhooks are people too

median blade
#

ok

magic current
#

You can find the ID on phone or rclick it while network panel open

fluid plank
#

webhooks are people too hmm imma get some hookas

tiny sorrel
#

!class

clever salmonBOT
#

Classes

Classes are used to create objects that have specific behavior.

Every object in python has a class, including lists, dictionaries and even numbers. Using a class to group code and data like this is the foundation of Object Oriented Programming. Classes allow you to expose a simple, consistent interface while hiding the more complicated details. This simplifies the rest of your program and makes it easier to separately maintain and debug each component.

Here is an example class:

class Foo:
    def __init__(self, somedata):
        self.my_attrib = somedata

    def show(self):
        print(self.my_attrib)

To use a class, you need to instantiate it. The following creates a new object named bar, with Foo as its class.

bar = Foo('data')
bar.show()

We can access any of Foo's methods via bar.my_method(), and access any of bars data via bar.my_attribute.

tiny sorrel
#

!classes

clever salmonBOT
#
Did you mean ...

classmethod
class

tiny sorrel
#

!classmethod

clever salmonBOT
#

Although most methods are tied to an object instance, it can sometimes be useful to create a method that does something with the class itself. To achieve this in Python, you can use the @classmethod decorator. This is often used to provide alternative constructors for a class.

For example, you may be writing a class that takes some magic token (like an API key) as a constructor argument, but you sometimes read this token from a configuration file. You could make use of a @classmethod to create an alternate constructor for when you want to read from the configuration file.

class Bot:
    def __init__(self, token: str):
        self._token = token  

    @classmethod
    def from_config(cls, config: dict) -> Bot:
        token = config['token']
        return cls(token)

# now we can create the bot instance like this
alternative_bot = Bot.from_config(default_config)

# but this still works, too
regular_bot = Bot("tokenstring")

This is just one of the many use cases of @classmethod. A more in-depth explanation can be found here.

tiny sorrel
#

i dont understand at all

dusky cliff
tiny sorrel
#

both

#

i dont understand the difference

dusky cliff
# tiny sorrel both

as for classes
classes are a way to make a bunch of objects which have the same properties and behaviours

#

for example

#

if Human was a class

#

jack could be one object of the class, john could be another

#

lmao

#

lurc

#

anyway
they'd have the attributes and methods as defined in the Human class

tiny sorrel
#

that kind of makes sense

dusky cliff
#

classmethods aren't directly related to this concept

#

basically

#

all functions in a class take in a class object as the first parameter

#

usually named self

#

then the function would work with this object

#

if walk was a function in the Human class, it would look like:

class Human:
  def walk(self):

and if you did john.walk(), self would be set to the john object, if you called jack.walk(), self would be set to the jack object

#

this is the default behaviour, where the first parameter is an object of the class

#

In a classmethod however, the class itself is the first parameter

grim seal
#

oh quic RFC passed

#

that's dope as heckk

#

this is fantastic news

#

oh I see you mentioned it earlier @half timber hah

#

I wonder if the DNS roots will consider DNS-over-QUIC

#

they for obvious reason rejected DoH and DoT because of their stateful nature, the roots can't operate like that

#

but QUIC remains UDP, which is advantageous

#

I guess the fact facebook were using QUIC heavily encouraged IETF to pass it

#

iirc it's an RFC requirement that there is existing implementation

#

Today, more than 75 percent of our internet traffic uses QUIC and HTTP/3 (we refer to QUIC and HTTP/3 together as QUIC).

half timber
#

what am i.. oh yeah lol

#

it's both good and questionable when it's semi abused to deliver ads

median blade
#

Damn

woven hornet
#

for lines 4 to 10

#

isit the case where high == low is when the array only has one value?

#

while high < low, isnt it it could be the list is unsorted?

echo fern
echo fern
woven hornet
#

is it in line 10, it's setting int small as 2^31-1?

#

that's how Integer.MAX_VALUE work?

#

i dont get whats happening in line 12, for (int j = i; j < newArr.length; j++)

#

what are they iterating?

echo fern
echo fern
#

selection sort works by finding the element that should go on each position, basically

dusky cliff
echo fern
#

so you find the minimum of the array and place it at first place. Then you find the minimum of all the other elements and place it at the second place, and so on.

woven hornet
dusky cliff
#

at the first iteration, it starts from the first item

#

after the j-loop ends, it has found the minimum number in the whole array

#

it then swaps the first item in the array with the min number

#

so the first iteration of i fixes the first position

#

similarly

#

in the second iteration of i, it finds the smallest number in the array, excluding the first number which is already fixed

woven hornet
#

oh yeah

dusky cliff
#

so the second iteration of i fixes the first 2 positions

#

generalizing, after n iterations of i, the first n positions get sorted

woven hornet
#

right yeah i get it

#

the reason why they use Integer.MAX_VALUE is cuz they dunno the max value in the array?

dusky cliff
#

yeah, so the small variable gets overwritten at the first opportunity

woven hornet
#

okay thanks both i gotit!

odd sphinx
#

nice

jovial island
#

true

ebon tusk
#

!pypi pyunity

clever salmonBOT
woven hornet
#

Can I ask for stuff like sorting and searching algorithms I want to be able to code them quickly, I'm still in the midst of learning them. But I feel the transition from understanding how it works to writing the pseudocode/implementing it is hard. Like once we get the general idea, how shd we proceed?

jovial island
#

you can ask.

#

searching algos are mainly just 2 btw, linear sort (O(n)) easy af, and another sort which is done on sorted list.

#

O(logn)

dusky cliff
#

||linear search* another search*||

sinful sun
#

Binary search

jovial island
#

i forgot name

#

yeah binary search

dusky cliff
#

clairvoyance

jovial island
#

hey we wrote together.

sinful sun
#

Well thats the most popular search algo thats log n

#

Idk if theres more

dusky cliff
#

log n is probably about as good as it gets

#

I mean if you're just checking if something exists its ||almost|| O(1) with a set

jovial island
#

if data is in hash then O(1)

#

jeez

dusky cliff
#

jinx

jovial island
#

you're weird you're reading the goddamn future

sinful sun
#

Thats not really a search tho

dusky cliff
#

yeah

#

except O(1), O(log n) is probably the best possible complexity for any alg

jovial island
#

*searching algo on list(sorted)

#

Hello collections of atoms

viral hare
#

ackerman function be like

ornate mist
#

can anyone give examples of objectively oriented languages in which it is impossible to implement some Gang of Four pattern?

viral hare
#

welp i think i remember reading that the singleton pattern is rather frowned upon in python

grim seal
#

nearly there

hazy laurel
#

Rust compile times :c

grim seal
#

indeed

#

it's wild

#

this cli tool does arguably do quite a lot, so it's understandable there are a lot of deps, but sheesh

hazy laurel
#

Yes, my laptop gets fairly hot when compiling bigger programs lol

wide totem
#

@rapid zinc smh

#

you're using my people 😳

lime drum
#

when all the deps are built the build times are fast af

grim seal
#

well

#

i mean depends on how fast you consider super fast lol

lime drum
#

tbf thats extremely fast for a project that size

#

idk how long a similarly sized cpp or c project would take

grim seal
#

lol

#

that is true

#

but yeah I don't do enough large rust projects to know

lime drum
#

also thats completely ignoring the speed of dev builds

#

which are wicked fast

grim seal
#

ya this is a dev build

lime drum
grim seal
#

yeah

#

on a macbook air, bear in mind lol

lime drum
#

bruh

#

how long did the release build take KEKW

grim seal
#

lol, will try release

viral hare
#

can cargo build with multiple threads

lime drum
#

yeah

viral hare
#

like can u specify or sth

lime drum
viral hare
#

or does it pick a number for u

grim seal
#

oh fuck no nevermind, lol. not waiting for all this lol

viral hare
#

building llvm be like

lime drum
viral hare
#

1 hr build time

lime drum
viral hare
#

thats like if u run make with out specifying any cores

#

which is like gg

terse bison
#

Hello

real forum
#

OMG YES

#

ITS TIME

#

I am now famous

median blade
#

No

upbeat sandal
#

!e print(True * 3 + (True + True) + True * 7)

clever salmonBOT
#

@upbeat sandal :white_check_mark: Your eval job has completed with return code 0.

12
upbeat sandal
#

That was Chili's idea

real forum
#

yes but instead of being a normie and writing True I spammed a bunch of dunders and achieved the same thing

upbeat sandal
#

Okay but what about

#

!e print(21 << True)

clever salmonBOT
#

@upbeat sandal :white_check_mark: Your eval job has completed with return code 0.

42
upbeat sandal
#

!e print(((21 << True) ^ 384) - 6)

clever salmonBOT
#

@upbeat sandal :white_check_mark: Your eval job has completed with return code 0.

420
upbeat sandal
#

@real forum BLAZE IT

real forum
#

lmao SHEEESH

sweet wind
upbeat sandal
#

you shift all the bits to the left. Why would you want to do this? no clue.

sweet wind
#

interesting. Haven't touched to bit shifting in a while. So shifting 21 in binary by 1 makes it 42, am I right?

hazy laurel
#

bit shift to the left, yes

sweet wind
#

yeah, I just played with that in an interpreter and now I got it. Thanks

scarlet totem
#

x << y == x * 2 ** y, x >> y == x // 2 ** y

median blade
#

ok

jovial island
#

bye

odd sphinx
#

damn

dim root
#

@idle comet reloading is fucking amazing! Thankyou for doing it!

copied the folder locally and messing around with it

odd sphinx
#

lol

#

wtf

odd sphinx
#

@keen burrow typo! in #pixels-announcements You can now run an HEAD request you probably mean You can now run a HEAD request

keen burrow
#

aha, thanks

odd sphinx
#

the french got to u

keen burrow
#

It totally did

odd sphinx
#

lol

#

oh another grammatical error

#

rate-limited endpoint to know how what is your current rate-limit state without actually interacting
you probably mean
rate-limited endpoint to know what your current rate-limit state is without actually interacting

#

@keen burrow ^ (sorry for double ping)

keen burrow
#

smh

#

thanks!

dusky cliff
#

damn

#

zeeshanok more like correctionop

languid osprey
#

Lol

odd sphinx
tranquil ridge
odd sphinx
#

yes

dusky cliff
#

correction OP

#

correctionop

#

I didn't stutter.

odd sphinx
#

ok

full marlin
#

what is pixels

full marlin
#

oh

#

cool

median blade
#

Hi daspecito

jovial island
#

long time no see

#

heyy

idle comet
grave scaffold
#

So i am doing an internship and unable achieve targets what to do

#

??

#

Its been 3 weeks

fluid haven
#

@rustic lagoon Ah I found it, it's called slicing

#

[start:stop:step]

rustic lagoon
#

ecplain

#

explain*

fluid haven
#

[::-1] goes in reverse

#

[2:8:2] for example starts at 2, stop at 8 and steps 2 at a time

rustic lagoon
#

but like

#

how do you use it

fluid haven
#

!e
print("Hello that one dude"[2:8:2])

rustic lagoon
#

what is it used for

clever salmonBOT
#

@fluid haven :white_check_mark: Your eval job has completed with return code 0.

lot
fluid haven
#

Making selections from strings

rustic lagoon
#

I see

fluid haven
#

Personally mostly reversing strings

rustic lagoon
#

!e py print("This gonna be reversed"[::-1])

clever salmonBOT
#

@rustic lagoon :white_check_mark: Your eval job has completed with return code 0.

desrever eb annog sihT
rustic lagoon
#

YES

#

thx man

jovial island
viral hare
#

keyboard warrior it seems

hot pulsar
#

@wooden panther just one book, its on the web nothing to purchase. scroll down a bit. some of it is super simple but given your q about return in a for loop id recommend reading through it all quickly

#

sry was away didnt answer when u asked

proper python
#

this image has more layers than a coconut

jovial island
#

I believe Shrek liked coconuts.

shadow elk
#

@sterile pelican
If I host a microservice using a GPL library, do I have to make all code that sends requests to that microservice GPL-licensed?

mint solstice
#

well isn't that not including a copy of the code?

sterile pelican
shadow elk
#

then that's the most ridiculous license ever

mint solstice
sterile pelican
#

well, that's kind of the whole point of GPL, to prevent close-sourcing any projects, if you only want to prevent close-sourcing of a work based on your library, i.e. a derivative, you can license under LGPL so that people who just use your lib are fine and can use some other license

junior moat
#

gpl was designed to be ridiculous, yeah

#

basically it tries to turn copyright on its head forcefully, using its own laws against itself

sterile pelican
junior moat
#

i'm not saying it's bad

sterile pelican
shadow elk
# shadow elk <@!306876636526280705> If I host a microservice using a GPL library, do I have ...

Okay, let's take this scenario:

  1. Someone writes a microservice "A" without using any GPL code, so e.g. the microservice code is MIT-licensed.
  2. I write a piece of code "B" that talks to that microservice. I license it under the MIT license.
  3. The author of microservice "A" rewrites it from scratch using a GPL library, but preserves the same interface.

Does the piece of code "B" now have to be licensed under GPL?

sterile pelican
#

no as long as you use the non-updated version

shadow elk
#

Or:

  1. A person writes two implementations of a library (with the same interface), one implementation is licensed under MIT, another one is licensed under GPL.
  2. I write a piece of code that imports that library.

Do I have to license my code under GPL?

shadow elk
junior moat
sterile pelican
junior moat
shadow elk
#

So what's the difference between:

import library_licensed_under_gpl

print( library_licensed_under_gpl.some_function(42) )
``` and ```py
def some_function(n: int):
    r = requests.post(f"https://api.that-uses-a-library-licensed-under.gpl/{n}")
    return r.json()["result"]
print( some_function(42) )
```?
sterile pelican
#

the API author could probably try and make a case against you, but I very much doubt he'd succeed with something like that, though it's possible, since GPL simply isn't clear on this

sterile pelican
junior moat
#

I think part of the problem is that there also isn't much legal precedent on these matters

shadow elk
#

it seems that GPL brings up lots of paradoxes that weren't considered when it was created

sterile pelican
#

yeah, that it certainly does

junior moat
#

the GPL library copyright holder might take you to court on these and who knows what the outcome will be

sterile pelican
#

but I doubt any api author would realistically try to enforce usage of GPL to clients since his API is GPLed

#

but yes, if the author would decide to take it to the court, the outcome is unclear

shadow elk
#

I think I'll stick with MIT for my projects 👀

#

I don't think I'll ever understand GPL

junior moat
#

well

#

the good news is that if you decide to use GPL

#

you don't really have to enforce it

#

if you're the copyright holder that is

sterile pelican
#

I do like using GPL for some of my things, but I'd never enforce those minor things on anybody

#

and I doubt I'd have any success even if i tried doing so, though again, it's technically possible

shadow elk
#

I think the idea that importing a library is making a derivative work of it doesn't really make sense.

woven hornet
#

why in sorting, we can't directly exchange two values, but we have to create a temp to swap them?

dusky cliff
#

you can swap directly in python with something like a, b = b, a

#

and you can swap two numbers in any lang without a temp variable with a trick

#

but in general its not possible to swap two vars without a third

#

something like

a = b
b = a

won't swap a and b

#

both a and b will end up with the value of b

#

because when it gets to the second line, the value of a has changed to that of b, and the original a has been lost already

woven hornet
#

oh

dusky cliff
#
a = a + b
b = a - b
a = a - b

its a bit hard to explain in words, just work it out for two numbers and you'll see

woven hornet
#

oh wow yeah

dusky cliff
#

show 👀

undone root
#

xor is the poggest one

dusky cliff
#

ye it works
e🅱️ic

#

i read an article on xor tricks on reddit some time back

#

finding duplicates in lists and stuff

viral hare
#

xor only really works when ur thing fits in one register

dusky cliff
#

hmm

woven hornet
#

oh ok, i think i asked this before but i still dont get it
lets say the array is [5,2,4,3],
array clone = [5,2,4,3]

for the first iteration, i = 0, j= 0
since 5 < 2147483647,
small = 5, smallIndex = 0

for the next iteration, i = 1, j=1,
(a side qn, does small reupdate to 2147483647 or it remains as 5 when the i loops again)
since 2 < 5,
small = 2, smallIndex = 1,

then swap(newArr, 1, 1)?
wouldnt that be swapping nth

dusky cliff
#

the j loop is nested inside the i loop
you're not considering the (i=0, j=1), (i=0, j=2)... etc iterations

#

when the inner j loop ends, smallindex will be 1 (the index of 2, the smallest no. in the arr)

woven hornet
#

lemme try again

woven hornet
wide totem
#

Like,

#

As the only feature of your library, and then shipping that

woven hornet
#
public class sort {
    static void swap(int[] arr, int i1, int i2) {
        int temp = arr[i1];
        arr[i1] = arr[i2];
        arr[i2] = temp;
    }
    
    static int[] bubbleSort(int[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = i; j< arr.length-1; j++) {
                if (arr[j+1] < arr[j]) {
                swap(arr, j, j+1);
                }  
            }
        }
        return arr;
    }
    
    public static void main(String[]args) {
        int[] x = new int[]{10, 40, 30, 20};
        System.out.println(bubbleSort(x));
    }
#

why is the output so weird?

woven hornet
#

I tried to create a function which bubble sorts

#

But the output is some string of characters

odd sphinx
#

can u print out arrays in java?

dusky cliff
#

not directly no

#

System.out.println(Arrays.toString(arr))

#

and you'd need to have java.util.Arrays imported

#

or java.util.*

#

@woven hornet

odd sphinx
#

thats probably the issue

dusky cliff
#

ye

jovial island
#

oh wait no we can't print array like that, it may be printing its address

#

yeah that was the issue

#
public class sort {
    static void swap(int[] arr, int i1, int i2) {
        int temp = arr[i1];
        arr[i1] = arr[i2];
        arr[i2] = temp;
    }
    
    static int[] bubbleSort(int[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = i; j< arr.length-1; j++) {
                if (arr[j+1] < arr[j]) {
                swap(arr, j, j+1);
                }  
            }
        }
        return arr;
    }
    
    public static void main(String[]args) {
        int[] x = bubbleSort(new int[]{10, 40, 30, 20});
        for(int i=0; i<x.length;i++){
            System.out.println(x[i]);
        }
    }
}

This works fine

woven hornet
#
public class sort {
    static void swap(int[] arr, int i1, int i2) {
        int temp = arr[i1];
        arr[i1] = arr[i2];
        arr[i2] = temp;
    }
    
    static int[] bubbleSort(int[] arr) {
        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = i; j< arr.length-1; j++) {
                if (arr[j+1] < arr[j]) {
                swap(arr, j, j+1);
                }  
            }
        }
        return arr;
    }
    
    public static void main(String[]args) {
        int[] x = new int[]{10, 40, 30, 20};
        int[] y = bubbleSort(x);
        String y = Arrays.toString(y);
        System.out.println(y);
    }
}
woven hornet
woven hornet
jovial island
woven hornet
jovial island
woven hornet
#

i tried using his Arrays.toString

jovial island
#

alright? so any error came?

woven hornet
#
javac /tmp/Q9i8rsATpT/sort.java
/tmp/Q9i8rsATpT/sort.java:22: error: variable y is already defined in method main(String[])
String y = Arrays.toString(y);
               ^
/tmp/Q9i8rsATpT/sort.java:22: error: cannot find symbol
        String y = Arrays.toString(y);
                   ^
  symbol:   variable Arrays
  location: class sort
2 errors
jovial island
#

you can't have variables of same name.

#

also you need to import the class

#

as above mentioned.

woven hornet
woven hornet
jovial island
#

Arrays is a class which in order to use we need to import just like we import scanner class.

jovial island
median blade
#

ping

hazy laurel
woven hornet
#

that's what he means

#

i see

#

okay thanks

odd sphinx
#

yes

#

or u can loop thru each elemnt

keen burrow
#

Nice timing @rigid echo

rigid echo
keen burrow
#

Discord barrier skip 101

rigid echo
#

lol

odd sphinx
#

hi