This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="loading-page" class="loading-page"> | |
<div class="loader"></div> | |
</div> | |
<div class="content"> | |
<h1>Page loaded!</h1> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "learn-semver", | |
"dependencies": { | |
"update-patch": "~0.0.1", | |
"update-minor": "^0.1.0" | |
}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type CallbackProps = (...args: any[]) => any; | |
const useCallback2 = <T extends CallbackProps>( | |
y: T, | |
dependencies: unknown[] | |
): T => { | |
const [myState, setMyState] = useState<T>(() => y); | |
useEffect(() => { | |
setMyState(() => y); | |
}, dependencies); | |
return myState; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Default importing | |
import Func from 'utils' | |
// Entire content importing | |
import * as Utils from 'utils' | |
// Selective importing | |
import {Func} from 'utils' | |
// Selective importing with alias |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Functional Instantiation | |
// the weakness of this pattern is that whenever we create | |
// a new person, we have to re-create all the methods in memory, | |
// which is not cool.. | |
function Person (name, energy) { | |
let person = {} | |
person.name = name | |
person.energy = energy | |
person.eat = function (amount) { |
NewerOlder