Skip to content

Instantly share code, notes, and snippets.

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

Zack Zeng knight42

❤️
Loving @FogDong
View GitHub Profile
#!/bin/bash
SWAGGER_DOCS_PORT=${SWAGGER_DOCS_PORT:-8080}
d=$(mktemp -d)
cd $d || exit 1
wget -q https://raw.githubusercontent.com/moby/moby/master/api/swagger.yaml
docker run --rm -tid -v "$PWD/swagger.yaml":/usr/share/nginx/html/swagger.yaml \
-e 'REDOC_OPTIONS=hide-hostname="true" lazy-rendering' \
-p $SWAGGER_DOCS_PORT:80 \
bfirsh/redoc:1.6.2
@knight42
knight42 / mozlz4a.py
Created January 26, 2018 09:41 — forked from Tblue/mozlz4a.py
MozLz4a compression/decompression utility
#!/usr/bin/env python
#
# Decompressor/compressor for files in Mozilla's "mozLz4" format. Firefox uses this file format to
# compress e. g. bookmark backups (*.jsonlz4).
#
# This file format is in fact just plain LZ4 data with a custom header (magic number [8 bytes] and
# uncompressed file size [4 bytes, little endian]).
#
# This Python 3 script requires the LZ4 bindings for Python, see: https://pypi.python.org/pypi/lz4
#
@knight42
knight42 / main.go
Created August 13, 2018 17:59 — forked from walm/main.go
Simple Golang DNS Server
package main
import (
"fmt"
"log"
"strconv"
"github.com/miekg/dns"
)
@knight42
knight42 / aws_ip_ranges.py
Created August 30, 2018 10:29
get aws ip ranges in cn-north-1 region
#!/usr/bin/env python -O
# -*- coding: utf-8 -*-
#from __future__ import print_function, unicode_literals, with_statement, division, absolute_import
# import os
# import random
# import requests
import sys
import requests
@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:
// ==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/*

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?

package main
import (
"bytes"
"context"
"fmt"
"io"
"log"
"net"
"strconv"
@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"
)
@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