Skip to content

Instantly share code, notes, and snippets.

@Yunuuuu
Yunuuuu / namespace.R
Last active April 3, 2024 03:35
Use environment to define internal namespace and sub-namespace like Python. Instead of using `R6` object, which will make the data object mutable, this will break normal scoping rules of R.
# This is not same with `r-polars` pacakge, which use more complicated design to create namespace and sub-namespace
#
# In package namespace -----------------------
utils::globalVariables("self")
# Check that all elements of a list are named.
# NULL and empty lists return TRUE.
all_named <- function(x) {
if (length(names(x)) != length(x) || any(names(x) == "")) {
return(FALSE)
}
@Yunuuuu
Yunuuuu / rsync-resume.sh
Last active July 6, 2026 10:03
面向弱网和不稳定 SSH 连接的 rsync 自动重试脚本, 支持无限重连, SSH 配置与 ssh-agent, 以及可选临时 SSH 密钥.
#!/usr/bin/env bash
# rsync-resume 是一个面向不稳定网络环境的 rsync 传输包装脚本。
#
# 它负责在 rsync 因网络、SSH 或协议连接问题中断后自动等待并重新执行传输,
# 适合跨公网、弱网、高延迟或连接容易中断的服务器之间进行长时间数据同步。
#
# 脚本本身不会为 rsync 添加默认同步参数。所有归档、删除、压缩、断点文件、
# 进度显示、限速和排除规则等传输行为, 均由用户直接通过 rsync 参数控制。
#
# 对于 SSH 远程传输, 脚本默认使用现有 SSH 配置、IdentityFile 或 ssh-agent
@Yunuuuu
Yunuuuu / frp-install.sh
Last active July 14, 2026 04:46
Install or update FRP from the SourceForge mirror.
# Install or update FRP from the SourceForge mirror.
#
# Usage:
# _install_frp [OPTIONS]
# _install_frp -h
# unset -f _install_frp
#
# Default mode: --user
#
# Default user layout:
@Yunuuuu
Yunuuuu / xray-install.sh
Last active July 14, 2026 05:29
Install or update Xray from the SourceForge mirror.
# Install or update Xray from the SourceForge mirror.
#
# Usage:
# _install_xray [OPTIONS]
# _install_xray -h
# unset -f _install_xray
#
# Default mode: --user
#
# Default user layout:
@Yunuuuu
Yunuuuu / Remove-UninstallEntry.ps1
Last active July 18, 2026 12:50
Interactive PowerShell function for finding and removing stale Windows uninstall registry entries.
<#
.SYNOPSIS
Finds and removes Windows uninstall registry entries interactively.
.DESCRIPTION
Scans user and machine uninstall registry locations, detects stale MSI
entries, and lets you select entries before deletion.
Selection:
- Press Enter to select detected stale MSI entries.