Skip to content

Instantly share code, notes, and snippets.

#! /bin/bash
# https://pve.proxmox.com/wiki/Cloud-Init_Support
main() {
# download the image
if [ ! -f "$VM_IMAGE" ]; then
wget -c -x -P "$VM_IMAGE_DIR" "$VM_IMAGE_URL"
fi
# create a new VM with VirtIO SCSI controller

Linux 下如何正确设置 locale?

Linux 下如何正确设置 locale 一直令人困扰, 简单研究发现下面这些 packages 提供了用于 locale 配置的工具, 那么这些工具的关系是什么呢?

# find /etc -type f -name '*locale*'
/etc/default/locale
/etc/locale.gen
/etc/locale.alias
$InterfaceIndex = 29
# Set-NetIPAddress 不能设置 -DefaultGateway
# 而 New-NetIPAddress 必须设置 -IPAddress, 已设置静态 IP 的情况下重复 添加 会报错
$CurrentDefaultGateway = (Get-NetRoute -DestinationPrefix "0.0.0.0/0" -InterfaceIndex $InterfaceIndex).NextHop
Remove-NetIPAddress -DefaultGateway $CurrentDefaultGateway -InterfaceIndex $InterfaceIndex -Confirm:$False
# Set ss-tproxy as DefaultGateway
New-NetIPAddress -IPAddress 10.0.0.20 -PrefixLength 24 -DefaultGateway 10.0.0.5 -InterfaceIndex $InterfaceIndex -Confirm:$False
@ak1ra-komj
ak1ra-komj / deepl.rs
Created February 19, 2023 12:56 — forked from andelf/deepl.rs
DeepL Rust command line
// https://zu1k.com/posts/thinking/deception-tactics-in-deepl-api-design/
#! /bin/bash
# Check git lfs file's integrity in ~/.cache/huggingface/transformers by it etag
# Run this script in MINGW64 if you are on Windows
# Root of all evil: https://huggingface.co/openai/clip-vit-large-patch14/resolve/main/pytorch_model.bin
# I spent a whole day troubleshooting AUTOMATIC1111/stable-diffusion-webui bugs due to incomplete file downloads
# OSError: Unable to load weights from pytorch checkpoint file for '~/.cache/huggingface/transformers/c506559a5367a918bab46c39c79af91ab88846b49c8abd9d09e699ae067505c6.6365d436cc844f2f2b4885629b559d8ff0938ac484c01a6796538b2665de96c7'.
# If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
path=~/.cache/huggingface/transformers
# coding: utf-8
# A helper script to convert vol.moe's mobi files to 7zip archives.
# python3 -m pip install mobi py7zr
import argparse
import logging
import os
import shutil
import sys
import time
# clash core DNS sample config
# Wiki: https://github.com/Dreamacro/clash/wiki/configuration
# Unoffcial Wiki: https://lancellc.gitbook.io/clash/clash-config-file/dns
dns:
# 默认为 true
enable: true
# 是否启用 AAAA 查询
# 并不代表 clash 不会建立 IPv6 连接或者主动丢弃 AAAA 响应
ipv6: false
# clash DNS server 监听地址
# coding: utf-8
import re
import json
import logging
from telethon import TelegramClient, events
def init_logger(name, level=logging.INFO):
format = '[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s'
# Author: ak1ra
# Date: 2022-01-23
# 自动添加访问特定域名时使用 OpenVPN 网关作为下一条的路由
# 配置命令行选项
Param(
[string]$Action = "add",
[string]$Domain = "cloud.tencent.com",
[Parameter(Mandatory=$false)][Int32]$InterfaceIndex,
[string]$InterfaceDescription = "TAP-Windows Adapter V9",
@ak1ra-komj
ak1ra-komj / dds2webp.sh
Created October 29, 2021 15:35
GNU Parallel 实战: Using GNU Parallel + ImageMagick to convert .dds image
#! /bin/bash
# author: ak1ra
# date: 2021-10-29
# using GNU Parallel + ImageMagick to convert .dds image
function magick_convert() {
# ddsImage/ddsImage000000/CHU_UI_Character_0000_00_00.dds
src="$1"
format="$2"
resize="$3"