Skip to content

Instantly share code, notes, and snippets.

import os
import sys
def rename_items_with_chinese_numerals(directory_path):
"""
Renames files and subdirectories in the specified directory by replacing
Chinese numerals (一, 二, 三, 四, 五, 六, 七, 八, 九) with their
corresponding Arabic numerals (1, 2, 3, 4, 5, 6, 7, 8, 9).
Args:
@myl7
myl7 / mermaidSvg.css
Last active June 15, 2024 10:41
CSS to make Mermaid SVG charts automatically switch to light/dark mode based on class `dark` of parents
#graph-div {
font-family: 'trebuchet ms', verdana, arial, sans-serif;
font-size: 16px;
fill: #333;
}
#graph-div .error-icon {
fill: #552222;
}
#graph-div .error-text {
fill: #552222;
@myl7
myl7 / 魂2弹反.xml
Last active January 25, 2024 20:06
DARK SOULS II: Scholar of the First Sin(黑暗之魂2原罪学者)跳劈&弹反 Razer Synapse(雷蛇 雷云)鼠标宏。以 0.05s 为单位已手动调节到极限。结合 https://www.bilibili.com/read/cv2283238/ (archived http://web.archive.org/web/20240125200414/https://www.bilibili.com/read/cv2283238/ ) 使用。
<?xml version="1.0" encoding="utf-8"?>
<Macro xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Name>魂2弹反</Name>
<Guid>5c389610-c089-4dc2-89db-c429bc285cbf</Guid>
<MacroEvents>
<MacroEvent>
<Type>1</Type>
<KeyEvent>
<Makecode>42</Makecode>
</KeyEvent>
@myl7
myl7 / ci.yaml
Created August 23, 2023 12:24
GitHub Actions Node + pnpm basic CI
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
name: Test
runs-on: ubuntu-latest
@myl7
myl7 / ci.yaml
Created August 23, 2023 12:20
GitHub Actions Rust basic CI
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
name: Test
runs-on: ubuntu-latest
@myl7
myl7 / sendmail.py
Last active July 13, 2022 01:12
SMTP send script for simple email notification
import sys
import smtplib
SMTP_SERVER = 'smtp.mailgun.org'
SMTP_PORT = 587
SMTP_USERNAME = '[email protected]'
SMTP_PASSWORD = ''
FROM_ADDR = '[email protected]'
TO_ADDRS = ['[email protected]']
@myl7
myl7 / ci.yaml
Created April 13, 2022 13:09
GitHub Actions Docker CD template
name: CI with CD
on:
push:
branches:
- main
release:
types:
- published
jobs:
ci:
@myl7
myl7 / build.sh
Created January 25, 2022 05:09
Staticly build go even with cgo but excluding external dynamic libraries
#!/usr/bin/env bash
set -euo pipefail
# Ref: https://honnef.co/posts/2015/06/statically_compiled_go_programs__always__even_with_cgo__using_musl/
CC=musl-gcc go build --ldflags '-linkmode external -extldflags "-static"' "$@" cmd/bibak/main.go
@myl7
myl7 / main.cpp
Created December 26, 2021 12:17
Append a char into std::stringstream in C++ is hard
#include <sstream>
#include <string>
#include <cstdio>
int main() {
std::stringstream a;
a << "0"; // const char *
printf("%s\n", a.str().c_str()); // 0, expected
std::stringstream b;
@myl7
myl7 / reset.css
Last active January 19, 2022 11:51
Modern CSS reset
/**
* Modern CSS reset at https://gist.github.com/myl7/7af84d97e246b733c82dd414f49dfd29
* From Josh's Custom CSS Reset at https://www.joshwcomeau.com/css/custom-css-reset/
* Public domain
*/
*, *::before, *::after {
box-sizing: border-box;
}