Skip to content

Instantly share code, notes, and snippets.

View QuantumGhost's full-sized avatar
🎯

QuantumGhost QuantumGhost

🎯
View GitHub Profile

采取 RESTful 风格的 api 是否应该对结果包一层?

又是基于 HTTP 的 API 设计问题

我个人的想法是:

  1. RESTful 和 RPC 风格各有优劣,具体场景具体分析,但是整体一致最重要,不一致的 API 始终是最糟糕的。

  2. 如果要添加错误码,错误码最好放在 HTTP 头里面,这样可以在不读取 payload 的情况下判断是否存在错误

    例如:X-Error-Code: 10001 或者 X-Error-Code: OUT_OF_CREDIT

@QuantumGhost
QuantumGhost / AnIntro.md
Created October 10, 2019 03:46 — forked from chrisdone/AnIntro.md
Statically Typed Lisp

Basic unit type:

λ> replTy "()"
() :: ()

Basic functions:

Rust in Large Organizations

Initially taken by Niko Matsakis and lightly edited by Ryan Levick

Agenda

  • Introductions
  • Cargo inside large build systems
  • FFI
  • Foundations and financial support
@QuantumGhost
QuantumGhost / chez-future.ss
Created August 31, 2019 08:28 — forked from yinwang0/chez-future.ss
experimental implementation of future with Chez Scheme threads
(define-record fitem (result ready mutex cond))
(define future
(lambda (thunk)
(let ([item (make-fitem #f #f (make-mutex) (make-condition))])
(fork-thread
(lambda ()
(let ([result (thunk)])
(with-mutex (fitem-mutex item)
(set-fitem-result! item result)
#!/usr/bin/env bash
CODENAME=buster
APT_MIRROR=https://mirrors.ustc.edu.cn/debian
cat <<EOF | tee /etc/apt/sources.list.d/zfs.list
deb ${APT_MIRROR} ${CODENAME}-backports main contrib
deb-src ${APT_MIRROR} ${CODENAME}-backports main contrib
EOF
@QuantumGhost
QuantumGhost / hosts
Created June 17, 2019 23:38 — forked from alswl/hosts
hosts for OpenWRT, for disable AD in xiaomi TV
127.0.0.1 api.ad.xiaomi.com
127.0.0.1 sdkconfig.ad.xiaomi.com
127.0.0.1 ad.mi.com
127.0.0.1 ad.xiaomi.com
127.0.0.1 ad1.xiaomi.com
127.0.0.1 adv.sec.miui.com
127.0.0.1 test.ad.xiaomi.com
127.0.0.1 new.api.ad.xiaomi.com

Personal Tech stack

Go

Queue:

  • NATS for messaging queue.

Database:

#!/usr/bin/env bash
set -e
error() {
local sourcefile=$1
local lineno=$2
printf "Error: ${sourcefile}:${lineno}\n\n"
}
trap 'error "${BASH_SOURCE}" "${LINENO}"' ERR
@QuantumGhost
QuantumGhost / mesalink_release_v0.6.0_chn.md
Created April 3, 2019 08:03 — forked from ymjing/mesalink_release_v0.6.0_chn.md
MesaLink v0.6.0 released [Chinese version]
### Keybase proof
I hereby claim:
* I am quantumghost on github.
* I am quantumghost (https://keybase.io/quantumghost) on keybase.
* I have a public key whose fingerprint is C685 98CD AF85 11D1 6CB9 0610 B29A 1408 6516 184D
To claim this, I am signing this object: