Skip to content

Instantly share code, notes, and snippets.

View dannyfallon's full-sized avatar

Danny Fallon dannyfallon

  • Intercom
  • Dublin, Ireland
View GitHub Profile
@dannyfallon
dannyfallon / gist:2471083
Created April 23, 2012 14:03
Remote branch fetch & track
Blatantly stolen from stack overflow, copy the below command into a terminal and run it
remote=origin ; for brname in `git branch -r | grep $remote | grep -v master | grep -v HEAD | awk '{gsub(/[^\/]+\//,"",$1); print $1}'`; do git branch --set-upstream $brname $remote/$brname ; done
@dannyfallon
dannyfallon / gist:2567041
Created May 1, 2012 10:20
Git branches in your terminal - copy to ~/.bashrc
#
# Git branches in terminal path
#
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo " ("${ref#refs/heads/}")"
}
YELLOW="\[\033[0;33m\]"
PS1="[${debian_chroot:+($debian_chroot)}\u@\h \w$YELLOW\$(parse_git_branch)\[\e[0m\]]\$ "
@dannyfallon
dannyfallon / gist:46404cb34985ad09da77
Last active August 29, 2015 14:05
Replaces the AWS CLI with a piped command that prettifies and colorises the output
#
# Pretty, colourful AWS
#
function paws() {
/usr/local/bin/aws "$@" | python -m json.tool | pygmentize -l javascript
}
@dannyfallon
dannyfallon / gist:79dd7b40ebcb1b574844
Last active August 29, 2015 14:09
PUBLIC GIST: AWS CLI Magic Fu
# List all access keys for every IAM user
aws iam list-users | jq '.Users[].UserName' | sed "s/\"//g" | xargs -I {} aws iam list-access-keys --user={}
# Enable Metrics Collection on ASGs that don't have it
aws autoscaling describe-auto-scaling-groups | jq '.AutoScalingGroups[] | select(.EnabledMetrics==[]).AutoScalingGroupName' | xargs -I {} aws autoscaling enable-metrics-collection --auto-scaling-group-name {} --granularity "1Minute"
@dannyfallon
dannyfallon / rubymine_jdkchange.sh
Last active August 29, 2015 14:13
Enables OS X RubyMine to use the current version of the JDK instead of forcing 1.6 (specifically for Yosemite)
#!/usr/bin/env bash
set -e
# Get the java version, quit if it's not found
JAVA_VERSION=`java -version 2>&1 | head -n 1 | cut -d\" -f 2 | cut -c1-3`
if [ -z "$JAVA_VERSION" ]; then
echo "Unable to determine Java version, exiting"
exit
fi
@dannyfallon
dannyfallon / its_its_its_its_BIGINT_time.sql
Created September 1, 2017 13:34
Determining what tables with an auto incrementing primary key are coming close to the max of the int datatype (80%)
SELECT t.TABLE_NAME, `AUTO_INCREMENT`
FROM information_schema.TABLES AS t
JOIN information_schema.COLUMNS AS c ON (
c.COLUMN_NAME = 'id' AND
c.TABLE_SCHEMA = t.TABLE_SCHEMA AND
c.TABLE_NAME = t.TABLE_NAME AND
c.`DATA_TYPE` = 'int'
)
WHERE AUTO_INCREMENT > 1717986918;