Skip to content

Instantly share code, notes, and snippets.

View seeflanigan's full-sized avatar

Cory Flanigan seeflanigan

View GitHub Profile
@seeflanigan
seeflanigan / appusers.rb
Created May 3, 2012 04:56 — forked from kartikrustagi/appusers.rb
Auth using Sinatra-Warden
require 'openssl'
class AppUser < Sequel::Model(:AppUsers)
AppUser.unrestrict_primary_key
def self.authenticate(username, password)
#TODO: Store salt in config
puts "In Auth"
user = self.first(:username => username)
@seeflanigan
seeflanigan / description
Created December 6, 2011 19:56
Element no longer connected to DOM
Found by Dima Kovalenko
Selenium specs which call "wait for element to be visible" fail on an "Element no longer connected to DOM" error.
The problem occurs when the div appears briefly, then goes away. If the loop exits after the div is already off the screen, the call to "wait for element to be visible times out, and causes the spec to fail.
This issue can be elusive, only failing intermittently because sometimes the loop exits quickly enough to avoid producing the error. The fact that the div is displayed then hidden was the key to identifying and solving this bug in our test.
@seeflanigan
seeflanigan / binlog-filter.rb
Created November 30, 2011 19:59
Filter binlogs, selectively replicate queries
#!/usr/bin/env ruby
require "rubygems"
require "bundler/setup"
require "sequel"
# DB Config
options = {
:database => "development",
:host => "localhost",
@seeflanigan
seeflanigan / pairmux.sh
Created August 26, 2011 16:22
Aliases for pairing
alias pairtunl='ssh -fNR 4242:localhost:22 $1'
alias pairinit='tmux -S /tmp/pairing new-session -d -s pairing'
alias pairjoin='tmux -S /tmp/pairing attach -t pairing'
# alias pairmuch='pairtunl $1 && pairinit && pairjoin'
@seeflanigan
seeflanigan / names.rb
Created August 24, 2011 17:33
Select Names with Matching Last Name and First Initial from a list
require 'csv'
CSV_FILENAME = "some_names.csv"
names_hash = {}
matches_array = []
CSV.foreach(CSV_FILENAME) do |row|
last_name,first_name = row[0],row[1]
@seeflanigan
seeflanigan / rvm.zsh
Created July 23, 2011 07:48
Functions for RVM
# Functions for RVM
rvmrubyversion () {rvm info|grep -C1 "interpreter"|grep "version:"|awk {'print $2'}}
rvmrc () {current_path=$(pwd | awk '{split($0,array,"/");print array[length(array)]}')
echo "rvm use default@$current_path --create" >> .rvmrc; source .rvmrc}
@seeflanigan
seeflanigan / error.log
Created July 15, 2011 17:35
Error installing npm
npm ERR! Error: Failed to mkdir /usr/local: File exists
npm ERR! at STATCB (/private/var/folders/1i/1iBDWfZ0FcS+Cwr4gRZ7GU+++TM/-Tmp-/npm.73154/package/lib/utils/mkdir-p.js:117:19)
npm ERR! at cb (/private/var/folders/1i/1iBDWfZ0FcS+Cwr4gRZ7GU+++TM/-Tmp-/npm.73154/package/lib/utils/graceful-fs.js:31:9)
@seeflanigan
seeflanigan / communication_books
Created June 18, 2011 15:38
Books About Communication
A list of books that people have recommended to me about communication:
http://t.co/Lsr5t4J - How to Win Friends & Influence People (Dale Carnegie)
http://t.co/7CHxjpc - Getting Naked (Patrick Lencioni)
http://t.co/vrmhKAh - Pragmatic Thinking and Learning (Andrew Hunt)
http://t.co/MmJOPW6 - Life's A Pitch (Stephen Bayley)
http://t.co/SW5nLRd - Crucial Conversations (Kerry Patterson)
autocmd User Rails Rnavcommand config config -suffix.rb -default=environment
autocmd User Rails Rnavcommand fabricator spec/fabricators -glob=**/* -suffix=_fabricator.rb
autocmd User Rails Rnavcommand feature features -suffix=.feature -default=cucumber
autocmd User Rails Rnavcommand sass app/stylesheets -glob=**/* -suffix=.sass -default=main
autocmd User Rails Rnavcommand scss app/stylesheets -glob=**/* -suffix=.scss -default=style
autocmd User Rails Rnavcommand steps features/step_definitions -suffix=_steps.rb -default=web
let g:surround_{char2nr("l")} = "link_to \1text: \1, \2path:\2\r"
let g:surround_{char2nr("#")} = "#{\r}"
@seeflanigan
seeflanigan / benchmark_results.txt
Created June 1, 2011 20:32
Prawn vs PDFKit Benchmark
-> % ./prawn_vs_pdfkit.rb
user system total real
PDFKit: 1.760000 1.850000 231.550000 (286.579597)
Prawn: 99.140000 0.890000 100.030000 (102.124293)
2.4 GHz Intel Core 2 Duo
4 GB 1067 MHz DDR3