Skip to content

Instantly share code, notes, and snippets.

💭
你开心就好

Axetroy axetroy

Block or report user

Report or block axetroy

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@axetroy
axetroy / README.md
Created Dec 17, 2018
Mac上的优化,提升文件打开数/连接数
View README.md
$ echo kern.maxfiles=65536 | sudo tee -a /etc/sysctl.conf
$ echo kern.maxfilesperproc=65536 | sudo tee -a /etc/sysctl.conf
$ sudo sysctl -w kern.maxfiles=65536
$ sudo sysctl -w kern.maxfilesperproc=65536
$ ulimit -n 65536
@axetroy
axetroy / index.ts
Last active May 25, 2018
基于角色的访问控制
View index.ts
interface User {
username: string;
roles: string[];
}
interface Role {
name: string;
desc: string;
permission: Permission[];
}
@axetroy
axetroy / index.js
Last active May 16, 2019
基本版的 JS 解析器
View index.js
const babylon = require("babylon");
const types = require("babel-types");
const visitors = {
File(node, scope) {
evaluate(node.program, scope);
},
Program(program, scope) {
for (const node of program.body) {
evaluate(node, scope);
@axetroy
axetroy / main.go
Last active Jan 12, 2018
合并Http请求的Go实现雏形
View main.go
package main
import (
"net/http"
"log"
"io/ioutil"
"encoding/json"
"bytes"
"strings"
)
@axetroy
axetroy / supershell.js
Last active Dec 20, 2017
supershell初稿
View supershell.js
const { spawn, exec } = require('child_process');
const COMMAND = Symbol('command');
class Shell {
constructor(command) {
this[COMMAND] = [command];
}
}
const run = new Proxy(
@axetroy
axetroy / cycle.js
Last active Dec 6, 2017
环形数据结构
View cycle.js
class Node {
constructor(prev, value, next) {
this.prev = prev;
this.next = next;
this.value = value;
}
}
const CURRENT_INDEX = Symbol('current index in cycle');
const ROUND_INDEX = Symbol('how many round in cycle');
@axetroy
axetroy / pool.go
Created Nov 27, 2017
Golang资源池
View pool.go
package pool
type CreatorFunc func() (interface{}, error)
type DestroyerFunc func(resource interface{}) (interface{}, error)
type Pool struct {
config Config
options Options
pool []interface{}
}
@axetroy
axetroy / emitter.go
Last active Nov 27, 2017
EventEmitter for golang
View emitter.go
package pool
import "time"
type Event struct {
Time time.Time
Name string
Data interface{}
Id string
}
@axetroy
axetroy / hs.js
Created Nov 27, 2017
Http status code and message module
View hs.js
/**
* Generate a New status
* @param code
* @param message
* @constructor
*/
function Status(code, message) {
this.code = code;
this.message = message;
}
You can’t perform that action at this time.