Skip to content

Instantly share code, notes, and snippets.

View sanae10001's full-sized avatar

sanae10001 sanae10001

  • Sloan Great Wall
View GitHub Profile
@sanae10001
sanae10001 / printStruct.go
Created June 8, 2020 05:05
print go struct
func printStruct(i interface{}) {
s := reflect.ValueOf(i).Elem()
typeOfT := s.Type()
for i := 0; i < s.NumField(); i++ {
f := s.Field(i)
fmt.Printf("%d: %s %s = %v\n", i,
typeOfT.Field(i).Name, f.Type(), f.Interface())
}
}
@sanae10001
sanae10001 / timemilli.go
Created June 8, 2020 05:03
Function to convert a Unix Millisecond Epoch Timestamp to time.Time(https://github.com/Tigraine/go-timemilli)
package timemilli
import "time"
const millisInSecond = 1000
const nsInSecond = 1000000
// Converts Unix Epoch from milliseconds to time.Time
func FromUnixMilli(ms int64) time.Time {
return time.Unix(ms/int64(millisInSecond), (ms%int64(millisInSecond))*int64(nsInSecond))
@sanae10001
sanae10001 / iperf.sh
Created November 25, 2019 02:34 — forked from madeye/iperf.sh
Bandwidth test for shadowsocks
#!/bin/bash
method=$1
ss-tunnel -k test -m $method -l 8387 -L 127.0.0.1:8388 -s 127.0.0.1 -p 8389 &
ss_tunnel_pid=$!
ss-server -k test -m $method -s 127.0.0.1 -p 8389 &
ss_server_pid=$!
iperf -s -p 8388 &

dnsmasq的配置文件由/etc/config/dhcp决定 ####禁用 dnsmasq 的 DNS 功能 在该文件 config dnsmasq下添加

option port 54

如果你的 WAN 口是 PPPOE 等方式连接,而且系统日志中有 DHCP packet received on eth0.2 which has no address 就再添加

@sanae10001
sanae10001 / 1-redsocks2-openwrt.md
Created July 12, 2019 07:48 — 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源

@sanae10001
sanae10001 / act-setup.md
Created January 9, 2019 19:37 — forked from TomRichter/OnWipe.xml
Installation Instructions for FFXIV ACT + Key Plugins

FFXIV ACT Installation Instructions

[TODO: act is a thing you want so you can be awesome]

We'll also add the following helpful plugins:

  • OverlayPlugin - Adds overlay support to conveniently display information in game.
  • Kagerou - A nice DPS overlay that's customizable via an easy-to-use control panel.
  • Triggernometry - Advanced custom triggers with better organization.
@sanae10001
sanae10001 / go-os-arch.md
Created June 29, 2018 02:34 — forked from asukakenji/0-go-os-arch.md
Go (Golang) GOOS and GOARCH

Go (Golang) GOOS and GOARCH

All of the following information is based on go version go1.8.3 darwin/amd64.

A list of valid GOOS values

(Bold = supported by go out of the box, ie. without the help of a C compiler, etc.)

  • android
  • darwin
@sanae10001
sanae10001 / curl.md
Created May 29, 2018 09:33 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

import (
"encoding/json"
"github.com/graph-gophers/graphql-go"
"github.com/graph-gophers/graphql-go/errors"
)
type ErrorType string
type Error struct {
@sanae10001
sanae10001 / graceful.go
Created December 18, 2017 11:08
A go graceful server
import (
"context"
"crypto/tls"
"log"
"net/http"
"os"
"os/signal"
"syscall"
"time"