In computing, memoization or memoisation
is an optimization technique used primarily
to speed up computer programs by storing
the results of expensive function calls and
returning the cached result when the same
inputs occur again.
— wikipedia
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
import React, { Component } from 'react'; | |
import ReactSelect, { components } from 'react-select'; | |
const TextOption = props => ( | |
components.Option && ( | |
<components.Option { ...props }> | |
... | |
</components.Option> | |
) | |
); |
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
const isEqual = (a, b) => { | |
const aKeys = Object.keys(a); | |
if (aKeys.length !== Object.keys(b).length) { | |
return false; | |
} | |
return aKeys.every( | |
(k) => Object.prototype.hasOwnProperty.call(b, k) | |
&& a[k] === b[k], |
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> | |
<head> | |
<meta charset="utf-8"/> | |
<title>`value => value` vs Boolean #jsbench #jsperf</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
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
// https://codepen.io/P3R0/pen/MwgoKv | |
var matrix = (function(){ | |
var init = function() { | |
document.body.style.background = 'black'; | |
var mdr = document.createElement('canvas'); | |
mdr.id = "mdr"; | |
mdr.style.display = 'block'; | |
mdr.style.position = 'fixed'; | |
mdr.style.top = '0'; | |
mdr.style.left = '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
--scrollbar-thumb-width: 9px; // bigger = smaller width | |
--scrollbar-thumb-margin: 3px; | |
--scrollbar-thumb-color: rgba(255, 255, 255, 0.25); | |
/* Chrome-like (mobile) scrollbar */ | |
&::-webkit-scrollbar { | |
width: var(--scrollbar-thumb-width); | |
} | |
&::-webkit-scrollbar-thumb { |
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
# delete local tag '12345' | |
git tag -d 12345 | |
# delete remote tag '12345' (eg, GitHub version too) | |
git push origin :refs/tags/12345 | |
# alternative approach | |
git push --delete origin tagName | |
git tag -d tagName |
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* fibonacci(limit = Infinity) { | |
let [prev, current] = [0, 1] | |
while (current < limit) { | |
;[prev, current] = [current, prev + current] | |
yield current | |
} | |
} | |
for (let i of fibonacci(30)) console.log(i) |
NewerOlder