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 / reactive.js
Created December 4, 2020 16:51
reactive.js
function reactive(val) {
const isPrimitive =
val instanceof Number || val instanceof String || val instanceof Boolean;
return new Proxy(
{
[Symbol.toPrimitive]: () => val,
valueOf: () => val.valueOf(),
toString: () => val.toString(),
},
{
@axetroy
axetroy / index.ts
Created August 6, 2020 04:32
HTTP printer
type HTTPHeaders = { [key: string]: string | string[] };
interface HTTPResponse {
status: number;
headers: HTTPHeaders;
body: unknown;
}
class Printer {
#url!: string;
@axetroy
axetroy / README.md
Created December 1, 2019 10:27
卸载 xcode

xcode 太庞大,而我又用不到 xcode,只能卸载

在卸载 xcode 之后 Git 命令不起作用了

$ git
xcrun: error: active developer path 
("/Applications/Xcode.app/Contents/Developer") 
does not exist, use `xcode-select --switch path/to/Xcode.app` 
to specify the Xcode that you wish to use for command line 
@axetroy
axetroy / README.md
Created October 2, 2019 08:17 — forked from hellokaton/README.md
Go 的信号处理和优雅退出

每个平台的信号定义或许有些不同。下面列出了POSIX中定义的信号。 Linux 使用34-64信号用作实时系统中。 命令man 7 signal提供了官方的信号介绍。

在POSIX.1-1990标准中定义的信号列表

@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 / index.js
Last active May 16, 2019 02:41
基本版的 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 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(