Skip to content

Instantly share code, notes, and snippets.

View obrenoco's full-sized avatar
🏗️
building things

Breno Romeiro obrenoco

🏗️
building things
View GitHub Profile
{
"name": "learn-semver",
"dependencies": {
"update-patch": "~0.0.1",
"update-minor": "^0.1.0"
},
}
@obrenoco
obrenoco / fibonacci.ts
Last active January 10, 2022 01:55
Fibonacci
// using phi - best performance
// see: https://akuli.github.io/math-tutorial/fib.html
function fibonacciGoldenRation(n: number) {
const phi = (1 + Math.sqrt(5))/2;
const asymptotic = Math.pow(phi, n) / Math.sqrt(5);
return Math.round(asymptotic);
}
// using for() loop
const fibonacciForLoop = (num: number) => {
function shuffle(array) {
var m = array.length, t, i;
while (m) {
i = Math.floor(Math.random() * m--);
t = array[m];
array[m] = array[i];
array[i] = t;
}
return array;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Static Template</title>
</head>
<body></body>
<script>
@obrenoco
obrenoco / pre-load.html
Last active May 2, 2022 02:56
pre-loading
<div id="loading-page" class="loading-page">
<div class="loader"></div>
</div>
<div class="content">
<h1>Page loaded!</h1>
</div>