Skip to content

Instantly share code, notes, and snippets.

View boyzhujian's full-sized avatar
🎯
Focusing

Damon boyzhujian

🎯
Focusing
  • Cisco
  • Suzhou Jiangsu China
View GitHub Profile
@boyzhujian
boyzhujian / 1-redsocks2-openwrt.md
Created September 16, 2020 07:49 — forked from lanceliao/1-redsocks2-openwrt.md
在OpenWrt上配置redsocks2

redsocks2是一款透明socks5代理工具,能够实现智能代理的功能,这里是redsocks2在OpenWrt上的配置,配合shadowsocks使用。

redsocks.conf 是配置文件,放在/etc目录,将192.168.1.1改成路由器的地址. redsocks2.sh 为自启动文件,改名为redsocks2放到/etc/init.d目录即可。自启动文件假设redsocks可执行文件在/opt/bin目录。

启动redsocks2: /etc/init.d/redsocks2 start 停止redsocks2: /etc/init.d/redsocks2 stop

redsocks2 git源

@boyzhujian
boyzhujian / upload.go
Created November 15, 2018 03:17 — forked from ebraminio/upload.go
golang upload client and server
// curl -X POST -H "Content-Type: application/octet-stream" --data-binary '@filename' http://127.0.0.1:5050/upload
package main
import (
"fmt"
"io"
"net/http"
"os"
"time"
@boyzhujian
boyzhujian / gnome-tracker-disable.md
Created September 25, 2018 01:50 — forked from vancluever/gnome-tracker-disable.md
GNOME Tracker Disable

Disabling GNOME Tracker and Other Info

GNOME's tracker is a CPU and privacy hog. There's a pretty good case as to why it's neither useful nor necessary here: http://lduros.net/posts/tracker-sucks-thanks-tracker/

After discovering it chowing 2 cores, I decided to go about disabling it.

Directories

@boyzhujian
boyzhujian / converthttpheader.py
Created April 25, 2018 01:40
convert raw http header to dict
headers = '''
Host: www.http.header.free.fr
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
Accept-Language: Fr
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 4.0)
Connection: Keep-Alive
'''
headers = dict([[field.strip() for field in pair.split(':', 1)] for pair in headers.strip().split('\n')])
###test.js
var express = require('express');
var router = express.Router();
router.get('/test', function (req, res) {
res.json(200, {'test': 'it works!'});
});
module.exports = router;
@boyzhujian
boyzhujian / init-single-node-ceph.sh
Created February 2, 2018 03:00 — forked from kofemann/init-single-node-ceph.sh
Single node CEPH setup
#
# Enable CEPH repos as described at http://ceph.com/docs/master/install/get-packages/#rpm
# Install ceph-deploy package
#
export DATA_DEV=sdb
export JRNL_DEV=sdc
export FS_TYPE=xfs
export CEPH_S_NODE=ceph-s
export CEPH_RELEASE=giant
//https://stackoverflow.com/questions/44471749/golang-enter-ssh-sudo-password-on-prompt-or-exit
package main
import (
"bufio"
"fmt"
"io"
"log"
"net"
"strings"
func openbrowser(url string) {
var err error
switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
@boyzhujian
boyzhujian / main.go
Created December 4, 2017 02:40 — forked from husobee/main.go
simple golang http middleware chaining example
package main
import (
"fmt"
"net/http"
"time"
"golang.org/x/net/context"
"github.com/husobee/backdrop"
@boyzhujian
boyzhujian / golangserver.go
Last active October 27, 2017 03:07
gohttpserver
package main
import (
"io"
"net/http"
)
func hello(w http.ResponseWriter, r *http.Request) {
io.WriteString(w, "Hello world!")
}