A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.
One-line version to paste in your DevTools
Use $$
if your browser aliases it:
~ 108 byte version
type Shoe = { | |
purpose: string | |
} | |
type ShoeFactory = { | |
create(t: 'boot'): Boot | |
create(t: 'balletFlat'): BalletFlat | |
create(t: 'sneaker'): Sneaker | |
create(t: string): Boot | |
} |
/** | |
* 二分查找有序数值列表 | |
* [1, 4, 10, 300, 5000000] | |
* | |
* Benchmark 结果, | |
* | |
* [1, 4, 10, 300, 5000000].findIndex((el) => el === 500); | |
* 原生 x 95,827,672 ops/sec ±0.87% (88 runs sampled) | |
* | |
* findIndex(500, [1, 4, 10, 300, 5000000]); |
Markdown 8 mins ███████████████████▌░ 93.3% | |
Bash 0 secs █▍░░░░░░░░░░░░░░░░░░░ 6.7% |
// /-> INSERT -> EQUAL | |
// EQUAL | /-> EQUAL | |
// \-> DELETE | | |
// \-> INSERT -> EQUAL |
If you haven’t worked with JavaScript in the last few years, these three points should give you enough knowledge to feel comfortable reading the React documentation:
let
and const
statements. For the purposes of the React documentation, you can consider them equivalent to var
.class
keyword to define JavaScript classes. There are two things worth remembering about them. Firstly, unlike with objects, you don't need to put commas between class method definitions. Secondly, unlike many other languages with classes, in JavaScript the value of this
in a method [depends on how it is called](https://developer.mozilla.org/en-US/docs/Web/Jav// List all files in a directory in Node.js recursively in a synchronous fashion | |
var walkSync = function(dir, filelist) { | |
var fs = fs || require('fs'), | |
files = fs.readdirSync(dir); | |
filelist = filelist || []; | |
files.forEach(function(file) { | |
if (fs.statSync(dir + file).isDirectory()) { | |
filelist = walkSync(dir + file + '/', filelist); | |
} | |
else { |
/* | |
Code examples from the article: S.O.L.I.D The first 5 priciples of Object Oriented Design with JavaScript | |
https://medium.com/@cramirez92/s-o-l-i-d-the-first-5-priciples-of-object-oriented-design-with-javascript-790f6ac9b9fa#.7uj4n7rsa | |
*/ | |
const shapeInterface = (state) => ({ | |
type: 'shapeInterface', | |
area: () => state.area(state) | |
}) |
console.reset = function () { | |
return process.stdout.write('\033c'); | |
} |