Skip to content

Instantly share code, notes, and snippets.

@QinMing
QinMing / bash_profile
Last active July 19, 2016 07:19
.bash_profile or .profile
# Ming's .bash_profile
# -- Less is better
# function cd() {
# if [ $# -gt 0 ]; then
# builtin cd "$*" && ls
# else
# builtin cd && ls
# fi
# }
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
@QinMing
QinMing / Ubuntu Remote Desktop.md
Last active December 3, 2015 01:05
Ubuntu Remote Desktop

This can be done. Following are the steps to setup the GUI

Create new user with password login. (But a new user is actually not needed)

sudo useradd -m awsgui
sudo passwd awsgui
sudo usermod -aG admin awsgui
sudo vim /etc/ssh/sshd_config # edit line "PasswordAuthentication" to yes
sudo /etc/init.d/ssh restart
@QinMing
QinMing / git_profile.sh
Last active April 8, 2022 00:35
My git configurations, mainly alias. Just need to run it once.
#!/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"
@QinMing
QinMing / ss
Last active May 27, 2020 17:29
upload/download current folder to the same position at remote host
#!/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`
@QinMing
QinMing / .zshrc
Last active March 10, 2024 22:17
.zshrc (lazy loading shell functions)
# 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
eval "echo \"$(< $STARTUP_TPL_PATH)\"" > $STARTUP_PATH
chmod +x $STARTUP_PATH
du -hs *
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() {
@QinMing
QinMing / dotfile.sh
Last active November 7, 2017 09:26
Dot file
#!/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"