Skip to content

Instantly share code, notes, and snippets.

View knight42's full-sized avatar
❤️
Loving @FogDong

Jian Zeng knight42

❤️
Loving @FogDong
View GitHub Profile
@knight42
knight42 / forwarder.go
Created April 3, 2024 08:35
tcp forwarder that will retry upon connection refused error
package main
import (
"errors"
"flag"
"fmt"
"io"
"log/slog"
"net"
"os"
@knight42
knight42 / ci-check-pr-title-format.py
Created April 24, 2023 08:55 — forked from rexwangcc/ci-check-pr-title-format.py
A Python Script for checking Pull Request title conventions.
import sys
import re
from typing import Callable, List
VALID_PR_TAGS = {
# this pr implements new features
"Feature",
# this pr fixes bugs
"Bugfix",
# this pr updates documentation
@knight42
knight42 / compare_oss_cdn.py
Created November 3, 2022 03:29
比较阿里云 OSS 于 CDN 价格
#!/usr/bin/env python -O
def compare_price(requests_count: int, cdn_hit_ratio: float, obj_size_kb: int):
cdn_traffic_per_gb_price = 0.24
cdn_https_requests_per_10_thousand_price = 0.05
cdn_back_to_origin_traffic_per_gb = 0.15
oss_traffic_per_gb_price = 0.5
oss_get_per_10_thousand_price = 0.01
@knight42
knight42 / envoy-config.yml
Created September 16, 2022 10:17
Envoy ext_auth demo
static_resources:
listeners:
- name: listener_0
address:
socket_address:
protocol: TCP
address: 127.0.0.1
port_value: 3000
filter_chains:
- filters:
@knight42
knight42 / go.mod
Created May 15, 2022 14:47
Connect to the buildkitd embeded in dockerd
module q
go 1.18
replace github.com/docker/docker => github.com/docker/docker v20.10.3-0.20220224222438-c78f6963a1c0+incompatible
require (
github.com/containerd/console v1.0.3
github.com/docker/docker v20.10.7+incompatible
github.com/moby/buildkit v0.10.3
@knight42
knight42 / main.go
Last active September 14, 2020 05:45
scan non-synced shared informer factory in k8s unit tests
package main
import (
"bufio"
"fmt"
"os"
"path/filepath"
"strings"
"sync"
)
package main
import (
"bytes"
"context"
"fmt"
"io"
"log"
"net"
"strconv"

FWIW: I didn't produce the content presented here (the outline from Edmond Lau's book). I've just copy-pasted it from somewhere over the Internet, but I cannot remember what exactly the original source is. I was also not able to find the author's name, so I cannot give him/her the proper credits.


Effective Engineer - Notes

What's an Effective Engineer?

// ==UserScript==
// @name Open in godoc
// @namespace https://github.com/knight42
// @version 0.1
// @description Open godoc from GitHub
// @author knight42
// @include https://github.com/*/*
// @exclude https://github.com/*/*/blob/*
// @exclude https://github.com/settings/*
// @exclude https://github.com/orgs/*
@knight42
knight42 / clean-k8s-yaml.py
Last active October 10, 2018 09:11
remove unused fields in yaml of k8s object
#!/usr/bin/env python -O
# -*- coding: utf-8 -*-
import yaml
import sys
def delete_key(d, *keys):
for key in keys:
if d.get(key) is not None: