Skip to content

Instantly share code, notes, and snippets.

View jiahuif's full-sized avatar

Jiahui Feng jiahuif

View GitHub Profile
@jiahuif
jiahuif / main.go
Last active March 20, 2024 23:49
Minimalist Kubernetes Validating Admission Webhook
package main
import (
"encoding/json"
"flag"
"fmt"
"log"
"net/http"
admissionv1 "k8s.io/api/admission/v1"
@jiahuif
jiahuif / cfsslnameconstraints.go
Last active August 12, 2022 23:13
cfssl initCA with Name Constraints
package main
import (
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
"crypto/x509"
"crypto/x509/pkix"
"encoding/hex"
"encoding/json"
FROM alpine AS alpine-full
RUN apk add gcc g++ libc-dev linux-headers zlib-dev
FROM debian AS builder
ENV LLVM_VERSION=13.0.0
COPY --from=alpine-full / /alpine
RUN apt-get update && apt-get install -y curl xz-utils cmake ninja-build python3
@jiahuif
jiahuif / cmake.bash
Created August 18, 2021 01:23
cmake wrapper to workaround preload issue.
#!/bin/sh
OLD_LD_PRELOAD="$LD_PRELOAD"
LD_PRELOAD=""
if [ "$1" == "--build" ]; then
LD_PRELOAD="$OLD_LD_PRELOAD";
fi
if [ "$1" == "--install" ]; then
@jiahuif
jiahuif / test_204.c
Created April 23, 2021 22:45
test_204.c
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#define BUF_SIZE 1024
--- /etc/kubernetes/manifests/kube-controller-manager.manifest 2021-03-09 20:06:23.081318499 +0000
+++ /tmp/kube-controller-manager.manifest 2021-03-09 20:12:54.482769996 +0000
@@ -59,7 +59,11 @@
"--allocate-node-cidrs=true",
"--flex-volume-plugin-dir=/home/kubernetes/flexvolume",
"--pv-recycler-pod-template-filepath-nfs=/home/kubernetes/kube-manifests/kubernetes/pv-recycler-template.yaml",
-"--pv-recycler-pod-template-filepath-hostpath=/home/kubernetes/kube-manifests/kubernetes/pv-recycler-template.yaml"
+"--pv-recycler-pod-template-filepath-hostpath=/home/kubernetes/kube-manifests/kubernetes/pv-recycler-template.yaml",
+"--feature-gates=ControllerManagerLeaderMigration=true",
+"--leader-elect=true",
@jiahuif
jiahuif / zerocount.c
Created February 19, 2021 05:08
zerocount.c
#include <stdio.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
int main(int argc, char **argv) {
if (argc < 2) {
fprintf(stderr, "usage: %s FILE\n", argv[0]);
return 1;
}
@jiahuif
jiahuif / main.go
Created October 16, 2017 06:00
golang: tunnel tcp over socks5
package main
import (
"flag"
"io"
"net"
"time"
log "github.com/sirupsen/logrus"
"golang.org/x/net/proxy"
@jiahuif
jiahuif / transmission-download-site.nginx
Created April 12, 2016 05:00
nginx config file for transmission download site
# requires ngx-fancyindex
server {
listen 8080;
location /downloads {
alias /var/lib/transmission-daemon/downloads;
charset utf-8;
gzip on;
fancyindex on;
fancyindex_exact_size off;
fancyindex_default_sort date_desc;