Skip to content

Instantly share code, notes, and snippets.

View inclyc's full-sized avatar

Yingchi Long inclyc

  • Institute of Computing Technology, CAS
  • Beijing
  • 10:51 (UTC +08:00)
View GitHub Profile
@inclyc
inclyc / filter.py
Created February 25, 2023 20:09
Rewrite labeled git commit message "pathlike", e.g "[foo][bar] baz" -> "foo/bar: baz"
#!/usr/bin/env python3
from sys import stdin
import re
def label2path(msg: str):
'''
"[foo][bar] baz" -> "foo/bar: baz"
For commit messages rewriting
@inclyc
inclyc / Group-Report.mk
Last active April 16, 2023 15:21
Generate report draft (markdown) and convert it into html (for email sending)
YEAR ?= $(shell date +"%Y")
MONTH ?= $(shell date +"%m")
DAY ?= $(shell date +"%d")
export YEAR
export MONTH
export DAY
PREFIX ?= $(YEAR)/$(MONTH)/$(DAY)
@inclyc
inclyc / patchelf-string-literal.sh
Created April 20, 2023 03:08
Patch hardcoded string literals in ELF
#!/usr/bin/env bash
# https://everydaywithlinux.blogspot.com/2012/11/patch-strings-in-binary-files-with-sed.html
function patch_strings_in_file() {
local FILE="$1"
local PATTERN="$2"
local REPLACEMENT="$3"
# Find all unique strings in FILE that contain the pattern
#!/usr/bin/env python3
import subprocess
def main():
storePaths = [
'5jrqcja5680bgm7ycdw6lpnvm65hga5y-qemu-8.0.0',
'1nyg1fvhpz8bx3vn3r9f18zhra2rpbx9-glibc-2.37-8',
'28wb2asziwwv2wxynqi9nxiigycsjjmg-zlib-1.2.13',
'hp8yk1q64r8qmxp1k6bava09asgx805z-pcre2-10.42',
@inclyc
inclyc / start-win10.sh
Created May 5, 2023 08:51
QEMU - Windows 10 startup script
#!/usr/bin/env bash
MACHINE_NAME=win10
MACHINE_PATH=$PWD
SPICE_LINK=/tmp/vm-spice-$MACHINE_NAME.socket
# shellcheck disable=SC2054
qemu_cmd=(
@inclyc
inclyc / launch-vm.sh
Last active September 20, 2023 11:21
#!/usr/bin/env bash
# shellcheck disable=SC2054
# Tweakable options, comment to unset.
# Passthrough the GPU (hardware) via PCI Passthrough (OVMF)
EnableGPUPassthrough=
# Whether or not add a sound device, connect to the system
# EnableSystemSound=
@inclyc
inclyc / TPM.sh
Created September 9, 2023 10:20
TPM for QEMU, command line
# TPM
TPMSTATE=${TPMSTATE:-"$XDG_RUNTIME_DIR/tpm0"}
mkdir -p $TPMSTATE
TPMCMD=(
swtpm
socket
-d
--tpmstate dir=$TPMSTATE,mode=0600
--tpm2
--ctrl type=unixio,path=${TPMSTATE}/swtpm-sock
@inclyc
inclyc / grammar.txt
Created September 16, 2023 03:21
The grammar of Nix language, official implementation
start: expr;
expr: expr_function;
expr_function
: identifier ':' expr_function
| '{' formals '}' ':' expr_function
| '{' formals '}' '@' identifier ':' expr_function
| ASSERT expr ';' expr_function
#!/usr/bin/env bash
# add-vfio.sh: detect iommu groups and override the driver of these devices to vfio-pci
IsolatingDevice="$1"
IOMMUGroup=$(ls "/sys/bus/pci/devices/$IsolatingDevice/iommu_group/devices")
for Device in ${IOMMUGroup}; do
DeviceDir="/sys/bus/pci/devices/$Device"
@inclyc
inclyc / llvm-build.sh
Created October 4, 2023 11:35
LLVM compiling commands for developers, with some tweaks for debugging & ccache
#!/usr/bin/env bash
LLVM="$1"
# LLVMBaseDirectory="$LLVM"
# BuildMode="Release"
# BuildDirectory="build-release"
# BuildBase="${LLVMBaseDirectory}/${BuildDirectory}"
# LLVMEnableProjects="clang;mlir"