Skip to content

Instantly share code, notes, and snippets.

View matschundbrei's full-sized avatar

Jan 'Maub' Kapellen matschundbrei

View GitHub Profile
@matschundbrei
matschundbrei / human_readable_to_bytes.py
Last active January 2, 2018 13:25 — forked from beugley/human_readable_to_bytes.py
Python function to convert a human-readable byte string (e.g. 2G, 10GB, 30MB, 20KB) to a number of bytes
# stolen from https://stackoverflow.com/questions/354038/how-do-i-check-if-a-string-is-a-number-float
def is_number(s):
"""
tries to convert to float and returns true if it works
"""
try:
float(s)
return True
except ValueError:
return False
@matschundbrei
matschundbrei / git-commit-change-author-email.md
Created September 3, 2024 11:19 — forked from mikaello/git-commit-change-author-email.md
Change Git commit author / email in existing commits

Docs: https://github.com/newren/git-filter-repo/blob/main/Documentation/converting-from-filter-branch.md#changing-authorcommittertagger-information and https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html#_filtering_of_names_amp_emails_see_also_name_callback_and_email_callback

git filter-repo \
  --email-callback ' return email if email != b"OLD_EMAIL" else b"NEW_EMAIL" ' \
  --name-callback 'return name.replace(b"OLD_AUTHOR", b"NEW_AUTHOR")' \
  --force \
  --refs HEAD~<NUMBER_OF_COMMITS>..<BRANCH_NAME> # This line is optional, remove to do the change in all commits (will rewrite complete history)