Skip to content

Instantly share code, notes, and snippets.

View kuanyui's full-sized avatar
❄️
なんでそんなに慣れてんだよ!

クエン酸 kuanyui

❄️
なんでそんなに慣れてんだよ!
View GitHub Profile
@kuanyui
kuanyui / Makefile
Last active June 2, 2023 03:19
Makefile for gvm + $GOPATH + git checkout
.ONESHELL:
REPO_DIR="${PWD}"
define my_git_checkout
(git checkout $(1) || git checkout --track origin/$(1)) && git pull
endef
define GVM_USE
echo "========================================================================================="
@kuanyui
kuanyui / rsync.sh
Last active March 3, 2023 06:14
my alias for rsync
function init_rsync() {
# --archive, -a archive mode is -rlptgoD (no -A,-X,-U,-N,-H)
# --recursive, -r recurse into directories
# --links, -l copy symlinks as symlinks
# --perms, -p preserve permissions
# --times, -t preserve modification times
# --group, -g preserve group
# --owner, -o preserve owner (super-user only)
# -D same as --devices --specials
# --devices preserve device files (super-user only)
function cliPrompt<T = string>(promptMsg: string): Promise<T> {
return new Promise((resolve, reject) => {
process.stdin.on("data", function(data: any) {
resolve(data.toString())
process.stdin.end()
})
process.stdout.write(promptMsg);
})
}
// ==UserScript==
// @name Mastodon Anti-zh_CN Filters Installer
// @grant none
// @version 1.2
// @match https://pawoo.net/filters
// @match https://pawoo.net/filters/new
// @run-at document-end
// ==/UserScript==
// [USAGE]
// 1. Change "@match" to the filter page of the Mastodon instance you're using ("Perference -> Filters")
@kuanyui
kuanyui / renameunix2win.py
Created October 17, 2022 10:52
To rename files in ext4 to exFAT. Forked from https://askubuntu.com/a/671466/442465
#!/usr/bin/env python3
import os
import shutil
import sys
if len(sys.argv) == 1:
print('[USAGE] Please provide directory in argv.')
exit(1)
directory = sys.argv[1]
@kuanyui
kuanyui / Makefile
Created October 17, 2022 02:36
Auto use nvm & gvm in Makefile
.ONESHELL: # This ".ONESHELL" is important!
define GVM_USE
echo "========================================================================================="
echo "[INFO] Recommended Go Version: 1.9"
source "${GVM_ROOT}/scripts/gvm" # Or source "${HOME}/.gvm/scripts/gvm"
gvm use go1.9
echo "[INFO] Remember to git checkout in ~/.gvm/pkgsets/go1.9/global/src/github.com/........"
echo "========================================================================================="
endef
@kuanyui
kuanyui / Makefile
Created August 24, 2022 11:55
auto `nvm use` in Makefile
.ONESHELL:
.PHONY: clear build watch server
default: watch
GULP:="./node_modules/.bin/gulp"
define NVM_USE
source ~/.nvm/nvm.sh
nvm use v14.20.0
endef
@kuanyui
kuanyui / mscorex.sh
Created August 16, 2022 13:55
Launch MuseScore until success
#!/bin/bash
# https://stackoverflow.com/questions/1570262/get-exit-code-of-a-background-process
mscore > /dev/null 2>&1 &
MS_PID=$!
while true
do
# if string.length == 0
@kuanyui
kuanyui / Makefile
Last active March 11, 2022 08:49
Colors in console (NodeJS, Makefile)
ifneq (,$(findstring xterm,${TERM}))
DARK_BLACK := $(shell tput setaf 0)
DARK_RED := $(shell tput setaf 1)
DARK_GREEN := $(shell tput setaf 2)
DARK_YELLOW := $(shell tput setaf 3)
DARK_BLUE := $(shell tput setaf 4)
DARK_MAGENTA := $(shell tput setaf 5)
DARK_CYAN := $(shell tput setaf 6)
DARK_WHITE := $(shell tput setaf 7)
BLACK := $(shell tput setaf 8)
@kuanyui
kuanyui / Makefile
Created March 11, 2022 07:21 — forked from rsperl/Makefile #snippet
self-documenting makefile with colors
SHELL=/bin/bash
# to see all colors, run
# bash -c 'for c in {0..255}; do tput setaf $c; tput setaf $c | cat -v; echo =$c; done'
# the first 15 entries are the 8-bit colors
# define standard colors
ifneq (,$(findstring xterm,${TERM}))
BLACK := $(shell tput -Txterm setaf 0)
RED := $(shell tput -Txterm setaf 1)