Skip to content

Instantly share code, notes, and snippets.

View smudge's full-sized avatar

smudge smudge

View GitHub Profile
@smudge
smudge / model-count-history.sh
Last active March 2, 2020 20:23
Count the number of models in a Rails app over time.
APP_DIR=.
DATE=0
echo "Date, Tier 1, Tier 2, Tier 3, Tier 4, Tier 5, Total" > model_counts.csv
for COMMIT in $(git log --first-parent --reverse --format=format:%H -- $APP_DIR); do
NEW_DATE=$(git show -s --format=%cs ${COMMIT})
if [[ "$DATE" == "$NEW_DATE" ]]; then
continue
fi
@smudge
smudge / switch_remote_from_upstream_to_fork.sh
Last active March 30, 2022 14:18
Switch a git repo to track a fork origin, with read-only upstream.
#### Switch a git repo to track a fork origin, with read-only upstream.
# Step 1: Press that "fork" button on github to fork a repo to your account.
# (Don't worry -- if it's a private repo, your fork will still be private
# and should be effectively owned by the original repo's organization.)
# Step 2: Update your local repo
# IMPORTANT: This assumes your local repo is a clone of the ORIGINAL/upstream repo.
## Add a new 'upstream' remote and add a bogus URL for push commands.
@smudge
smudge / delete_remote_git_branches.sh
Last active January 26, 2022 16:08
Delete all remote git branches
#### Delete all remote git branches
# Primary purpose: When you fork a repo and want a clean slate for your fork.
#### WARNING
# This is REALLY UNSAFE. Don't do this on a shared repo!
# Again: DO NOT DO THIS unless you're really, really sure.
git branch -r | grep -e "origin" | grep -v "origin/main" | awk '{sub(/origin\//,"");print}'| sed 's/^[ *]*//' | sed 's/^/git push origin :/' | bash
### BONUS: Delete all remote tags
@smudge
smudge / keybase.md
Last active August 29, 2015 14:06
keybase.md

Keybase proof

I hereby claim:

  • I am smudge on github.
  • I am smudge (https://keybase.io/smudge) on keybase.
  • I have a public key whose fingerprint is 06B3 1390 A506 C319 C8E0 B6D2 272E 1858 A286 E3A8

To claim this, I am signing this object: