Skip to content

Instantly share code, notes, and snippets.

@tounan
tounan / cap.sh
Created March 7, 2023 15:02
SH imitation of capsh decoding
#!/bin/bash
# https://raw.githubusercontent.com/torvalds/linux/master/include/uapi/linux/capability.h
declare -A capnum=(
["chown"]=0
["dac_override"]=1
["dac_read_search"]=2
["fowner"]=3
["fsetid"]=4
["kill"]=5
@tounan
tounan / cross_and_static_compile_shadowsocks-libev.sh
Last active November 28, 2021 21:49 — forked from harv/cross_and_static_compile_shadowsocks-libev.sh
cross & static compile shadowsocks-libev
#!/bin/sh
# cross & static compile shadowsocks-libev
PCRE_VER=8.41
PCRE_FILE="http://ftp.cs.stanford.edu/pub/exim/pcre/pcre-$PCRE_VER.tar.gz"
MBEDTLS_VER=2.6.0
MBEDTLS_FILE="https://tls.mbed.org/download/mbedtls-$MBEDTLS_VER-gpl.tgz"
@tounan
tounan / default.conf
Created August 20, 2021 01:27
Simple, no bullsh*t nginx+php+mariadb (lnmp) with docker-compose
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/host.access.log main;
location / {
root /var/www/html;
index index.html index.htm index.php;
}
@tounan
tounan / git-reset-author.sh
Created October 12, 2020 16:47 — forked from bgromov/git-reset-author.sh
Git: reset author for ALL commits
#!/bin/sh
# Credits: http://stackoverflow.com/a/750191
git filter-branch -f --env-filter "
GIT_AUTHOR_NAME='Newname'
GIT_AUTHOR_EMAIL='new@email'
GIT_COMMITTER_NAME='Newname'
GIT_COMMITTER_EMAIL='new@email'
" HEAD
@tounan
tounan / Copyful.user.js
Last active November 25, 2020 15:10
拒绝流氓行径,未经允许强奸用户的剪贴板!我复制你的东西,并不是你作恶的理由。
// ==UserScript==
// @name Copyful
// @namespace FromZhihuImportShit
// @version 0.11
// @description 阻止老版权卫士了
// @author You
// @run-at document-start
// @match https://www.zhihu.com/*
// @match https://*.csdn.net/*
// @match https://juejin.im/*
@tounan
tounan / CopyLess 2.md
Created March 28, 2020 15:10
Set clipboard capacity to 1000

Notice

Upgrade to Pro to unlock the feature (convinced)

Howto

Start trial, slide the bar to MAX (1000)

OR

@tounan
tounan / forward-proxy.js
Last active August 4, 2023 15:07
Proxy on cloudflare workers
// URI prefix
const token = TOKEN; // env, like 'https://<your worker domain>.workers.dev/'
const blocked_code = [
'US', 'UK', 'CA', 'AU', 'RU', 'FR', 'DE'
];
const blocked_hosts = [
'0.0.0.0',
'127.0.0.1',
@tounan
tounan / 82589933.py
Created November 2, 2019 13:16
Computes the largest known prime up to now
from gmpy2 import mpz
mp = mpz('2') ** mpz('82589933') - mpz('1')
prime = str(mp)
open('prime82589933.txt', 'wt').write(prime)
exit(0)