Skip to content

Instantly share code, notes, and snippets.

View davidfrey's full-sized avatar

David Frey davidfrey

View GitHub Profile
@davidfrey
davidfrey / doorkeeper-provider.log
Created February 27, 2012 23:19
The redirect uri included is not valid.
Started GET "/oauth/authorize?response_type=code&client_id=197ed256c231df835220264639dc4122a1f08a5806ac49d8558bca5a4559908f&redirect_uri=http%3A%2F%2Fdoorkeeper-client.dev%2Fusers%2Fauth%2Fdoorkeeper%2Fcallback" for 127.0.0.1 at 2012-02-27 15:18:29 -0800
Processing by Doorkeeper::AuthorizationsController#new as HTML
Parameters: {"response_type"=>"code", "client_id"=>"197ed256c231df835220264639dc4122a1f08a5806ac49d8558bca5a4559908f", "redirect_uri"=>"http://doorkeeper-client.dev/users/auth/doorkeeper/callback"}
Admin Load (0.2ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = 1 LIMIT 1
Doorkeeper::Application Load (0.2ms) SELECT "oauth_applications".* FROM "oauth_applications" WHERE "oauth_applications"."uid" = '197ed256c231df835220264639dc4122a1f08a5806ac49d8558bca5a4559908f' LIMIT 1
Rendered doorkeeper/authorizations/error.html.erb within layouts/application (9.5ms)
Completed 200 OK in 140ms (Views: 70.0ms | ActiveRecord: 0.6ms)
@davidfrey
davidfrey / rescue.rb
Created April 5, 2012 22:45
Twitter::Error::ServiceUnavailable
attempt_count = 0
begin
response = Twitter.user_timeline('davidfrey', {:count=>200, :include_rts => true, :include_entitites => true})
rescue Twitter::Error => error
attempts_count += 1
code = error.class.to_s.gsub('Twitter::Error::','')
case code.downcase
when /notfound|unauthorized/
#void collection
@davidfrey
davidfrey / Ruby Checklist
Last active December 17, 2015 06:59
Brief checklist for setting up a new Mac (Mountain Lion) for ruby development
# Setting up Ruby development environment for a new Mac
Install Xcode from the App store.
Install Command Line Tools from XCode
Install Homebrew
Run `brew doctor` at each stage of an install
You may have to reorder the path priority in /etc/paths
Install Git
`brew install git`
Configure Git
`config --global user.name "Your Name"`
@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
@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 / .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 / 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 / .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 / .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 / .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`'