Skip to content

Instantly share code, notes, and snippets.

View SimonAKing's full-sized avatar
🍅
PRESS START

SimonAKing SimonAKing

🍅
PRESS START
View GitHub Profile
@SimonAKing
SimonAKing / counter.js
Created July 5, 2020 05:05
Redux-Counter
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
@SimonAKing
SimonAKing / Generator.go
Created March 7, 2020 07:36
Generator.go
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
}
@SimonAKing
SimonAKing / PromiseSimple.js
Created February 26, 2020 04:00
PromiseSimple
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);
}
@SimonAKing
SimonAKing / recent-activity.txt
Last active October 29, 2020 14:15
⚡️ Recent activity
❗️ 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
@SimonAKing
SimonAKing / Weibo.md
Last active November 11, 2023 12:38
✨ Latest Weibo

Newsletter 是一类去平台化的信息源,能让自己重新掌握消费的主动权,通过筛选的优质信息,可创造出能使自己思考的环境。

Newsletter 作为我重要的输入源,已使用多年,不知不觉已积累了一些自认为的高质信息源,这些信息粗分为 技术主题 与 科技人文主题,信息源与其订阅方式已梳理到 https://tomotoes.com/newsletter/,希望能对你有所帮助。

如果你也有推荐的 newsletter,欢迎补充到 issue 中,同时也可以看看 我的 newsletter - 思考的价值 是不是你想要的菜~

微博地址: https://tomotoes.com/blog/weibo

@SimonAKing
SimonAKing / Once.go
Created August 18, 2019 09:34
Officially provided Context package
package sync
import (
"sync"
"sync/atomic"
)
type Once struct {
m sync.Mutex
done uint32
@SimonAKing
SimonAKing / Mutex.go
Created August 18, 2019 09:12
Mutex with channel
package main
import "time"
type Mutex struct {
lock chan struct{}
}
func New() *Mutex {
mu := &Mutex{lock: make(chan struct{}, 1)}
@SimonAKing
SimonAKing / Context.go
Last active August 18, 2019 09:18
Officially provided Context package
package context
import (
"errors"
"reflect"
"sync"
"time"
)
// Context 四个方法
@SimonAKing
SimonAKing / Command.go
Created August 18, 2019 08:57
Command tool
package main
import (
"bufio"
"errors"
"fmt"
"os"
"os/exec"
"strings"
)
@SimonAKing
SimonAKing / merge.go
Created August 18, 2019 08:54
Merge Channels
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