Skip to content

Instantly share code, notes, and snippets.

View suewonjp's full-sized avatar

Suewon Bahng suewonjp

View GitHub Profile
@suewonjp
suewonjp / .gitconfig
Created October 1, 2019 13:39
gitconfig
[user]
name = your_name
email = your@email
[alias]
unstage = reset HEAD --
last = log -1 --stat
co = checkout
b = branch
l = log -10 --pretty=format:\"%h - %ar : %s\"
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %Cblue<%an>%Creset' --abbrev-commit --date=relative --all
@suewonjp
suewonjp / source-code-line-counter.sh
Last active March 10, 2018 00:31
Count the number of source code lines using lf.sh
### Count lines in every Python source file in the current project
count=0
for f in `lf . .py`; do count=$(( $count + `cat $f | wc -l` )); done
echo $count
@suewonjp
suewonjp / killProcess.bash
Last active March 10, 2018 00:26
Bash function that lets you interactively kill arbitrary process with pattern matching (See the comment below for an example usage)
killProcess() {
if [ $# -lt 1 ]; then
echo "Usage: ${FUNCNAME[0]} [pattern for process name]"
return
fi
local procs=() selected=
case "$( uname )" in
Darwin*|CYGWIN*) mapfile -t procs < <( pgrep -fil "${1}" ) ;;
*) mapfile -t procs < <( pgrep -fl "${1}" ) ;;
@suewonjp
suewonjp / selectFromArray.bash
Last active January 10, 2018 09:29
General Bash function that creates selection interface from arbitrary array (See comment below for usage example)
selectFromArray() {
if [ "$1" ]; then
local IFS=$'\n' selected= idx=$2 tmp=()
eval "local arr=( \${$1[*]} )"
if [ ${#arr[@]} -eq 1 ]; then
selected="${arr[0]}"
elif [ ${#arr[@]} -gt 1 ]; then
select a in "QUIT!" "${arr[@]}"; do
[ "${a}" = "QUIT!" ] && break
@suewonjp
suewonjp / mergesort.py
Created December 25, 2017 09:17
Merge sort implementation in Python
def merge(lblock, rblock):
li, ri, llen, rlen = 0, 0, len(lblock), len(rblock)
merged = []
for _ in range(llen + rlen):
if li < llen and (ri >= rlen or lblock[li] < rblock[ri]):
merged.append(lblock[li])
li += 1
else:
merged.append(rblock[ri])
ri += 1
@suewonjp
suewonjp / quicksort.py
Created December 25, 2017 09:15
Quicksort implementation in Python (one line)
f = lambda x: (f([y for y in x if x[0] > y]) + [y for y in x if x[0] == y] + f([y for y in x if x[0] < y]) if x else [])
@suewonjp
suewonjp / BlockComment.vim
Created December 25, 2017 06:03
Simple Vim function to block comment multiple lines of code
" Block comment multiple lines of code.
" Intended for Visual mode only
function! BlockComment(tn, bn)
let l:ltop = line("'<")
let l:lbottom = line("'>")
let l:indc = indent(l:ltop)
let l:ind = ''
let l:i = 0
while l:i < l:indc
let l:ind .= ' '
@suewonjp
suewonjp / .tmux.conf
Last active December 17, 2022 19:35
My .tmux.conf ( usable across multi-platforms including OS X | Linux | Cygwin )
set-option -g default-terminal "xterm-256color"
set-window-option -g xterm-keys on
run-shell "tmux setenv -g TMUX_VERSION $(tmux -V | cut -c 6-)"
setw -g mode-keys vi
unbind C-b
# remap prefix to Control + Space
@suewonjp
suewonjp / My-bash-aliases.sh
Last active January 23, 2019 07:35
My Bash aliases
if [ "Darwin" == $(uname) ]; then
alias showFiles='defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app'
alias hideFiles='defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app'
alias hibernateMode='sudo pmset -a hibernatemode 25'
alias sleepMode='sudo pmset -a hibernatemode 3'
alias f='open -a Finder '
fi
## Save keystrokes for directory navigation
alias ~='cd ~'
@suewonjp
suewonjp / Edit and review github wiki on your local machine.md
Last active February 11, 2023 22:35
Edit and review github wiki on your local machine
First, clone your github wiki to your local machine
  1. Checkout your repository wiki via git.
     - You can find the URL at the lower-right of your wiki page (look for the label "Clone this wiki locally")
  2. Now that you have pulled down a local copy of your github repo wiki, create a new file in the repo called _Sidebar.md  - Note that other names might not work.
  3. Within the newly created _Sidebar.md file, you can add appropriate [[link]] markdown syntax.
  4. Add your new file to the local repository, and push via git push origin master.

With the same procedure, you can add a header(_Header.md) and footer(_Footer.md) file.