Skip to content

Instantly share code, notes, and snippets.

View axetroy's full-sized avatar
💭
Get busy living or get busy dying

Axetroy axetroy

💭
Get busy living or get busy dying
View GitHub Profile
@axetroy
axetroy / .gitattributes
Last active September 26, 2017 03:10
开源项目常用的配置文件
# Auto detect text files and perform LF normalization
* text=auto
# JS and TS files must always use LF for tools to work
*.js eol=lf
bin/* eol=lf
@axetroy
axetroy / kor.js
Last active November 4, 2017 10:15
整合koa + koa-router
const Koa = require('koa');
const Router = require('koa-router');
const methods = require('methods');
const router = new Router();
const KOA = Symbol('koa instance');
class Server {
constructor() {
this[KOA] = new Koa();
@axetroy
axetroy / hashCode.js
Last active November 18, 2017 10:00
获取一个对象/字符串/数组的hashCode
function hashCode(any) {
let hash = 0;
if (
any === null ||
any === void 0 ||
any === '' ||
any === 0 ||
any === false
) {
return 0;
@axetroy
axetroy / hs.js
Created November 27, 2017 10:05
Http status code and message module
/**
* Generate a New status
* @param code
* @param message
* @constructor
*/
function Status(code, message) {
this.code = code;
this.message = message;
}
@axetroy
axetroy / emitter.go
Last active November 27, 2017 14:47
EventEmitter for golang
package pool
import "time"
type Event struct {
Time time.Time
Name string
Data interface{}
Id string
}
@axetroy
axetroy / cycle.js
Last active December 6, 2017 02:48
环形数据结构
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 / supershell.js
Last active December 20, 2017 15:54
supershell初稿
const { spawn, exec } = require('child_process');
const COMMAND = Symbol('command');
class Shell {
constructor(command) {
this[COMMAND] = [command];
}
}
const run = new Proxy(
@axetroy
axetroy / README.md
Last active December 21, 2017 03:57
cache初稿
@axetroy
axetroy / main.go
Last active January 12, 2018 18:58
合并Http请求的Go实现雏形
package main
import (
"net/http"
"log"
"io/ioutil"
"encoding/json"
"bytes"
"strings"
)
@axetroy
axetroy / index.ts
Last active May 25, 2018 02:13
基于角色的访问控制
interface User {
username: string;
roles: string[];
}
interface Role {
name: string;
desc: string;
permission: Permission[];
}