Skip to content

Instantly share code, notes, and snippets.

QinMing /
Last active December 14, 2020 04:06
Set the correct line ending, either CRLF or LF, for a directory tree
#!/usr/bin/env python3
# Sample Usage:
# <command> '.*\.html'
import logging
import os
import re
from argparse import ArgumentParser
QinMing / .zshrc
Last active January 4, 2022 19:38
my very own zshrc
# Copyright (c) 2016-2021 Ming Qin (覃明) <>
# Open source under MIT LICENSE.
export PATH=/usr/local/bin:$PATH
export ZSH="$HOME/.oh-my-zsh"
# So that it doesn't add the extra excape character. Without this line, pasting `` will become `\?param`
QinMing / makefile
Last active October 9, 2018 08:26
MySQL utils
docker stop mysql1 || true
docker run --rm --volumes-from mysql1 -v $(BACK_DIR):/backup ubuntu tar cvf /backup/sql_volume.tar /var/lib/mysql
docker start mysql1
docker stop mysql1
docker run --rm --volumes-from mysql1 -v $(BACK_DIR):/backup ubuntu bash -c "rm -rf /var/lib/mysql/* && cd / && tar xvf /backup/sql_volume.tar"
docker start mysql1
docker exec -i mysql1 mysql -uroot $(DATABASE_NAME) < mysqldump
QinMing /
Created July 26, 2018 18:14
Run schemaspy
docker run -it --rm --net=host -v $PWD/static:/data mnuessler/schemaspy -hq -t mysql \
-host YOUR-DB.COM \
-u USER \
-db DB_NAME \
-o /data/FOLDER_NAME
QinMing /
Last active November 7, 2017 09:26
Dot file
# To run this file itself:
# wget -O && chmod +x
# Print out message in color
success() {
echo -e "\033[1;32m$1\033[0m"
alias grep='grep --color=auto'
alias l="ls -alhtr"
alias g='git'
alias gs="git status"
alias gl="git l"
alias gd="git diff"
alias gb="git branch"
alias gp="git pull"
function parse_git_branch() {
du -hs *
eval "echo \"$(< $STARTUP_TPL_PATH)\"" > $STARTUP_PATH
chmod +x $STARTUP_PATH
QinMing / .zshrc
Last active May 14, 2024 23:18
.zshrc (lazy loading shell functions)
# Copyright (c) 2016-2018 Ming Qin (覃明) <>
# Open source under MIT LICENSE.
lazy_load() {
# Act as a stub to another shell function/command. When first run, it will load the actual function/command then execute it.
# E.g. This made my zsh load 0.8 seconds faster by loading `nvm` when "nvm", "npm" or "node" is used for the first time
# $1: space separated list of alias to release after the first load
# $2: file to source
# $3: name of the command to run after it's loaded
# $4+: argv to be passed to $3
QinMing / ss
Last active May 27, 2020 17:29
upload/download current folder to the same position at remote host
# Copyright (c) 2016 Ming Qin (覃明) <>
# Open source under MIT LICENSE.
# Notice:
# dot files in remote will not be downloaded since we are using `zip -r -q ~/$ZIP_FILE_NAME ./*`
# This is to protect local dot files
# Change this to `zip blabala . ` if dot files are wanted. Also, `find . -delete` need to change
# Note: `find $path -delete` will delete the folder itself, so use `find . -delete`