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 / README.md
Last active April 21, 2019 15:38
跨平台,关闭xxx端口

有些时候程序开启了http服务,监听了某个端口。

然后关闭终端或者CTRL+C退出之后,进程没有被杀掉,端口还在监听,导致下次启动的时候报错。

这里就记录下来,查看进程监听的端口,以及杀死进程

Window

@axetroy
axetroy / README.md
Last active March 13, 2019 03:27
Thrift的Nodejs例子

Thrift的RPC

代码全部来源于官方教程

如何运行?

新建目录,把所有文件放在同一目录下

在该目录下执行命令

@axetroy
axetroy / README.md
Created December 17, 2018 14:19
Mac上的优化,提升文件打开数/连接数
$ 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 02:13
基于角色的访问控制
interface User {
username: string;
roles: string[];
}
interface Role {
name: string;
desc: string;
permission: Permission[];
}
@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 / README.md
Last active December 21, 2017 03:57
cache初稿
@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 / 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 / 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 / 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;
}