Skip to content

Instantly share code, notes, and snippets.

View jianshen92's full-sized avatar
🐢
One step at a time

Jian Shen jianshen92

🐢
One step at a time
View GitHub Profile
@jianshen92
jianshen92 / gist:e9092e19c89ce71a11f40368dc18c020
Created December 30, 2020 08:32
Print out git lineage nicely
git log --all --graph --decorate --oneline
@jianshen92
jianshen92 / gist:f9b278d94a7c82a1d3d6ee3b2c401a58
Created April 14, 2021 04:27
Unset git hooks for pre commit not running
git config --unset core.hookspath
@jianshen92
jianshen92 / gist:d0cd0df3248689da1f5318defc62e5dd
Created April 14, 2021 04:28
Remove all *pyc files and __pycache__ folder
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
@jianshen92
jianshen92 / gist:3dc65159b03796db6ef67a20e61cecd1
Created June 25, 2021 03:00
Find all running services on certain port, 8000 in this case
lsof -i -P -n | grep 8000
@jianshen92
jianshen92 / deque.ipynb
Last active June 30, 2021 11:04
Prepending with List vs Deque
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jianshen92
jianshen92 / keybase.md
Created October 18, 2021 12:45
keybase.md

Keybase proof

I hereby claim:

  • I am jianshen92 on github.
  • I am jianshen92 (https://keybase.io/jianshen92) on keybase.
  • I have a public key ASDkjUMPb-RJE9ox1OqohA5HOSI91BKkzqQ2GTV5X__5Swo

To claim this, I am signing this object:

@jianshen92
jianshen92 / gist:f1a482463aef5a4ac84bd3f03d478856
Created October 29, 2021 10:58
Delete remote branch via CLI
git push origin --delete <branch-name>
@jianshen92
jianshen92 / download_s3.py
Created October 29, 2021 11:01
Download s3 directory into temporary directory locally
import boto3
def download_s3_directory(s3_resource, bucket: str, key: str, local_dir: str):
""" Download the S3 directory to a local disk """
bucket_obj = s3_resource.Bucket(bucket)
if key != "" and not key.endswith("/"):
key = key + "/"
for obj in bucket_obj.objects.filter(Prefix=key):
local_file_path = local_dir + "/" + obj.key[len(key) :]
local_file_dir = os.path.dirname(local_file_path)