Skip to content

Instantly share code, notes, and snippets.

View mahaffey's full-sized avatar
🕶️
-_-

Ryan Mahaffey mahaffey

🕶️
-_-
View GitHub Profile
@mahaffey
mahaffey / AuthyToOtherAuthenticator.md
Created June 5, 2024 14:16 — forked from gboudreau/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy
@mahaffey
mahaffey / install-zsh-windows-git-bash.md
Created May 12, 2022 09:34 — forked from fworks/install-zsh-windows-git-bash.md
Zsh / Oh-my-zsh on Windows Git Bash
@mahaffey
mahaffey / delete-stale-branches.sh
Created August 1, 2019 22:23
Delete Stale git branches at remote, output stale and deleted branches to txt files
#!/bin/bash
IFS=$'\n'
COUNT=0
REMOTE="origin"
MAX_CONCURRENCY=20
# cat out to file that includes all remote branches older than 2 months
for branch in `git branch -r | grep -v 'HEAD' | grep "${REMOTE}/"`;do echo -e `git show --format="%cn %ci %cr" $branch | head -n 1` \\t$branch; done | egrep -v '(days|weeks|hours) ago' | sort -r > branches.txt
# delete branches with concurrency
@mahaffey
mahaffey / tail-call-factorial.js
Last active July 14, 2017 19:49
tail-call-factorial-js
"use strict"
function tailFactorial(n, acc=1) {
if (n <= 1) {
return acc
}
// Else is not needed due to the return
return tailFactorial(n-1, acc*n)
}
@mahaffey
mahaffey / factorial-interpreter.js
Created July 13, 2017 04:20
what-the-interpreter-sees-non-tail-call-factorial-js
factorial(4)
4 * factorial(3)
4 * (3 * factorial(2))
4 * (3 * (2 * factorial(1)))
4 * (3 * (2 * (1)))
24
@mahaffey
mahaffey / js-factorial.js
Created July 13, 2017 04:14
Non-Tail-Call-Optimized-Factorial-js
function factorial (n) {
if (n === 0) {
return 1
} else {
return (n * factorial(n-1))
}
}
# python server
# $1 = port
# Example: pss 8080
pss() {
# Allow myself to change the port ($1)
python -m SimpleHTTPServer "$1"
}
# Say and do many things
dothesethings() {
# Aliases
# =====================
# LS
alias l='ls -lah'
# Git
alias gcl="git clone"
alias gst="git status"
alias gl="git pull"
alias gp="git push"
@mahaffey
mahaffey / recursion_simple_counter.rb
Last active May 12, 2017 00:05
Recursion Example
class BlastOff
def t_minus(n)
puts "T-minus: #{n} seconds"
countdown(n)
puts "Blast OFF!!!"
end
def countdown(n)
return if n.zero? # base case
def factorial(n)
n == 0 ? n = 1 : n * factorial(n-1)
end
factorial(3)
#=>6
# This is happening behind the scenes:
#
# n=3, 3 * factorial(2)