Skip to content

Instantly share code, notes, and snippets.

@bitxel
bitxel / gist:a61ae87eb0465565964832fd765cf178
Created September 11, 2025 15:15
tun2socks mac start/stop proxy
#!/bin/bash
set -e
### === 配置区 ===
PROXY_HOST="127.0.0.1" # 本机 SOCKS5 地址
PROXY_PORT="1080"
DEV="utun123" # TUN 网卡名称
TUNIP="198.18.0.1" # TUN 的 IP
IFACE="en0" # 物理出口网卡 (ifconfig 查看)
REMOTE_HOSTS=("xxx.com" "yyy.com") # 需要直连的上游主机,可填多个
@bitxel
bitxel / session.go
Created December 12, 2015 08:29
Bulk call func in stucts
// Come from golang.org/x/crypto/ssh/session.go:353
type F func(*Session)
for _, setupFd := range []F{(*Session).stdin, (*Session).stdout, (*Session).stderr} {
setupFd(s)
}
@bitxel
bitxel / mongodb mapreduce
Created June 26, 2015 15:49
use mongodb mapreduce to update document example
var m = function(){
emit(this._id,this)
}
var r = function(k, value) {
// here is the process of update data
t = value.running_param.targets;
for (var i = 0; i < t.length; i++) {
var tmp = t[i].split("/")[1];
if (tmp.indexOf(".") == -1) {
@bitxel
bitxel / gist:8edf7c17b66949d60121
Last active August 29, 2015 14:22
python alternative switch
#!/usr/bin/env python
# coding=utf-8
def switch(key):
return {
'keya': '123',
'keyb': '456',
'keyc': 'aaa'
}.get(key,'8888')