This file contains hidden or 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 class="loading"></div> |
This file contains hidden or 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() { | |
| let [prev, curr] = [0, 1]; | |
| while (true) { | |
| [prev, curr] = [curr, prev + curr]; | |
| yield curr; | |
| } | |
| } | |
| for (let n of fibonacci()) { | |
| if (n > 1000) break; |
This file contains hidden or 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 dom = new Proxy({},{ | |
| get(target,property){ | |
| return function (attrs={},...children){ | |
| const el = document.createElement(property) | |
| for(let prop of Object.keys(attrs)){ | |
| el.setAttribute(prop,attrs[prop]) | |
| } | |
| console.log(property) // a li li li ul div | |
| for(let child of children){ |
This file contains hidden or 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 promisify = callback => (...args) => | |
| new Promise((resolve, reject) => | |
| callback(...args, (err, data) => err ? reject(err) : resolve(data)) | |
| ) |
This file contains hidden or 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 java.util.stream.IntStream; | |
| public class SleepSort implements Runnable { | |
| private int number; | |
| private SleepSort(int number) { | |
| this.number = number; | |
| } | |
| public static void main(String[] args) { |
This file contains hidden or 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
| package main | |
| import "fmt" | |
| type MethodRequest int | |
| const ( | |
| Incr MethodRequest = iota | |
| Decr | |
| ) |
This file contains hidden or 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
| package main | |
| import "sync" | |
| func merge(cs ...chan interface{}) <-chan interface{} { | |
| var wg sync.WaitGroup | |
| out := make(chan interface{}) | |
| output := func(c <-chan interface{}) { | |
| for e := range c { | |
| out <- e |
This file contains hidden or 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
| package main | |
| import ( | |
| "bufio" | |
| "errors" | |
| "fmt" | |
| "os" | |
| "os/exec" | |
| "strings" | |
| ) |
This file contains hidden or 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
| package context | |
| import ( | |
| "errors" | |
| "reflect" | |
| "sync" | |
| "time" | |
| ) | |
| // Context 四个方法 |
This file contains hidden or 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
| package main | |
| import "time" | |
| type Mutex struct { | |
| lock chan struct{} | |
| } | |
| func New() *Mutex { | |
| mu := &Mutex{lock: make(chan struct{}, 1)} |
OlderNewer