Skip to content

Instantly share code, notes, and snippets.

View blackwhale's full-sized avatar

Ching-Yu Wu blackwhale

  • Taiwan
View GitHub Profile
from functools import wraps
import time
def retry(num_attempts=3, exception_class=(Exception, ), sleeptime=1):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
for i in range(1, num_attempts+1):
try:
return func(*args, **kwargs)
@blackwhale
blackwhale / commits_diff.sh
Created September 2, 2019 01:53
master branch's diff between last two commits
#!/bin/bash
last_two_commits=$(git log -n 2 --first-parent master --pretty=format:"%H")
files=$(git diff --name-only ${last_two_commits})
folders=()
for file in ${files[@]}; do
# echo $file
folder=$(echo $file | cut -d'/' -f1)
folders+=($folder)