Skip to content

Instantly share code, notes, and snippets.

View QuantumGhost's full-sized avatar
🇯🇵

QuantumGhost QuantumGhost

🇯🇵
  • 0xB29A14086516184D
  • 22:53 (UTC +08:00)
View GitHub Profile
@QuantumGhost
QuantumGhost / example.puml
Last active March 23, 2024 22:39
A simple template for PlantUML to draw ER diagram.The basic idea comes from http://plantuml.sourceforge.net/qa/?qa=331/database-modeling
@startuml
' uncomment the line below if you're using computer with a retina display
' skinparam dpi 300
!define Table(name,desc) class name as "desc" << (T,#FFAAAA) >>
' we use bold for primary key
' green color for unique
' and underscore for not_null
!define primary_key(x) <b>x</b>
!define unique(x) <color:green>x</color>
!define not_null(x) <u>x</u>
@QuantumGhost
QuantumGhost / ssl.md
Created November 3, 2023 14:53 — forked from clowwindy/ssl.md
为什么不应该用 SSL 翻墙

SSL 设计目标:

  1. 防内容篡改
  2. 防冒充服务器身份
  3. 加密通信内容

而翻墙的目标:

  1. 不被检测出客户端在访问什么网站
  2. 不被检测出服务器在提供翻墙服务
@QuantumGhost
QuantumGhost / README.md
Created October 21, 2023 13:39
COS policy for restic with minimal permission.

COS Policy for Restic

适用于 Restic 腾讯云 COS 最小权限策略.

本策略只允许备份, 不允许删除备份 (但要注意恶意攻击者仍可把所有的备份文件替换为空文件).

变量:

  • $UID: 腾讯云 uid, 形如 uid/1250000000
  • $BUCKET: 存储桶名称, 形如 examplebucket-1250000000
@QuantumGhost
QuantumGhost / hosts
Last active September 27, 2023 07:09
# 中国移动
0.0.0.0 config.cmpassport.com
0.0.0.0 www.cmpassport.com
0.0.0.0 wap.cmpassport.com
0.0.0.0 onekey1.cmpassport.com
0.0.0.0 log1.cmpassport.com
0.0.0.0 smsks1.cmpassport.com
0.0.0.0 verify.cmpassport.com
# 中国联通
@QuantumGhost
QuantumGhost / style.css
Last active July 12, 2023 14:45
Humble New Tab Page Bing Wallpaper Style
.column {
background-color: rgba(238, 238, 238, 0.85);
border-radius: 1em;
margin: 1.5em;
}
body {
/**
The bing wallpaper service is provided by:
https://github.com/TimothyYe/bing-wallpaper.
@QuantumGhost
QuantumGhost / DefaultKeyBinding.dict
Last active January 31, 2023 15:04
xcode keybindings for emacs emulation
{
/* Override symbols so other apps can bind */
/* ~ stands for option, ^ stands for control */
"~j" = "noop:";
"~i" = "noop:";
"~;" = "noop:";
"~a" = "noop:";
"~2" = "noop:";
"~g" = "noop:";
"~y" = "noop:";

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

又是基于 HTTP 的 API 设计问题

我个人的想法是:

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

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

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

#!/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 / limit.maxfiles.plist
Last active August 10, 2022 09:29
Automatically increase maxfiles on macOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>limit.maxfiles</string>
<key>ProgramArguments</key>
<array>
<string>launchctl</string>
<string>limit</string>

先开启开发者模式,并连接到 adb shell,然后在 adb shell 中执行下面的命令:

# 禁用腾讯小微语音搜索:(也会禁用搜索功能)
pm disable-user --user 0 com.sony.dtv.searchapp
# 禁用京东智能家居
pm disable-user --user 0 com.jd.smartservicetwo
# 禁用原装桌面(**执行前请务必确认已安装第三方桌面,否则可能无法使用遥控器控制电视**)
pm disable-user --user 0 com.dangbei.TVHomeLauncher