Skip to content

Instantly share code, notes, and snippets.

@kwoktung
kwoktung / ss.md
Created May 6, 2023 02:51 — forked from HJianBo/ss.md
Shadowsocks original protocol

The shadowsocks protocol is very similar to SOCKS5 but encrypted and simpler.

Below is the structure of a shadowsocks request (sent from client-side), which is identical for both TCP and UDP connections before encrypted (or after decrypted).

+--------------+---------------------+------------------+----------+
| Address Type | Destination Address | Destination Port |   Data   |
+--------------+---------------------+------------------+----------+
|      1       |       Variable      |         2        | Variable |
+--------------+---------------------+------------------+----------+
@kwoktung
kwoktung / .vimrc
Last active July 10, 2021 08:30
vim
" generate by figlet
" _
" _ __ ___ _ ___ _(_)_ __ ___ _ __ ___
"| '_ ` _ \| | | \ \ / / | '_ ` _ \| '__/ __|
"| | | | | | |_| |\ V /| | | | | | | | | (__
"|_| |_| |_|\__, | \_/ |_|_| |_| |_|_| \___|
" |___/
"
set nu
set nobackup
@kwoktung
kwoktung / deepCopyLoop.js
Created March 1, 2020 12:14
deep Copy Loop
function deepCopyLoop(obj){
let type = Object.prototype.toString.call(obj)
let ret
let SrcQuene = [];
let DestQuene = [];
let m = new WeakMap();
switch (type) {
case '[object Null]':
case '[object Undefined]':
function executeQueue(...fns) {
fns = fns.reverse()
return fns.reduce(function(next, fn) {
return fn.bind(this, next)
}, function() {
console.log("DONE")
})
}
/*
@kwoktung
kwoktung / inherits.js
Created March 1, 2020 05:59
inherits
function inherits(Child, Parent) {
let F = function(){}
// F only inherits Parent method, not instance property
F.prototype = Parent.prototype
Child.prototype = new F()
Child.prototype.constructor = Child;
}
// Usage
function Student(props) {
@kwoktung
kwoktung / deepCopy.js
Last active March 1, 2020 10:46
deep Copy
/*
Object.getPrototypeOf
Object.setPrototypeOf
也可以用来处理 原型相关的事物
*/
function deepCopy(obj, m = new WeakMap()){
let type = Object.prototype.toString.call(obj)
if (m.has(obj)) { return m.get(obj) }
switch (type) {
@kwoktung
kwoktung / reverse-gif.go
Last active December 26, 2019 09:34
golang script to reverse gif picture
package main
import (
"image/gif"
"log"
"os"
"path/filepath"
"strings"
)
@kwoktung
kwoktung / main.go
Last active December 5, 2019 06:20 — forked from 2minchul/main.go
Cancellation for http request using NewRequestWithContext in Golang
package main
import (
"context"
"fmt"
"net/http"
"time"
)
func main() {
  1. Configure launchctl to start minio on boot

sudo vim ~/Library/LaunchAgents/com.github.kwoktung.minio.local.plist

Copy the contents of this gist to the file, save and close.

  1. Start the minio service and set minio to start on boot
<?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>com.github.kwoktung.minio</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/minio</string>