Skip to content

Instantly share code, notes, and snippets.

View davidfrey's full-sized avatar

David Frey davidfrey

  • Faces of Dave
  • Portland, OR
View GitHub Profile
@davidfrey
davidfrey / beanstalk_ssh.sh
Created August 4, 2017 18:10
AWS Beanstalk SSH Workaround
#!/bin/bash
PROFILE=aws-profile
environment=$1
if [ $# -ne 1 ]; then
echo script needs environment as first arg
echo usage: $0 environment
exit 1
fi
echo using environment $environment
first_instance=$(eb list -v | grep Environments: -A 100|grep -v Environments:|grep $environment|cut -d\' -f2)
@davidfrey
davidfrey / cfn-keen.yml
Created February 21, 2017 15:27
Cloud Formation: Keen Stream to S3
AWSTemplateFormatVersion: "2010-09-09"
Description: Keen Policy Test
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Stack Variables
Parameters:
- Environment
- Label:
@davidfrey
davidfrey / cfn-s3-queue-notification.yml
Created February 21, 2017 15:25
Cloud Formation: S3 Queue Notification
AWSTemplateFormatVersion: "2010-09-09"
Description: S3 Queue Notifications Test
Metadata:
AWS::CloudFormation::Interface:
ParameterGroups:
- Label:
default: Stack Variables
Parameters:
- Environment
- Label:
@davidfrey
davidfrey / .gitconfig
Last active August 29, 2015 14:01
git last-tag
[alias]
last-tag = !sh -c 'git describe --tags `git rev-list --tags --max-count=1`'
stable = !sh -c 'git describe --tags `git rev-list --tags=releases/ --max-count=1`'
@davidfrey
davidfrey / .zshrc
Last active March 3, 2017 15:59
Clean up your local git branches
# Faces of Dave Customization
export CLICOLOR=1
export LSCOLORS=ExFxCxDxCxegedabagacGx
alias ls="gls -lh --color -h --group-directories-first"
alias externalip="dig +short myip.opendns.com @resolver1.opendns.com"
alias please=sudo
PROMPT="$emoji[rocket] $PROMPT"
@davidfrey
davidfrey / .zshenv
Created February 14, 2014 18:12
Sanity with RVM, Vim, and Zsh
# Make shelling out in Vim pick up RVM settings
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
@davidfrey
davidfrey / file.rb
Created October 22, 2013 20:13
Compare memory performance between File.open block and EventMachine streaming HTTP.
require 'yajl'
def get_memory_usage
`ps -o rss= -p #{Process.pid}`.to_i / 1024
end
before = get_memory_usage
parsed_lines = []
File.open("public/sample.json", 'r') do |f|
f.each_line do |line|
@davidfrey
davidfrey / .bash_profile
Created September 24, 2013 16:29
My personal favorite bash setup for a new computer.
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
if [ -f ~/.git-prompt.sh ]; then
source ~/.git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=true
fi
@davidfrey
davidfrey / local-processlist
Created July 1, 2013 17:59
Concurrent database connections using threads and mysqlplus. The following scenario will complete in roughly 3 seconds when db host is local, takes considerably longer on remote connections due to what appears to be blacking after 6 or 7 concurrent connections.
Id User Host db Command Time State Info
1 root localhost:58150 NULL Query 1131598 NULL show processlist
2 root localhost:58151 NULL Sleep 7 NULL
1452 root localhost NULL Query 1 User sleep select sleep(3)
1453 root localhost NULL Query 1 User sleep select sleep(3)
1454 root localhost NULL Query 1 User sleep select sleep(3)
1455 root localhost NULL Query 1 User sleep select sleep(3)
1456 root localhost NULL Query 1 User sleep select sleep(3)
1457 root localhost NULL Query 1 User sleep select sleep(3)
1458 root localhost NULL Query 1 User sleep select sleep(3)
@davidfrey
davidfrey / gist:5613946
Created May 20, 2013 17:52
Monkey patching an auto-loaded module.
# /lib/fix_me.rb
module FixMe
def self.status
'broken'
end
end
# /config/environments/development.rb
module FixMe
def self.status