Skip to content

Instantly share code, notes, and snippets.

View liweitianux's full-sized avatar
🎵
Focusing

Weitian LI liweitianux

🎵
Focusing
  • Shanghai, China
  • 18:38 (UTC +08:00)
View GitHub Profile
@liweitianux
liweitianux / oplog_marshal.go
Last active May 23, 2025 01:38
JSON-based marshaling with custom "oplog" tag
package main
import (
"bytes"
"encoding/json"
"fmt"
"reflect"
"time"
"strings"
)
@liweitianux
liweitianux / grdc.c
Created January 14, 2025 02:23
grdc – grand digital clock (curses)
/*
* Copyright (c) 2002 Amos Shapir.
* Public domain.
*
* Grand digital clock for curses compatible terminals
*
* Usage: grdc [-st] [-d msecs] [n] -- run for n seconds (default infinity)
* Flags: -s: scroll (default scroll duration 120msec)
* -t: show time in 12-hour format
* -d msecs: specify scroll duration (implies -s)
@liweitianux
liweitianux / bird.conf.j2
Created December 22, 2024 10:52
BIRD (Jinja template) for OSPF & OSPFv3 with DPVS
# NOTE: bird2 on centos 7.x
# Jinja template
# Configure logging
log syslog all;
# Log to file; need to 'touch /var/log/bird.log && chown bird: /var/log/bird.log'
#log "/var/log/bird.log" { debug, trace, info, remote, warning, error, auth, fatal, bug };
# Set router ID. It is a unique identification of your router, usually one of
# IPv4 addresses of the router. It is recommended to configure it explicitly.
@liweitianux
liweitianux / dnsqinfo.go
Last active October 28, 2024 02:42
Simple DNS query inspector (UDP+TCP+DoT+DoH)
// SPDX-License-Identifier: MIT
//
// Simple DNS server that inspects the query and reflects it back.
//
// Weitian LI
// 2024-10-23
//
package main
@liweitianux
liweitianux / pebble-ocsp.go
Created September 16, 2024 01:40
OCSP Responder accompanying Pebble CA
// SPDX-License-Identifier: MIT
//
// OCSP Responder accompanying Pebble CA.
//
// Aaron LI
// 2024-09-13
//
// Credits:
// - How can a client get the revocation status of a certificate?
// https://github.com/letsencrypt/pebble/issues/177#issuecomment-515928913
@liweitianux
liweitianux / encryptor.c
Last active August 24, 2023 09:08
Chacha20-Poly1305 AEAD with PBKDF2 key derivation
/*-
* SPDX-License-Identifier: MIT
*
* Copyright (c) 2022-2023 Aaron LI
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
@liweitianux
liweitianux / .git-commit-template.txt
Created August 1, 2023 02:00 — forked from adeekshith/.git-commit-template.txt
This commit message template helps you write great commit messages and enforce it across teams.
# <type>: (If applied, this commit will...) <subject> (Max 50 char)
# |<---- Using a Maximum Of 50 Characters ---->|
# Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# Provide links or keys to any relevant tickets, articles or other resources
# Example: Github issue #23
@liweitianux
liweitianux / hexdump.lua
Last active February 21, 2024 12:05
Hexdump in Lua
-- Hexdump the input data using the same style as 'hexdump -C'.
-- Supports Lua 5.1 and above.
-- Credit: http://lua-users.org/wiki/HexDump
function hexdump(data)
if type(data) ~= "string" then
return nil, "expected string type, but given " .. type(data)
end
local pieces = {}
local i = 1
@liweitianux
liweitianux / dfly-install-uefi.md
Last active December 17, 2023 15:33
DragonFly BSD Installation (UEFI & HAMMER2)

DragonFly BSD Installation

Date: 2023-04-22

Setup:

  • Disk: /dev/da3 (500GB)
  • Use full disk
  • UEFI boot
  • GPT disk type (don't use disklabel64(8))
@liweitianux
liweitianux / centos7-clang13.md
Last active April 19, 2023 05:29
Build Clang 13 on CentOS 7

Build Clang 13 on CentOS 7

Requirements [1]:

  • CMake >=3.13.4
  • GCC >=7.1.0
  • Python >=3.6 (automated test suite)
  • zlib >=1.2.3.4
  • GNU Make >=3.79