Skip to content

Instantly share code, notes, and snippets.

View cloverstd's full-sized avatar
🀄
Working for living

cloverstd cloverstd

🀄
Working for living
View GitHub Profile
@cloverstd
cloverstd / install.sh
Last active April 10, 2021 13:51
install libtorrent and python binds on centos 7
yum install -y boost boost-devel
yum install -y make gcc gcc-c++ kernel-devel python-devel
wget https://github.com/arvidn/libtorrent/releases/download/libtorrent-1_0_10/libtorrent-rasterbar-1.0.10.tar.gz
tar zxvf libtorrent-rasterbar-1.0.10.tar.gz
cd libtorrent-rasterbar-1.0.10.tar.gz
./configure --disable-debug --with-boost-libdir=/usr/lib64 --disable-encryption --enable-python-binding
make && make install
export LD_LIBRARY_PATH=/usr/local/lib/
cd bindings/python
python setup.py build
@cloverstd
cloverstd / cors.lua
Created April 1, 2021 09:02
Nginx cors by lua
local origin_pattern = [=[(\.hui\.lu|\.cloverstd\.com)(:\d+)?$]=]
local headers = ngx.req.get_headers()
ngx.header['Access-Control-Max-Age'] = '3600'
ngx.header['Access-Control-Allow-Credentials'] = 'true'
local origin = headers['Origin']
if origin then
local m, err = ngx.re.match(origin, origin_pattern, "jo")
if m then
@cloverstd
cloverstd / main.go
Created September 24, 2020 02:53
access value via unsafe
func main() {
var i interface{} = 100
/**
type eface struct {
_type *_type
data unsafe.Pointer
}
*/
n := *(*int)(*(*unsafe.Pointer)(unsafe.Pointer(uintptr(unsafe.Pointer(&i)) + unsafe.Alignof(i))))
fmt.Println(n)
@cloverstd
cloverstd / recover.js
Created March 29, 2020 07:25
坚果云恢复文件
function getParams() {
const pairs = window.location.hash.substr(1).split('::');
if (!pairs) {
throw new Error('取不到参数');
}
return {
sndId: pairs[1].split('=')[1],
sndMagic: pairs[2].split('=')[1]
};
}
@cloverstd
cloverstd / Probes
Created March 22, 2020 12:46
smokeping config
*** Probes ***
+ FPing
binary = /usr/bin/fping
+ Curl
binary = /usr/bin/curl
@cloverstd
cloverstd / thread.py
Created December 26, 2019 18:28
多线程
import requests
from Queue import Queue, Empty
import time
import threading
wait_q = Queue()
lock = threading.Lock()
@cloverstd
cloverstd / app.py
Last active November 4, 2019 21:33
微信二维码扫描登录
#!/usr/bin/env python
# encoding: utf-8
import tornado.ioloop
import tornado.httpclient
import tornado.web
import tornado.gen
import json
import tornado.websocket
import Queue
@cloverstd
cloverstd / check.py
Last active September 6, 2019 03:18
a cheap tcp check
import socket
import struct
import time
# https://github.com/tevino/tcp-shaker
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_TCP, socket.TCP_QUICKACK, 0) # disable TCP_QUICKACK
s.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack('ii', 1, 0)) # diable liner, send RST to close
s.connect(('127.0.0.1', 9999))
@cloverstd
cloverstd / setup.sh
Created September 4, 2019 09:03
vultr ipv6 setup
sudo apt-get install ndisc6 # install rdsic6
sudo rdisc6 ens3 # search ens3 iface info, the last line from block is your gateway
sudo ip -6 route add default via YOUR_GATEWAY_FROM_rdisc6 dev ens3
package sign
import (
"crypto/md5"
"encoding/hex"
"net/url"
"sort"
"strings"
)