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 August 18, 2024 08:42
vim
" generate by figlet
" _
" _ __ ___ _ ___ _(_)_ __ ___ _ __ ___
"| '_ ` _ \| | | \ \ / / | '_ ` _ \| '__/ __|
"| | | | | | |_| |\ V /| | | | | | | | | (__
"|_| |_| |_|\__, | \_/ |_|_| |_| |_|_| \___|
" |___/
"
set nu
set nobackup
  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>
[Unit]
Description=MinIO
Documentation=https://docs.min.io
Wants=network-online.target
After=network-online.target
AssertFileIsExecutable=/usr/local/bin/minio
[Service]
WorkingDirectory=/usr/local/
@kwoktung
kwoktung / install-redis.md
Last active November 28, 2019 14:57 — forked from hackedunit/install-redis.md
Install and configure Redis on Ubuntu 16.04 with systemd
  1. Install pre-requisities

sudo apt-get install build-essential tcl

  1. Install Redis
cd /tmp
curl -O http://download.redis.io/redis-stable.tar.gz
tar xzvf redis-stable.tar.gz
[Unit]
Description=Redis In-Memory Data Store
After=network.target
[Service]
User=redis
Group=redis
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/bin/redis-cli shutdown
Restart=always
@kwoktung
kwoktung / readme.md
Created August 16, 2018 16:22 — forked from irazasyed/readme.md
CSS: Retina Display Media Query

Retina Display Media Query Example:

===

CSS Code for Normal and Retina:

#logo{
    background-image: url(logo.png);
    background-size: 185px 75px;
 background-repeat: no-repeat;
;(function() {
var canvas = document.getElementsByClassName('runner-canvas')[0];
var ctx = canvas.getContext('2d');
function run(){
var hit = false;
var data = ctx.getImageData(150,180,175,50).data
for(var i=3, len = data.length; i < len; i += 8) {
if (data[i] > 0) {
hit = true;
break;
@kwoktung
kwoktung / jsonp.js
Created September 6, 2016 05:59
JSONP simple implementation
(function(global,document){
var uid = 0 ;
function getJSON(url,callback){
var elem;
uid ++;
getJSON.callbacks[uid] = callback;
url = filterUrlCallback(url);