This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2016-2018 Ming Qin (覃明) <https://github.com/QinMing> | |
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
git config --global user.name "Ming Qin" | |
git config --global user.email "$email_address" | |
git config --global push.default current | |
git config --global alias.l "log --stat --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %C(blue)(%an %ch)%Creset%n' --abbrev-commit" | |
git config --global alias.last "log -1 HEAD" | |
git config --global alias.a "add" | |
git config --global alias.b "branch -v --sort=committerdate" | |
git config --global alias.c "commit" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) 2016-2021 Ming Qin (覃明) <https://github.com/QinMing> | |
# Open source under MIT LICENSE. | |
export PATH=/usr/local/bin:$PATH | |
export ZSH="$HOME/.oh-my-zsh" | |
DISABLE_MAGIC_FUNCTIONS=true | |
# So that it doesn't add the extra excape character. Without this line, pasting `mingq.in/?param` will become `mingq.in/\?param` | |
ZSH_THEME="agnoster" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
# | |
# Sample Usage: | |
# <command> '.*\.html' | |
import logging | |
import os | |
import re | |
from argparse import ArgumentParser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
syntax on | |
filetype plugin indent on | |
" show existing tab with xx spaces width | |
set tabstop=4 | |
" when indenting with '>', use xx spaces width | |
set shiftwidth=4 | |
" On pressing tab, insert xx spaces | |
set expandtab | |
" Enable mouse use in all modes. So that when ssh into here, can use mouse to activate visual mode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Copyright (c) 2016 Ming Qin (覃明) <https://github.com/QinMing> | |
# 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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
backup: | |
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 | |
restore: | |
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 | |
load: | |
docker exec -i mysql1 mysql -uroot $(DATABASE_NAME) < mysqldump |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -it --rm --net=host -v $PWD/static:/data mnuessler/schemaspy -hq -t mysql \ | |
-host YOUR-DB.COM \ | |
-u USER \ | |
-p 'PASSWORD' \ | |
-db DB_NAME \ | |
-o /data/FOLDER_NAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# To run this file itself: | |
# wget https://gist.githubusercontent.com/QinMing/48cfe1e0a5b65d4c62dc2da8b91ab145/raw -O dotfile.sh && chmod +x dotfile.sh | |
shell=bash | |
# Print out message in color | |
success() { | |
echo -e "\033[1;32m$1\033[0m" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() { |
NewerOlder