Skip to content

Instantly share code, notes, and snippets.

View wangjiezhe's full-sized avatar
🏠
Working from home

Jiezhe Wang wangjiezhe

🏠
Working from home
View GitHub Profile
@wangjiezhe
wangjiezhe / geo.caddyfile
Created June 12, 2024 03:09
Reverse proxy for Google Map using caddy.
geo.domain.ltd {
# cert setting missing
handle /vt/* {
reverse_proxy mt0.google.com {
header_up Host {upstream_hostport}
}
}
handle {
respond 404
}
@wangjiezhe
wangjiezhe / config.yml
Created June 7, 2024 14:00
Reverse proxy for Docker Hub using docker and caddy.
version: 0.1
log:
fields:
service: registry
storage:
cache:
blobdescriptor: inmemory
filesystem:
rootdirectory: /var/lib/registry
delete:
@wangjiezhe
wangjiezhe / train.py
Last active March 20, 2024 04:40
Accelerating Inference in TensorFlow with TensorRT User Guide https://docs.nvidia.com/deeplearning/frameworks/tf-trt-user-guide/index.html
import tensorflow as tf
from tensorflow import keras
# Define a simple sequential model
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(input_shape=(28, 28)),
tf.keras.layers.Dense(128, activation='relu'),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10)
])
@wangjiezhe
wangjiezhe / nvidia_pcibusid.cc
Last active December 31, 2023 11:20
Get PCI Bus ID for Nvidia GPU. Compiled and run by `nvcc -arch=sm_89 nvidia_pcibusid.cc -o nvidia_pcibusid -lcuda -run`
#include <iostream>
#include <cuda_runtime.h>
#include <cuda.h>
int main() {
CUresult cuResult;
cuInit(0);
int deviceCount;
cuResult = cuDeviceGetCount(&deviceCount);
@wangjiezhe
wangjiezhe / hyper-v.cmd
Created November 18, 2023 01:08
在 Windows 家庭版上安装 Hyper-V
pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL
import os
import opencc
cv = opencc.OpenCC('t2s.json')
for i in os.listdir():
j = cv.convert(i)
if j != i:
os.rename(i, j)
@wangjiezhe
wangjiezhe / fileserver.py
Last active September 28, 2023 01:06
fileserver.py (from https://phus.lu)
#!/usr/bin/env python3
# pylint: disable=C0111, C0103
"""
curl phus.lu/fileserver.py | env PORT=8001 python
"""
import os
import re
import sys
@wangjiezhe
wangjiezhe / acme-aliyun.sh
Last active April 6, 2024 04:40
install acme.sh and issue a certificate on archlinux
#!/bin/bash
pacman -S --noconfirm acme.sh
yay -S --noconfirm acme.sh-systemd
# https://ram.console.aliyun.com/users
# require `AliyunDNSFullAccess`
export Ali_Key="***"
export Ali_Secret="***"
--- gentoo/eclass/rust-toolchain.eclass 2022-12-28 00:48:32.000000000 +0800
+++ local/eclass/rust-toolchain.eclass 2023-01-08 19:02:42.048876389 +0800
@@ -36,6 +36,7 @@
case ${CTARGET%%*-} in
aarch64*gnu) echo aarch64-unknown-linux-gnu;;
aarch64*musl) echo aarch64-unknown-linux-musl;;
+ mips64el*) echo mips64el-unknown-linux-gnuabi64;;
mips64*) echo mips64-unknown-linux-gnuabi64;;
powerpc64le*) echo powerpc64le-unknown-linux-gnu;;
powerpc64*) echo powerpc64-unknown-linux-gnu;;
@wangjiezhe
wangjiezhe / crossdev-fix-multilib.patch
Created May 7, 2023 04:38
fix multilib setting for sys-devel/crossdev
--- /usr/bin/crossdev 2022-12-17 00:33:21.559942156 +0800
+++ /opt/crossdev 2023-01-10 16:23:25.131824325 +0800
@@ -1310,7 +1310,7 @@
force+=" multilib"
;;
*)
- mask+=" multilib";;
+ mask+=" $( [[ ${MULTILIB_USE} == "yes" ]] && echo - )multilib";;
esac