Skip to content

Instantly share code, notes, and snippets.

@sleagon
sleagon / example.txt
Last active October 22, 2021 11:05
auto comment for idea
function comment
/**
* @Author sleagon
* @Description 一个测试用的函数
* @Date 6:20 下午 2021/10/22
* @Param TGICrowdRule : crowd 规则名单
* TGIField> : fields 标签清单
* Long : tenantId 租户ID
* @Return KQL
**/
@sleagon
sleagon / concurrent_hash_write.go
Created June 30, 2021 02:17
Calculate hash and write file content at the sametime.
package stat
import (
"crypto/sha256"
"fmt"
"io"
"os"
)
func Run() {
@sleagon
sleagon / broken-state-update.js
Last active August 21, 2019 15:35
broken-update
/*
* 这是一个setState执行成功,state也更新了,但是页面没渲染的例子,应该更多的是跟diff相关。
*/
class Example extends React.Component{
//...
state = {
fruit: [{
type: 'bannana',
count: 0
},{
@sleagon
sleagon / http_stream_server.go
Created July 25, 2019 06:54
A simple example of using chunked response to send huge file to clients in golang
package fileserver
import (
"fmt"
"io"
"log"
"net/http"
"time"
)
@sleagon
sleagon / async.go
Created July 19, 2019 03:22
A simple async package, like Promise.All
package async
import (
"context"
"fmt"
"sync"
)
type Job = func(ctx context.Context) error
@sleagon
sleagon / vscode.config
Last active May 24, 2019 05:37
vscode config
{
"javascript.implicitProjectConfig.experimentalDecorators": true,
"workbench.sideBar.location": "right",
"workbench.activityBar.visible": false,
"workbench.statusBar.visible": true,
"window.zoomLevel": 1,
"editor.renderWhitespace": "all",
"terminal.integrated.shell.osx": "/bin/zsh",
"gitlens.advanced.messages": {
"suppressShowKeyBindingsNotice": true
@sleagon
sleagon / string2stream.ts
Created March 29, 2019 09:59
A simple class to convert string to stream.
// FR file
import { Readable } from "stream";
export default class String2Stream extends Readable {
private data: Buffer;
private str: string;
private size: number;
private cur: number;
constructor(str: string) {
super();