Skip to content

Instantly share code, notes, and snippets.

@dhy2000
dhy2000 / create-container.sh
Last active May 29, 2026 10:02
Useful scripts to setup a docker container.
#!/bin/bash
###### FILL HERE ######
DATADIR_BASE="<base_dir>"
PUBLIC_DIR="<public_dir>"
IMAGE="<image>"
CONTAINER_BASE="<container basename>"
# `docker run` options
OPTIONS=(
@dhy2000
dhy2000 / add-user.sh
Created May 21, 2026 04:14
Quickly add a new user in linux servers.
#!/bin/bash
defaultuser=ubuntu
username=$1
set -ex
if [ -z "${username}" ]; then
echo "Empty username!"
exit 1
@dhy2000
dhy2000 / gitlab-trigger-ci.yml
Created November 7, 2025 06:19
A template .gitlab-ci.yml for trigger other repo's CI/CD pipeline and echo the triggered pipeline's output to current repo.
# This is a template .gitlab-ci.yml for trigger the pipeline of upstream repository.
#
# - Fill in the docker image and runner tag
# - Rename below `PROJECT_X` to the upstream repository's name
# - Setup `PROJECT_X_CI_API_TOKEN`, `PROJECT_X_TRIGGER_TOKEN`, `PROJECT_X_PROJECT_ID`, to CI/CD variables.
# - Pass arguments by `--form variables[VARIABLE_NAME]=VALUE` in curl trigger.
variables:
GIT_STRATEGY: none
GIT_SUBMODULE_STRATEGY: none
@dhy2000
dhy2000 / interact.cpp
Last active October 25, 2025 11:35
An interactor written in cpp for interactive algorithm problems.
/*
A simple interactor for algorithm problems.
Author: dhy2000
Usage:
- g++ interact.cpp -o interact [-DDEBUG]
- ./interact ./solution [args...]
*/
@dhy2000
dhy2000 / ipv4-cidr-exclude-rfc1918.txt
Last active September 30, 2025 09:34
IPv4 CIDR ranges exclude Private Addresses (RFC1918).
0.0.0.0/5
8.0.0.0/7
11.0.0.0/8
12.0.0.0/6
16.0.0.0/4
32.0.0.0/3
64.0.0.0/2
128.0.0.0/3
160.0.0.0/5
168.0.0.0/6
@dhy2000
dhy2000 / launch.json
Created May 15, 2025 03:16
VSCode Debugger launch.json to connect to GDB Server.
{
"configurations": [
{
"name": "GDB Connect",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/executable",
"cwd": "${workspaceFolder}",
"MIMode": "gdb",
"miDebuggerServerAddress": "localhost:9999",
@dhy2000
dhy2000 / vectorAdd.cu
Created May 6, 2025 09:06
vectorAdd of cuda-samples.
/**
* Vector addition: C = A + B.
*
* This sample is a very basic sample that implements element by element
* vector addition. It is the same as the sample illustrating Chapter 2
* of the programming guide with some additions like error checking.
*/
#include <stdio.h>
@dhy2000
dhy2000 / base-devel-debian-bookworm.dockerfile
Last active July 26, 2026 04:19
Base of my development docker.
FROM debian:bookworm
# setup apt
RUN sed -i 's#deb.debian.org#mirrors.ustc.edu.cn#g' /etc/apt/sources.list.d/debian.sources && \
apt-get update && apt-get install -y apt-transport-https ca-certificates gpg && \
sed -i 's#http#https#g' /etc/apt/sources.list.d/debian.sources && \
apt-get update && apt-get upgrade -y && apt-get install -y wget curl && apt-get clean
# install llvm
RUN wget --no-hsts -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \
@dhy2000
dhy2000 / set_cuda_env.sh
Last active November 10, 2025 07:26
Setup environment variables for bash/zsh.
# Environment setup script for bash/zsh.
_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]:-$0}"))
# --- ^_^ YOU CAN EDIT BELOW ^_^ --- #
_name="CUDA"
_components=(
bin/nvcc
)
_add_path=(
bin
@dhy2000
dhy2000 / Win11-Setup.md
Last active March 11, 2025 03:40
Setup guide for Windows 11 (Home Edition)

Windows 11 Setup

跳过联网

Windows 11 家庭版初始化阶段,选择完键盘布局后可能进入强制连接无线网络并登录微软账号的环节(如果连接了网线需要先拔掉)。跳过无线联网的方法参考这篇CSDN博客,总共提到了三种方法,推荐采用第二种:

Shift+F10 或 Shift+Fn+F10 打开 cmd,输入 oobe\bypassnro.cmd 命令(如果 cmd 窗口不是当前焦点,无法输入命令,需按 Alt+Tab 切换窗口),等待系统重启后,来到联网这步选择“我没有 Internet 连接”,下一步选择“继续执行受限的设置”即可设置本地的用户名和密码,无需登录微软账户。

常规设置