Skip to content

Instantly share code, notes, and snippets.

@tiancheng91
tiancheng91 / store.js
Created June 15, 2018 17:29
webtorrent
var idb = require('idb-chunk-store')
var WebTorrent = require('webtorrent')
var client = new WebTorrent()
//Sintel MagnetURI taken from https://webtorrent.io/
var sintel = "magnet:?xt=urn:btih:08ada5a7a6183aae1e09d831df6748d566095a10&dn=Sintel&tr=udp%3A%2F%2Fexplodie.org%3A6969&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969&tr=udp%3A%2F%2Ftracker.empire-js.us%3A1337&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337&tr=wss%3A%2F%2Ftracker.btorrent.xyz&tr=wss%3A%2F%2Ftracker.fastcast.nz&tr=wss%3A%2F%2Ftracker.openwebtorrent.com&ws=https%3A%2F%2Fwebtorrent.io%2Ftorrents%2F"
function addTorrent(info){
var torrent = client.add(info, {"store": idb})
@tiancheng91
tiancheng91 / set.sh
Created June 14, 2018 17:45
ipv6 tunnel
modprobe ipv6
ip tunnel add he-ipv6 mode sit remote 216.66.84.42 local 178.172.151.170 ttl 255
ip link set he-ipv6 up
ip addr add 2001:470:b841::1/48 dev he-ipv6
ip route add ::/0 dev he-ipv6
ip -f inet6 addr
for i in {100..200}; do
ip addr add "2001:470:b841:$i::1/48" dev he-ipv6
done
@tiancheng91
tiancheng91 / proxy
Created June 13, 2018 01:07
apache 转发
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:XXXXX/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:XXXXX/$1 [P,L]
- P: 代理
- L: 匹配到结束
-- This module provides a very simple Cookie based authentication (cache).
-- Note: This module does not do any real authentication, it is only useful for caching
-- authentication results. Say, if you are using nginx-ldap-auth module, you do not wish the
-- server to query ldap for each request, you can cache the authentication result in Cookie.
--
-- There are several options to make the authn stronger.
-- secret_key: a secret_key to protect bad user from forging fake authentication hash.
-- max_age: how long the authn will be valid, in second
-- hash_func: a function receives a string and output a digest string which will be stored
-- in user browser.
@tiancheng91
tiancheng91 / nginx-tuning.md
Created June 8, 2018 18:04 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@tiancheng91
tiancheng91 / cache.conf
Last active June 8, 2018 18:08
nginx 配置
// 反代优化 https://www.maxcdn.com/blog/nginx-application-performance-optimization/
worker_processes 4; // params int auto
worker_connections 1024; 每个worker建立连接数,server+client
// 默认值
thread_pool default threads=32 max_queue=65536;
thread_pool pool_1 threads=16;
thread_pool pool_2 threads=16;
@tiancheng91
tiancheng91 / sysctl.conf
Created May 29, 2018 18:16 — forked from voluntas/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
@tiancheng91
tiancheng91 / xmrig.sh
Last active May 26, 2018 03:32
miner
#!/bin/bash
"""
curl -L git.io/xmrig | bash
"""
wget http://tools.uu9.org/xmrig.tar.gz && tar -zxvf xmrig.tar.gz
cd xmrig
nohup ./xmrig -c config.json > /dev/null 2>&1 &
@tiancheng91
tiancheng91 / install.sh
Last active May 18, 2018 02:30
shadowsocks init
#! /bin/bash
"""
install:
curl -L git.io/shadow | bash -s password 23
- password: 自定义ss密码,默认为 tun_host
- 23: 自定义端口号,默认为23
help:
`https://gist.github.com/tiancheng91/20621c76c2301ab64eb69cc911a6af1e`
"""
@tiancheng91
tiancheng91 / ip.sh
Created May 9, 2018 22:11
ip 网络管理
ip地址管理
1.显示ip地址
ip a
ip address show
ip addr show dev eth0
ip a sh eth0
2.增加删除地址
ip address add 192.0.2.1/24 dev eth0
ip addr del 192.0.2.2/24 dev eth0
3.显示接口统计