Skip to content

Instantly share code, notes, and snippets.

View whiler's full-sized avatar
🇨🇳

whiler whiler

🇨🇳
View GitHub Profile
@whiler
whiler / build-haproxy.sh
Created September 4, 2020 13:16
build haproxy from source
#!/bin/bash
LUAVER=5.4.0
LIBSLZVER=ff537154e7f5f2fffdbef1cd8c52b564c1b00067
PCRE2VER=10.35
OPENSSLVER=1.1.1g
HAPROXYVER=2.2.2
PREFIX=/tmp/opt
CURDIR=${PWD}
@whiler
whiler / Dockerfile.dev
Last active September 5, 2020 07:21
CentOS Development tools
FROM centos:7
ENV container docker
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*; \
rm -f /etc/systemd/system/*.wants/*; \
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
@whiler
whiler / ca-bundle.makefile
Created August 28, 2020 10:41
generate bundle of CA root certificates
ca-bundle.crt: mk-ca-bundle.pl
perl mk-ca-bundle.pl -f -u -q
mk-ca-bundle.pl:
curl -LOs https://github.com/curl/curl/raw/master/lib/mk-ca-bundle.pl
@whiler
whiler / sniff_tls.go
Created August 28, 2020 10:26
sniff TLS hello information
package main
import (
"bytes"
"crypto/tls"
"io"
"net"
"time"
)
@whiler
whiler / new-instance.go
Created May 22, 2020 20:44
create new instance from pointer with reflect
// Ref. https://medium.com/capital-one-tech/learning-to-use-go-reflection-822a0aed74b7
package main
import (
"fmt"
"reflect"
)
func main() {
type CustomType struct {
@whiler
whiler / hostcgi.go
Created May 21, 2020 17:02
host CGI in golang
package main
import (
"flag"
"fmt"
"log"
"net/http"
"net/http/cgi"
"os"
"path"
@whiler
whiler / utun.py
Last active March 26, 2024 16:19
open utun device in OS X
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# open utun device in OS X
# Refs:
# - https://github.com/python/cpython/blob/master/Modules/socketmodule.c
# - https://opensource.apple.com/source/xnu/xnu-4570.31.3/bsd/sys/kern_control.h.auto.html
# - https://opensource.apple.com/source/xnu/xnu-344.49/bsd/sys/sys_domain.h.auto.html
# - https://opensource.apple.com/source/xnu/xnu-2782.20.48/bsd/net/if_utun.h.auto.html
#
@whiler
whiler / escape.sh
Last active December 27, 2022 21:46
escape string in bash shell
escape() {
sed -e 's/[]\/$*.^[]/\\&/g' <<<"${1}"
}
@whiler
whiler / http-proxy.go
Last active May 19, 2020 14:26
HTTP Proxy in Golang
package main
import (
"context"
"flag"
"fmt"
"io"
"log"
"net"
"net/http"
@whiler
whiler / hmac-sha256.sh
Last active October 3, 2024 08:43
hmac sha256 encode with url safe base64 in bash shell
$ echo -en "message" | openssl dgst -sha256 -hmac "key" -binary | base64 | sed -e 's/+/-/g' -e 's/\//_/g' | tr -d =
bp7ym3X__Ft6uuUn1Y_a2y_kLnIZARl2kXNDBl9Y7Uo