test
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 isElementInViewport(el) { | |
http://stackoverflow.com/questions/325933/determine-whether-two-date-ranges-overlap | |
{ /* The source of the following code. */ } | |
const rect = el.getBoundingClientRect() | |
const windowHeight = (window.innerHeight || document.documentElement.clientHeight) | |
const windowWidth = (window.innerWidth || document.documentElement.clientWidth) | |
const vertInView = (rect.top <= windowHeight) && ((rect.top + rect.height) >= 0) | |
const horInView = (rect.left <= windowWidth) && ((rect.left + rect.width) >= 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
const quickSort = a => { | |
if (!a.length) { return [] } | |
return [ | |
...quickSort(a.filter(e => e < a[0])), | |
...a.filter(e => e === a[0]), | |
...quickSort(a.filter(e => e > a[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
const permutate = (n, choices = ['A', 'B', 'C', 'D']) => { | |
const result = [] | |
const recursion = path => { | |
if (path.length === n) { | |
result.push(path.join('')) | |
return | |
} | |
choices.forEach(c => { recursion([...path, c]) }) | |
} |
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 patchTasksByTimeout = (task, tasks, timeout) => { | |
return tasks.reduce((a, t) => { | |
if (t.value === task.value) { | |
t.timeout = timeout | |
} else { | |
t.timeout = Math.max(0, t.timeout - 1) | |
} | |
return [...a, t] | |
}, []) | |
} |
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 PropTypes from 'prop-types' | |
import ReactDOM from 'react-dom' | |
import { createStore } from 'redux' | |
import { Provider, connect } from 'react-redux' | |
// React component | |
class Counter extends Component { | |
render() { | |
const { value, onIncreaseClick } = this.props |
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
package main | |
import "fmt" | |
func Iter(start, end int) chan int { | |
ch := make(chan int) | |
go func(ch chan int) { | |
for i := start; i <= end; i++ { | |
ch <- 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
class PromiseSimple { | |
constructor(executionFunction) { | |
this.promiseChain = []; | |
this.handleError = () => {}; | |
this.onResolve = this.onResolve.bind(this); | |
this.onReject = this.onReject.bind(this); | |
executionFunction(this.onResolve, this.onReject); | |
} |
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
❗️ Opened issue #103 in Tomotoes/weibo | |
❗️ Opened issue #102 in Tomotoes/weibo | |
❗️ Closed issue #99 in Tomotoes/weibo | |
❗️ Closed issue #82 in Tomotoes/weibo | |
🗣 Commented on #75 in Tomotoes/scrcpy-gui |
Newsletter 是一类去平台化的信息源,能让自己重新掌握消费的主动权,通过筛选的优质信息,可创造出能使自己思考的环境。
Newsletter 作为我重要的输入源,已使用多年,不知不觉已积累了一些自认为的高质信息源,这些信息粗分为 技术主题 与 科技人文主题,信息源与其订阅方式已梳理到 https://tomotoes.com/newsletter/,希望能对你有所帮助。
如果你也有推荐的 newsletter,欢迎补充到 issue 中,同时也可以看看 我的 newsletter - 思考的价值 是不是你想要的菜~
NewerOlder