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 fib = n => n === 0 ? [0, 1] : | |
n % 2 ? (([a, b]) => [b, a + b])(fib(n - 1)) : | |
(([a, b]) => [a * b + a * (b - a), a * a + b * b])(fib(n / 2)); | |
Array(10).fill(0).map((v, n) => fib(n)[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
function* primes(){ | |
let primes = []; | |
let i = 1; | |
outer:while(true) { | |
++ i; | |
for(let p of primes) | |
if(p % i === 0) | |
continue outer; | |
primes.push(i); | |
yield i; |
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
<body> | |
<style> | |
.number { | |
color:purple; | |
} | |
.keyword { | |
color:blue; | |
} | |
.string { | |
color:red; |
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 categories = [ | |
{id:'animals', parent:null}, | |
{id:'mammals', parent:'animals'}, | |
{id:'cats', parent:'mammals'}, | |
{id:'dogs', parent:'mammals'}, | |
{id:'chihuahua', parent:'dogs'}, | |
{id:'labrador', parent:'dogs'}, | |
{id:'persian', parent:'cats'}, | |
{id:'siamese', parent:'cats'}, | |
] |
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
/** | |
* Definition for singly-linked list. | |
* function ListNode(val) { | |
* this.val = val; | |
* this.next = null; | |
* } | |
*/ | |
/** | |
* @param {ListNode} head | |
* @param {number} 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
<body style="margin:0;"> | |
<div id="app" style="position:relative;width:100%;height:100%;"> | |
</div> | |
<script src="https://cdn.jsdelivr.net/npm/vue"></script> | |
<script> | |
Vue.component('local-storage', { | |
props: ['value', 'key'], | |
template: `<div></div>`, | |
mounted(){ | |
if(!localStorage[this.$props.key]) |
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
Vue.component('local-storage', { | |
props: ['value', 'key'], | |
template: `<div></div>`, | |
mounted(){ | |
if(!localStorage[this.$props.key]) | |
return; | |
var str = JSON.stringify(this.$props.value); | |
if(str != localStorage[this.$props.key]) | |
this.$emit('input', JSON.parse(localStorage[this.$props.key])) | |
}, |
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
<meta charset="utf-8"> | |
<body style="text-align:center"> | |
<canvas width="1000" height="1000" style="background:black;margin:auto;"> | |
</canvas> | |
<script src="tang.js"> | |
</script> | |
</body> |
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"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
<style> | |
.ball { | |
width:10px; | |
height:10px; |
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
<a href="javascript:void 0;">abc</a> | |
<div id="editor" contentEditable="true" style="white-space:pre;"> | |
abc | |
</div> | |
<div id="editor2" contentEditable="true" style="white-space:pre;"> | |
abc |
NewerOlder