Skip to content

Instantly share code, notes, and snippets.

View whiler's full-sized avatar
🇨🇳

whiler whiler

🇨🇳
View GitHub Profile
@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 / 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 / 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 / httpc.go
Last active November 17, 2020 08:57
default http client in golang
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 5 * time.Second,
KeepAlive: 30 * time.Second,
}).DialContext,
TLSHandshakeTimeout: 5 * time.Second,
ExpectContinueTimeout: 5 * time.Second,
ResponseHeaderTimeout: 7 * time.Second,
IdleConnTimeout: 5 * time.Second,
@whiler
whiler / adblock2domains.py
Created December 4, 2020 20:59
get domains from adblock rules in Python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import ipaddress
import re
HEAD = re.compile('^(\|\|?)?(https?://)?')
TAIL = re.compile('(/.*$)|(%2f.*$)|(%2F.*$)')
@whiler
whiler / extfile
Created April 25, 2021 16:23
generate the self-signed Certificate Authority and one certificate for localhost
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth,clientAuth
subjectAltName = @altnames
[altnames]
DNS.1 = localhost
DNS.2 = 127.0.0.1
DNS.3 = ::1
@whiler
whiler / create-a-workable-IPv6-network-for-ocserv-clients.md
Created June 6, 2021 05:40
create a workable IPv6 network for ocserv clients

create a workable IPv6 network for ocserv clients

  1. enable NDP proxy at ocserv server host: sysctl -w net.ipv6.conf.all.proxy_ndp=1 .

  2. assign a sub network of ocserv server host IPv6 network for clients, for example:

    if the IPv6 address of ocserv server host inteface eth0 is 2608:8207:7888:a450::1/64, then add the fellowing lines into ocserv.conf:

    ipv6-network = 2608:8207:7888:a450:cafe::/80
    
@whiler
whiler / mvfunc.sh
Created November 29, 2021 12:21
rename bash shell function
mvfunc() {
local original="$(declare -f $1)"
local newname="$2${original#$1}"
eval "${newname}"
}
@whiler
whiler / pi.go
Last active February 18, 2023 01:11 — forked from taiypeo/pi.go
Concurrent π calculation with Golang!
package main
import (
"fmt"
"math"
"runtime"
"time"
)
// Using the Bailey–Borwein–Plouffe formula
@whiler
whiler / svg2png.go
Created May 17, 2023 13:19
使用 golang 将 SVG 图像转换成 PNG 图像
package main
import (
"bytes"
"image"
"image/png"
"io"
"github.com/srwiley/oksvg"
"github.com/srwiley/rasterx"