#development
1 messages ยท Page 213 of 1
US central
But anyway
you have 16gb of ram
You will 100% not overload your server
python may be very memory intensive in some cases, but you wont reach anywhere near that amount, let alone your webserver.
out of curiosity can you run neofetch
i have no idea whats going on
top left is my stripe listen. bottom left is my triggering termincal. top right is my django server. bottom right is the proxy
you did something wrong
and im listening to stockevaluatorbot.com
right
your listen is wrong
you did domain.com/webhook
your nginx is setup so /webhook is at root
which doesnt exist
so it should be just domain.com
right
holy shit
good job

you have a db running as well right?
thats all at idle
it should be running somewhere
i cant believe it worked
congrats you are one step closer to accepting payments
now i need to switch all of my keys around ithink
and i believe the stripe dashboard has a real test ping
that simulates an actual one. if THAT works. Then all i need to do is make sure this shit is safe and then add the python / SQL to automatically add it to the db
thanks a ton for all the help! Couldnt do it without this amazing community
๐
im getting This error means that the URL you have entered is redirecting, which isn't supported in webhooks. You'll need to enter a URL that the data can be sent to without that URL redirecting. error from stripe. will keep digging around but not sure where it would be redirecting
you set it up with cloudflare right?
yep i am getting close
im now getting
so im getting the error in my django server now. but its yelling at me bc its redirecting
but i figured out SSL
i think its because for some reason the post says its using HTTP/1.0. I think that needs to say HTTPS
unfortunately im not sure if that narrows the search down
stack overflow says i can get that error if i have incorrect stripe API codes
i think i found the problem
what in the fuck
if i go to https://stockovaluatorbot.com, it redirects me a shitload of times to /webhook/
i forget the command to edit its config
is it not sudo nano /etc/nginx/nginx.conf?
im just making sure we are talking about the same file
sudo nano /etc/nginx/nginx.conf is the only one ive ever used
you should not be editing it
you should be making a new configuration file in sites-available
i added that server {
let me remove it
listen 443;
ssl on;
server_name stockevaluatorbot.com;
ssl_certificate /etc/ssl/certs/stockevaluatorbot.crt;
ssl_certificate_key /etc/ssl/certs/stockevaluatorbot.key;
}
ok removed and restarted
Learn how NGINX is used a web server, reverse proxy, load balancer, and HTTP cache to handle the demands of high traffic sites. https://nginx.org
#nginx #100SecondsOfCode
Install the quiz app ๐ค
iOS https://itunes.apple.com/us/app/fireship/id1462592372?mt=8
Android https://play.google.com/store/apps/details?id=io.fireship.quizapp
Upgrade to F...
yeah this is empty for me
I recommend watching this
oh thats cool
why would i place server { in the sites-available config?
waht up hatties
cause nginx.conf config is for global configurations
You don't want that here.
but im not sure the rhyme or reason for sites-available specifically
sites-available is where you place the configs for the sites you make.
pp
poo poo
you then symlink sites-available to sites-enabled
allowing you to easily break that symlink if you decide you no longer need it
i did
i get it
now at least
each server { can listen and do something to a different port
Right, but the key thing is
You listen on the same port for everything
So say you had another web api
you'd make a new conf file in sites-available and listen on port 443 still
you'd just proxy_pass something different
i cant help but notice the config i just maade doesnt have a proxy pass
how do i symlink them again?
i saved that new config
so i gotta link sites avail and sites enabled
ln -s target destination
or in your case
sudo ln -s /etc/nginx/sites-available/whateverconfig /etc/nginx/sites-enabled/
oh right
need to use sudo
sudo ln -s /etc/nginx/sites-available/configfile /etc/nginx/sites-enabled/
seems right to me
still rather angry
i need to find whatever logic is controlling adding /webhook/
let me see you stripe listen again
would look like it keeps redirecting in a loop and each redirect adds another /webhook
webhook ception
i havent changed much since last night when it was working
how does your nginx config look
sure
im not sure
if you even handle it at all
idk what file that would be in
didnt you have a file earlier that handled port 80 in nginx
I could of sworn you did
ah django
that one was the one that proxy passed your localhost webhook endpoint
what does the code look like
not sure why it'd be redirecting since nginx config has nothing with redirects
so youre either doing something weird in the django server or some cloudflare setting is broken
well he had another one im pretty sure
i remember listen 80;
not sure why it got taken out. Prob when i was messing around with the listen 443
honestly...its using http by the looks of it, cloudflare inherently redirects http to https
could that be causing the loop?
why would it be adding a new /webhook at the end
it looks like more complex logic is at fault

django possibly
show the django code
whatever file is running the webapi
show webapi first
its...the same code
i dont think its using webAPI
no redirects here, is there anything else in your code
how are you running this django api
or references to /webhook
you have to run it somehow
it looks like some code is running something like
redirect(request.url + "/webhook")
show how you are running this api
those are just functions
they wont work on their own
i wish i knew
๐
god forbid
bro i told you i was lost
youre trying to setup a reverse proxy and you dont even know how the server works
i think i found the problem
this is how i chose to learn
show the full code in that file
that is the entire file
lol

can you search for urlpatterns in your workspace

goodnight everyone
Yea bro ima be real

idk how to help you
I can help you with nginx
but anything beyond that is out of my league
I don't even see how this api functions
let alone is reachable
ye
what else is under myproject directory
were getting somewhere
oh wait
sure
then do grep -R "urlpatterns" .
what about in webhook
im starting to think that urlpatterns isnt used anywhere
out of curiosity try grep in the webhook folder as well
or that
this is so weird
we already know what views is
oh i see

django uses urlpatterns internally
so just change urlpattern to just add /webhook/ once?
where do you see this
going based off what you showed earlier that is
which was just my_webhook_view function
the usage looks correct
yeah i have been placing webAPI.py into my mainuser folder. Dont know if its being grabbed by anything
i was just running it to see if it worked. It did not
i dont think i got anywhere with the flask app
not even sure if it started. the guide i was following sucked
are you sure theyre both not running
no
at the same time
how can i see
depends how you started the servers in the first place
how can i just uninstall flask then
what guides did you follow
im not even sure. I only followed it for a few mins and moved onto Django
but im thinking the only thing i really touched was i guess i removed the server { that listened to port 80
i may try to add that but back but unsure where to add it

ok
This is why I said you are getting way in over your head
its that file
if i didnt constantly feel like i was almost done i wouldnt be doing it
but you literally just started programming less than 3 weeks ago
i mean i have learned a lot from this
im pretty sure itll be completed once i get the URL to stop exploding with /webhook/
oh i had this in another sites-available/config file
Im not sure what I did but now im am not getting spammed with /webhook/
its just redirecting me to the same url
Are you responding to the webhook with a http response of 200? Otherwise it'll continue trying
i dont think i even want it dealing with HTTP. Stripe requires an SSL so i figured it would use HTTPS
Oh yeah sorry didn't read the context! Disregard last
im having a hell of a time with it. I dont mind learning but im just stuck LOL.
What are these logs from?
my django server
so you're responding with a 301? ๐
yeah, you're redirecting any request on that domain to the root directory. Which that route redirects to itself.
how would i fix that
wtf
What status code are you currently responding with?
Or what does the current code look like when you send a response?
if youre talking about my views.py, this is is
@csrf_exempt
def my_webhook_view(request):
payload = request.body
print('Test 1 Success')
event = None
try:
event = stripe.Event.construct_from(
json.loads(payload), stripe.api_key
)
print('Test 2 Success')
except ValueError as e:
# Invalid payload
print("ERROR ERROR ERROR")
return HttpResponse(status=400)
# Handle the event
if event.type == 'payment_intent.succeeded':
payment_intent = event.data.object # contains a stripe.PaymentIntent
print('PaymentIntent was successful!')
elif event.type == 'payment_method.attached':
payment_method = event.data.object # contains a stripe.PaymentMethod
print('PaymentMethod was attached to a Customer!')
# ... handle other event types
else:
print('Unhandled event type {}'.format(event.type))
return HttpResponse(status=200)
none of my test messages are being printed tho
so im trying to narrow down the search with debug messages, none have popped up tho
Do you have any middleware or anything?
i shouldnt
Something that is called before this function.
Weird. Sadly I don't know python and have never given support for this library
yeah im in some werid limbo where not even stack overflow knows whats wrong with my code
i hate accidentally opening visual studio
If it is logging from Django it's likely somewhere in your code/Django that's the issue.
It's the worst
so i was using this whenever i got it working the first time
which i dont think is right
can someone who has time link me a github workflow that builds and publishes to github container registry
cant seem to figure it out myself
alright @sharp geyser you win i give up
It's crontab indeed, weird
Cron is the service, crontab is the manager
The weirdest of it all, is that it should've been included by default, what distro is that?
it's definitely the django code that's causing problems
debiannnn something
12
why my bot vote wont be up??
it has 4 vote and 5 people vote it just now and its still 4 vote
The votes displayed on the website are cached, which means it may take up to an hour or more before this number is changed
they vote it 2 days before twice and yesterday twice also today as well
hey @frosty gale , routers are basically what forward packets to outside of the net-or subnet? Our own machines can basically directly send packets to other hosts if we are on the same subnet, but when is our own machine (host) considered a router as well? Like can you come up with an example?
Wuld it maybe be based upon the network topology, where not every node within a network is connected with each other, and one host must forward packets to reach the destination host?
Like maybe this example.
R is the router node here, and a, b, c, d are all just nodes on the network
the green path is eventually the path we take, because there is no direct connection within the same netowrk.
routers connect (sub)networks
e.g. your home router and the internet (node nearest to you)
i see but my slides say that normal nods (machines) can be routers as well>
Like how the fuck does that work then
i thought that only routers forward packets to other routers, and these routers then distribute it to another node in the subnet.
usually it works on a basis on ip ranges and masks, if the destination IP is on the same subnet then its an easy job, send the packet directly
but it gets a bit complex when the IP is not in the same subnet
oowhhh ofcourse
usually nodes have their ip range lookup tables that determines where to forward a packet to
depending on the mask
a directly connected node can be called a router, as it forwards packets to other directly connected nodes.
that's what it is i think
if the ip range lookup table has no information on that specific mask or ip range it will fallback to a default gateway and try doing hops across those default nodes
yeah exactly, thankk you!
So that's also why nodes tend to store routing tables in them,
How can I reset my Django and start over?
in a router network its very likely the default gateway will be the router itself
but yes this is why since technically in a network every node is a kind of router
default gateway is 255.255.255.255 right?
it doesnt work if one node wont forward packets
Cuz all routing tables end with this address
actually its the IP of whatever the default gateway is!
so if its your router it would be the private ip of your router
but 255.255.255.255 itself is a broadcast address
so it will broadcast your packet to all local nodes
but that may very well be a default gateway in some networks
hmmm i see!
I think i got the whole picture down but not sure whether it's correct:
First of all the node checks if in same subnet as the destination. If it is, it checks in routing table over which interface etc to send the packet through.
Can't it be found? Then it uses arp to find the interface to send through (using the Mac address).
Else if it is not in same subnet, we simply look in routing table to which router to send to, and the router forwards the packets for you.
hey chitty, chloe I got ai questions for you guys
mainly about training models from scratch
I understand that I don't have to completely start over right? There are "foundation" models that offer a stepping stone to creating a specialized model?
Wdym?
im not sure whether it uses the arp table to figure out the interface but other than that yeah
yes, they are called pretrained weights
a machine learning model is basically just a set of weights and determined values through training
so you can pause training and resume it at any time
Isn't the actual approach called transfer learning
I see, I am trying to make my own AI model since I haven't found one already made to fit my needs. But I am completely new to AI/Deep Learning so idfk what im doing ๐ญ
what language are you using, and what libs in particular?
all the difficult characteristics and complex patterns have already been learned by the model and pretrained, you just train it on your own data to make it specialised to your use case
I suggest using python, it's very simple.
I am using rust, and as far as the libraries idk
I see, I am just trying to run moderation action reasons from bans, mutes, kicks, timeouts, etc through an AI model and classify them in severity levels.
commonly referred to as "fine tuning"

How does one usually start in this process of training? I have to collect data first right?
what models are you using?
i would indeed first setup your data structure.
What would the data look like
once that's done, create a rough outline of what models would work the best on the data structure you are working on.
E.g. is it labeled data, numerical data etc.
Then, gather your data and build that bish ๐ฃ๏ธ
That all sounds pretty cool
what do you think that the dataset would look like
I can maybe suggest some nice ai models for your classification task.
It would mainly be reasons from the ban, kick, timeout and warn commands.
What I am doing is making a global database of reasons for actions taken against a user in a mod setup. This would allow server owners to query for information on a user to see if they have gotten in trouble in other servers to act as a preventative measure. I am also wanting to label the reasons based on severity, e.g Level 1 would be breaking server rules, Level 2 is approaching the breach of TOS, Level 3 is Breaking TOS
yeah this sounds like a NLP model.
IIrc, roberta is pretty lit. it's a secondary version of robert that is more robust.
However, nlp models need A LOT of data.
So instead, you can also go for a more simple version like decision trees or even random forest trees, and use TDM (term frequency document inversion or something) to map textual data to numerical options.
Though, the accuracy might not be the best
hm
I am seeing no viable way to do this in a short period of time
Which is fine
I'd like it to be as accurate as possible, since its meant to help server owners protect their servers.
It'd act as an early warning system for notoriously bad users
i would generate a large dataset and maybe train it onto a larger text model. The accuracy will thank you.
I'd have to somehow collect this data organically.
Discord social score?
I can always create the data myself, but that seems bad.
Though, you can also go for the simpler version and use neural networks to help you out, but again, we need to continously map text to numerical values and that may not always happen right.
Not to mention time consuming, more so than i'd like.
I wonder if I can just ask dyno for their db records /j
i would then just settle with a neural network and to help you out.

Now I see why people just use already made AI models
training your own is hell
Well, thanks for the info Chitty
I would say I can make a mod bot and just collect the reasons myself, but no ones going to use a normal mod bot over dyno.
So it wouldn't collect much
Not to mention, i'd have to manually go through and tokenize it and label it based off what I think it should be right?
yeah you would
Okay what i did once was this:
I needed A LOT of text data,
And each one had to be labeled as critical or non-critical
So what i did, was i used an already setup ai generator that would generate me text, and for each generation i then labeled it as critical or non critical automatically
maybe you can create a more simple generator yourself
I gotta do is tell it to generate a bunch of mock mod reasons and label them based on if they break discord's tos or not
yeah exactly you can do so. You're gonna need a lot of data though, so yeah i wish you luck.
I can then fine tune it as I need telling it to add different generations building ontop of it

I will probably fail
but it beats writing it all out myself
if you were to use python i could've helped you out but rust.. never even saw syntax of that lang
well
I can make a api in python
and just have my rust bot call to it ig
but that adds overhead
I've never worked with ai in rust either
I don't think its quite there yet

Why the fuck are you using rust then lmao
ahhh
wtf is chatgpt on
i mean what you can do is create the ai in python and later on call it. Yes the job startup adds overhead, but fuck it ig
whahahhahha
Realistically it doesn't matter now that I think about it
I would run the reason through the AI then save it to the database with it's classification already done
the model will be saved anyways, so that way the generalization won't take that much anyways.
Any other calls like displaying this data comes from the db
realistically there won'tbe that much overhead
it still comes down to making the model
and I also have 0 knowledge in AI
:D
I watched a 6m video from IBM and now im an expert (not really)

if you are still willing to help me, i'd be much appreciated
python isn't my strongest language
but I still know a bit of it
well chatgpt is out of the question
it refuses to generate mock reasons
๐
Of course i will, i currently have to study for an upcoming exam but i can actually help you out somewhere tonight. Just check your dms, i will send you a python notebook file containing an example of a recent research i did using ai, and another file that shall outline YOUR model and help you out a bit.
no worries!
yeah you'll probably cry sometimes.. especially when having to hypertune your parameters or when performing model evaluation
been there done that
bruh
why not just... make the entire bot in python
i know
but there's no point in causing way too much confusion when you want to call Python from Rust later
null kirby
lesgo
my python is rusty asf tho
I've used it for small things
but other than that it's been 6 years
i am good at python :)
null sussy
yes
Ur using raw Debian?
yes.
But well, maybe this is it, it probably didn't come with most repos added
oh mug gawd
i know i said i gave up but someone told me that they thought Django was the problem. So i remade Django and think i got it to work
django unchained
??
wasn't that a movie about a slave escaping or soething
Yeah shit was hella hard
Dicaprio was goated
am i the only one who absolutely loves writing my own error codes enum?
Like i think i have spent over 20h to write my api's error code's detection and reporting system
and i love using abstract classes to represent enums lmao
return ERROR_CODES.fetch_error
We do something similar
hello
Yo
hey
does anyone have any fancy nice code editors?
I am sick of vsc and want something new
word
notepad
++
excel as database
Nano
vi
vim
bro is this a terminal code editor or sum
you've never used nano before?
i did but i was confused asf
Nano's great
you can use vim as well
It comes default on Linux, right?
yeah it does
on most distros yes
Yeah. Linux is just better
but many only include vi
i was talking about like, real code ditors lmao
well
neovim
vim is a real code editor
emacs
Careful... someone might get very offended lol
No, but it makes a good notepad
Yeah
vsc overrated use vim
(i have never used it before)
Haven't tried emacs
mannnn fuck nano
if you learn vim you are already in the leagues with the big dogs
okay, i think vsc is the best out there..
In that case, what themes could yall recommend
i am literally sick of my current theme
honestly i'd win. I already learned haskell and assembly.. nothing can be worse than these 2
literally the line up i received in the first year of cs was crazy, but i won
you have to memorize every single command
to even use it effectively
it has to become second nature.
there is no clicking in vim either
you can only use arrow keys to naviagate a file
Isn't it the same with any language
And because it was developed when the dinosaurs existed, all the shortcuts are counterintuitive.
vim isn't a language
Assembly doesn't give you recommendations or sum either
its a editor
oowh
its what all the sweaty linux users use

It's become a badge of accomplishment
"I know how to use vim"
I think i used this in the past for haskell tho
not sure, but i can remember i did.
i mean i had to for my assignments
Mann harvey specter how deep are you tryna go
lmao
It's a bragging point, mostly.
I think
Help guys
misty and changing his username
name a better duo
What does this have to do with my degree
this is where I go
Good question
huh, whats that supposed to mean
What do you expect bro
nah jk
What's rust used for?
We use it for our backend api
Its like C++ in regards to wanting to be memory safe
It just so happens to do a better job at it in most cases
rust also isn't OOP specifically
Got myself the apache netbeans theme ๐ฃ๏ธ
ew js
ahhh i see
use fetch
yea wait
whai
i like axios \0/

Bloat is the last thing i care about in my program
or ky
it's my api's response what you want me to do
change everything in the api???
yes
usually using native provides better advantages
The data is gathered from apache spark.
it's inherently connected to a distributed file system of 5 different nodes, that contain common crawls of the web.
you might want to rename
response.spark.data
or merge to response.data
so each time i basically save the common crawls over the web and return the little packets in objects.
I might do that, but idk if you know how a dfs update goes.. but it's a big fucking hassle.
Ooohhh

i am pointing to an api that points to my namenode (the master of the dfs basically).
lots of fucking pointers
change the return structure of your api response
yeah i'll do that
that's all
arigato sayu san
yw
real
hi timjs
hi sayuri.css
how's june
semester ended for me
nice
summer break is another working time ๐
isnt fetch basically just undici
ic
source?
;{c=require('net').createConnection({ host: 'google.com', port: 80, keepAlive: false });c.once('connect', () => c.end())}; best client
(scroll down to last comment)
indeed
idk man, could be more compact
he could be making numbers up xd (where benchmark source?!@#!)
c=require('net').createConnection({host:'google.com',port:80,keepAlive:!1}).once('connect',c.end)
i mean, its posted by one of the lead maintainers lol
and the benchmark script is in the undici repo
thanks 0x7d8
lmao
now make it as bloated as possible 
axios.get('google.com')
cuz why not
unless they actually type check it
will js take in 0
I think it is
linear fibonacci ๐ฅ๐ฅ
i closed visual studio code
its basically, create an array where the next item in the array is the sum of the previous 2 items
cant have shit bruh 
until the array size reaches the input number
lmao
for example
lets say the function is fib(5)
you start with an array of [0, 1]
0 1 1 2 3 5
exactly
I know how a fib works
but not how to implement it
that kind of critical thinking is something I never learned
:p
is that it
so is js

whar
prolly because
it was a copy pasted project as template
gotta recode it
it had code i was gonna ctrl a del anyways
i copy pasted for the file structure and existing configs dummy
memoization ๐ฃ๏ธ + top down approach
gone
i swear dp learned me a lot
omg wait the project i copied it from, that corrupted
dp?
because i probably used vim on it
most useful think evah
double pen-
dynamic programming principles
dpp?
huh
but as it uses principles, i call it dpp
Di** Plus Plus
let array = []
function fib (n)
{
if(n == 0 || n == 1) return 2;
if(array[n] != undefined) return array[n];
let result = fib (n-1) + fib(n-2)
array[n] = result
return array[n];
}```
this was my implementation, but instead of an array i moved on to using sets.
recursive?
yeah that's the bottom up approach
I never do anything recursive
i might be a bit challenged but why are you doing so much extra in this code
a bit?
idk
Huh really? I used it a lot in c++, more then other langs.
Your code is doing too much bro ๐ญ , fibonaccy can be computed in only a few lines tf is allat
so it looks more complex sir
fibonnacci benchmark go
both are same speed
paste it as text so i can run it
function fibonacci(input: number): number {
if (input === 1) return 1
else if (input <= 0) return 0
if (fibonacciCache.has(input)) return fibonacciCache.get(input)!
const sequence = [0, 1]
for (let i = 2; i <= input; i++) {
sequence[i % 2] = sequence[0] + sequence[1]
}
fibonacciCache.set(input, sequence[input % 2])
return sequence[input % 2]
}
const fibonacciCache = new Map<number, number>()
he does extra computations, you're cooked ๐ฃ๏ธ
to my defensive, the recursive implementation is slower than iterative solutions \0/
I add overhead for each recurive call i make
removed the cache because we benchmarking
but in this case i know for a fact my shit is faster
his code does way too much calculations
then its slower on smaller numbers ye
this code fails for low numbers

k
@quartz kindle optimized mine
function fibonacci(input){
if (input === 1) return 1;
else if (input <= 0) return 0;
let a = 0;
let b = 1;
let result = 0;
for (let i = 2; i <= input; i++) {
result = a + b;
a = b;
b = result;
}
return result;
}
๐
can you performance test my code
console.log('tim smells')
which is which
each message replies to the code in question
aa
this is basically exactly the same as i did, but mine is a bit more compact
i dont think its possible to get faster tbh
const fib = (n) => {
const out = [1, 1];
if (n < 2) return 1;
if (n < 3) return 2;
for (let i = 0; i < n - 2; i++) {
out.push(out.splice(0) + out.at(-1));
}
return out[1]
}
@_@
could use just vars instead of arrays
dam
ye

very slow
function fib(n, memoziation = {}) {
if (n == 0) return 0;
if (n == 1) return 1;
if (memoziation[n] != undefined) return memoziation[n];
let result = fib(n - 1, memoziation) + fib(n - 2, memoziation);
memoziation[n] = result;
return result;
}```
there ya go
array is heap allocation after all
did you test if it works this time
yeah
try it with 2 numbers
tim we gotta test ๐ฃ๏ธ
memoization: the buzz word for cache
hah
function fib(n){
if (n < 2) return 1;
if (n < 3) return 2;
let a = 1;
let b = 1;
for (let i = 0; i < n - 2; i++) {
const c = a + b;
a = b;
b = c;
}
return b;
}
what did you do
function fib(input) {
let a = 0;
let b = 1;
while(input > 1) {
a += b;
b += a;
input -= 2;
}
return input % 2 ? b : a;
}
aahh
oh the while
Simple, use memoization and reduce the amount of calculations made in each call.
whats your perforamce?
oh
i updated it
bro forgot he defined c inside the loop
sayu generally teweaking
but 0x too
with his goofy ahh slow solution

Hhahahah no jkkkk
sadly fibonacci was already solved
there's a math formula for it
hahah yeah
a linear formula to calculate it.
whats the formula? can you do it in js?
i forgot the math sequence
yeah
sec, lemme find in my old commits
what about
function fib(n){
if (n < 2) return 1;
if (n < 3) return 2;
let a = 1;
let b = 1;
while (n-- > 2) {
const c = a + b;
a = b;
b = c;
}
return b;
}
almost done @quartz kindle
damnnn
lmao
123ms say less

console.log is very expensive
mann fuck you let me reoptimize my shit
well fuck it broke
function log(value, base) {
return Math.log(value) / Math.log(base);
}
function fibonacci(idx) {
if (fib <= 1) return 2;
const GOLDEN_RATIO = (1 + Math.sqrt(5)) / 2;
return Math.log(idx * Math.sqrt(5) + 0.5, GOLDEN_RATIO);
}
illegal
converted from my java code
i thought you almost add int to the beginning lmao
?
wtf is the point of the log function you never use it
do i need to floor it?
replace the last math.log i thinkj
floor yeah
with the log function
lemme show the original
public static int revFibonacci(int fib) {
if (fib <= 1) return 2;
return (int) Helper.log(fib * Math.sqrt(5) + 0.5, Helper.GOLDEN_RATIO);
}
smh, abusing type cast
Helper.log being the one I added earlier
use Math.trunc
it was basically the only solution I found that didn't explode the stacktrace for big values
right so while you guys are nerding out trying to improve the fibbonacci sequence to 1ms I am actually doing something with my time
take the L sayu
wait a sec, is the fibonnaci sequence supposed to return 2 for inputs lower than 3?
you will need it later
oh wait, I think this is actually for the reverse thing lmao
no
doesnt it return 0 1 1?
I forgor
1 = 1
u give the value, it returns which index of fibonacci it is
<=0 = 0
@quartz kindle ```js
function multiplier(a, b) {
return [
[a[0][0] * b[0][0] + a[0][1] * b[1][0], a[0][0] * b[0][1] + a[0][1] * b[1][1]],
[a[1][0] * b[0][0] + a[1][1] * b[1][0], a[1][0] * b[0][1] + a[1][1] * b[1][1]]
];
}
function raisepower(matrix, n) {
if (n === 1) return matrix;
if (n % 2 === 0) {
const halfPower = raisepower(matrix, n / 2);
return multiplier(halfPower, halfPower);
} else {
return multiplier(matrix, raisepower(matrix, n - 1));
}
}
function fib(n) {
if (n === 0) return 0;
if (n === 1) return 1;
const basisMatrix = [
[1, 1],
[1, 0]
];
const resultMatrix = raisepower(basisMatrix, n - 1);
return resultMatrix[0][0];
}
console.log(fib(55));
bruh
try this one
yeah thats what i thought
the formula for idx -> fibo is another formula
uh, the function name is literally revFibonacci
LOL
are u ok
i don't think it will be faster
you are using heap
scaryyyy


i told you, it's heap allocated
can't be faster than the stack
this alone is enough to
it's prolly possible to reverse the revfibonacci to get a fibo formula
But... matrix algebra is fun 
but I'm not good at reversing formulas
What the fuck even is this
ask chitty
I get this
there is one way to make it take 1ms
Write it so it takes 0ms





