Skip to content

Instantly share code, notes, and snippets.

View rpdelaney's full-sized avatar
🏠
Working nomad

Ryan Delaney rpdelaney

🏠
Working nomad
View GitHub Profile
@rpdelaney
rpdelaney / crontab.header
Created August 17, 2016 19:17
Useful crontab header
# +--------- Minute (0-59) | Output Dumper: >/dev/null 2>&1
# | +------- Hour (0-23) | Multiple Values Use Commas: 3,12,47
# | | +----- Day Of Month (1-31) | Do every X intervals: */X -> Example: */15 * * * * Is every 15 minutes
# | | | +--- Month (1 -12) | Aliases: @reboot -> Run once at startup; @hourly -> 0 * * * *;
# | | | | +- Day Of Week (0-6) (Sunday = 0) | @daily -> 0 0 * * *; @weekly -> 0 0 * * 0; @monthly ->0 0 1 * *;
# | | | | | | @yearly -> 0 0 1 1 *;
# * * * * * COMMAND
@rpdelaney
rpdelaney / keybase.md
Created August 2, 2017 20:53
keybase.md

Keybase proof

I hereby claim:

  • I am rpdelaney on github.
  • I am rpdelaney (https://keybase.io/rpdelaney) on keybase.
  • I have a public key whose fingerprint is 311C 10F2 26E0 14E3 8BA4 3B06 B634 36F1 C9E7 771B

To claim this, I am signing this object:

@rpdelaney
rpdelaney / include.sh
Created December 20, 2017 21:18 — forked from aguy/include.sh
shell script trap functions
# Debugging tools. REMOVE THIS LATER. {{{1
set -o errexit # exit on errors
set -o nounset # exit on use of uninitialized variable
set -o errtrace # inherits trap on ERR in function and subshell
trap 'traperror $? $LINENO $BASH_LINENO "$BASH_COMMAND" $(printf "::%s" ${FUNCNAME[@]:-})' ERR
trap 'trapexit $? $LINENO' EXIT
trapexit() {
log "EXIT on line $2 (exit status $1)" "INFO "
@rpdelaney
rpdelaney / git.commit.template
Last active April 25, 2019 20:23
git commit template
# (If applied, this commit will...)
# |<---- Using a Maximum Of 50 Characters ---->|
# Explain what this changes and why (avoid "how")
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# Provide links or keys to any relevant tickets, articles or other resources
# Example: - Fixes #32
@rpdelaney
rpdelaney / PYTHON_EXCEPTION_TRACEBACKS.md
Last active April 3, 2024 08:12
Transforming python exceptions while preserving the traceback

Sometimes a simple exception isn't enough information to explain what went wrong:

>>> def do_foo():
>>>     pass
>>>
>>>
>>> def do_bar():
>>>     pass
>>>
@rpdelaney
rpdelaney / mapping.py
Created December 19, 2018 22:18
python3 custom map object
#!/usr/bin/env python3
#
# from: https://stackoverflow.com/questions/4014621/a-python-class-that-acts-like-dict
class Mapping(dict):
def __setitem__(self, key, item):
self.__dict__[key] = item
def __getitem__(self, key):
@rpdelaney
rpdelaney / GIT_PURGE_SECRETS.md
Last active March 1, 2019 01:19
Purge secrets from the local git repository

So you committed something you shouldn't have, like an oath token or a password. If you have not pushed yet then not all is lost.

How to purge bad commits from the local repo:

  1. Rebase out the offending commit(s)
  2. git reflog --expire-unreachable=now && git gc --prune=now

Caveats:

  • If you have pushed the commits, the cat is out of the bag. You must revoke the access credentials immediately.
  • Note that this will irrevocably remove any refs that are no longer in the tree, not only those that you just rebased out.
@rpdelaney
rpdelaney / GIT_BLAME_DELETED.md
Last active March 3, 2023 14:52
git blame for deleted lines

git blame can tell you who last changed a file line by line. But how can you find out who deleted a line?

You can pseudo-git-blame a deleted line using either of the following, depending on whether you want to do a simple string matching search or use a regex:

  1. git log -S [string] ./file
  2. git log -G [regex] ./file
@rpdelaney
rpdelaney / BACKUP.md
Last active March 18, 2019 23:58
rsync backup command
$ explain rsync --recursive --compress --inplace --acls --times --executability --owner --group --xattrs --links --safe-links --devices --specials --human-readable --human-readable --verbose --progress


rsync(1) --recursive --compress --inplace --acls --times --executability 
--owner --group --xattrs --links --safe-links --devices --specials 
--human-readable --human-readable --verbose --progress

a fast, versatile, remote (and local) file-copying tool
@rpdelaney
rpdelaney / xl_to_iso.py
Created July 30, 2019 01:53
Convert Excel date-time to ISO formatted string in python
#!/usr/bin/env python3
#
import pytz
from xlrd import xldate
TZ_PACIFIC = pytz.timezone("US/Pacific")
def xl_to_iso(xl_date: float, datemode: int = 0) -> str: