Skip to content

Instantly share code, notes, and snippets.

@pikachule
pikachule / 1_singlehost.go
Created September 12, 2017 11:01 — forked from justinas/1_singlehost.go
Go middleware samples for my blog post. http://justinas.org/writing-http-middleware-in-go/
package main
import (
"net/http"
)
type SingleHost struct {
handler http.Handler
allowedHost string
}
@pikachule
pikachule / redirectExample.go
Created September 18, 2017 02:52 — forked from d-schmidt/redirectExample.go
How to redirect HTTP to HTTPS with a golang webserver.
package main
import (
"net/http"
"log"
)
func redirect(w http.ResponseWriter, req *http.Request) {
// remove/add not default ports from req.Host
target := "https://" + req.Host + req.URL.Path
if len(req.URL.RawQuery) > 0 {
@pikachule
pikachule / install.sh
Created October 28, 2017 11:51 — forked from cloverstd/install.sh
install libtorrent and python binds on centos 7
yum install -y boost boost-devel
yum install -y make gcc gcc-c++ kernel-devel python-devel
wget https://github.com/arvidn/libtorrent/releases/download/libtorrent-1_0_10/libtorrent-rasterbar-1.0.10.tar.gz
tar zxvf libtorrent-rasterbar-1.0.10.tar.gz
cd libtorrent-rasterbar-1.0.10.tar.gz
./configure --disable-debug --with-boost-libdir=/usr/lib64 --disable-encryption --enable-python-binding
make && make install
export LD_LIBRARY_PATH=/usr/local/lib/
cd bindings/python
python setup.py build
@pikachule
pikachule / RegexHandler.go
Created October 30, 2017 08:16 — forked from iamphill/RegexHandler.go
Very basic golang HTTP server
package main
import (
"net/http"
"Regexp"
)
type route struct {
pattern *regexp.Regexp
handler http.Handler
@pikachule
pikachule / myip.go
Created October 31, 2017 01:28 — forked from jniltinho/myip.go
Get My IP Golang
package main
/*
URL: https://github.com/mccoyst/myip/blob/master/myip.go
URL: http://changsijay.com/2013/07/28/golang-get-ip-address/
*/
import (
"net"
"os"
@pikachule
pikachule / gist:8d310f5584c990817deddb05b47c367f
Last active November 5, 2017 12:48
proxy match / golang regexp
package main
import (
"fmt"
"regexp"
)
func main() {
data := `
`
@pikachule
pikachule / http_get_request.go
Created November 17, 2017 02:27
golang http post request
package main
import (
"bytes"
"fmt"
"io/ioutil"
"net/http"
"net/url"
)
@pikachule
pikachule / aes_encryption.go
Created January 21, 2018 07:18 — forked from stupidbodo/aes_encryption.go
AES Encryption Example in Golang
// Playbook - http://play.golang.org/p/3wFl4lacjX
package main
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
@pikachule
pikachule / interfaces.go
Created May 4, 2018 01:35 — forked from meson10/interfaces.go
Golang Interfaces
package main
import "log"
type EventLogger interface {
Log() int
}
type EventA struct {
Id int
@pikachule
pikachule / git_toturial
Last active August 1, 2018 01:20 — forked from guweigang/git_toturial
git命令大全
git init # 初始化本地git仓库(创建新仓库)
git config --global user.name "xxx" # 配置用户名
git config --global user.email "xxx@xxx.com" # 配置邮件
git config --global color.ui true # git status等命令自动着色
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git config --global --unset http.proxy # remove proxy configuration on git
git clone git+ssh://git@192.168.53.168/VT.git # clone远程仓库