Skip to content

Instantly share code, notes, and snippets.

View john-theo's full-sized avatar
🏠
Working from home

John Dope john-theo

🏠
Working from home
View GitHub Profile
@john-theo
john-theo / earliest_commits.sh
Created December 21, 2022 05:14
Find the earliest commit of every branch in a repo.
git fetch
brs=$(git branch -v -a | awk '{print $1}' | sed 1,2d)
IFS=$'\n'; brs=($brs); unset IFS
for i in "${brs[@]}"
do
msg=$(git log $i --pretty=format:"%h%x09%aD%x09%s" | tail -1)
echo "$msg\t\t$i"
done

SVG icons can be downloaded anywhere. When using these SVGs as icons in production, they may not be able to align on the same horizontal line, they can't change color dynamically, along with other problems.

This script does the following things:

  1. Remove undesired attributes in path and svg tags
  2. Remove group content outside, and get rid of g tags
  3. Add id=main to svg tag to support use of an external source
  4. Replace fill and stroke color to currentColor, so the color of the SVG icon can be changed by css
  5. (Optional) Adjust viewBox so it fits the content (0 margin)
# Specify hostname (-h <hostname>) and disable ulimit (--privileged)
docker run --rm -it -h <hostname> -p 8822:22 --privileged --name <container name> ubuntu
# Open port 8822 on the host
apt-get update
# Follow directions here to install docker
# https://docs.docker.com/engine/install/ubuntu/
git remote rm origin
git remote add origin git@github.com:John-Theo/repo.git
git config master.remote origin
git config master.merge refs/heads/master
# https://stackoverflow.com/questions/44031150/why-does-git-pull-hang/50253087#50253087
git fsck && git gc --prune=now
@john-theo
john-theo / bar_download.py
Last active June 6, 2020 00:18
Show progress bar when downloading a huge file.
from tqdm import tqdm
import requests
from io import BytesIO
def bar_download(url, block_size=4096, session=None, tqdm_kwargs=None, requests_kwargs=None):
tqdm_kwargs, requests_kwargs = tqdm_kwargs or {}, requests_kwargs or {}
# use a predefined session if possible to get access to session-wise cookies & headers
_requests = session if session else requests