Skip to content

Instantly share code, notes, and snippets.

View gaffneyc's full-sized avatar

Chris Gaffney gaffneyc

  • Dead Man's Snitch
  • Holland, MI
View GitHub Profile

Keybase proof

I hereby claim:

  • I am gaffneyc on github.
  • I am gaffneyc (https://keybase.io/gaffneyc) on keybase.
  • I have a public key whose fingerprint is 16D8 FE25 1160 5118 22EC 3B48 0F56 ABBB D997 1DF8

To claim this, I am signing this object:

@gaffneyc
gaffneyc / gist:bd15062f4cfe079c0522
Created October 1, 2014 14:20
Spammer template fail
{
{I have|I’ve} been {surfing|browsing} online
more than {three|3|2|4} hours today, yet I never
found any interesting article like yours. {It’s|It is} pretty worth enough for
me. {In my opinion|Personally|In my view}, if all {webmasters|site owners|website owners|web
owners} and bloggers made good content as you did, the {internet|net|web} will be {much more|a lot more} useful than ever
before.|
I {couldn’t|could not} {resist|refrain from} commenting.
{Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I’ll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch} your {rss|rss feed}
@gaffneyc
gaffneyc / running.sql
Last active August 29, 2015 14:16
Issues with PostgreSQL
-- We're having some really weird issues in a production application running on
-- Heroku PostgreSQL 9.3.5. We are seeing a number of long running queries
-- getting stuck inside a transaction (below). We are using PgHero to see and
-- kill the long running queries[1]. Trying to understand what could be
-- happening but we're at a loss.
-- Usually we'll see it idle out at the `UPDATE "sprockets"` line below which
-- causes further updates to that row to block. This bit of code gets run about
-- 1000x per minute for multiple sprockets.
BEGIN
require 'benchmark'
N = 100_000
a = []
100.times { a << (rand(10) > 5 ? true : false) }
Benchmark.bm(35) { |x|
x.report("String#to_i(base)") {
# Based of Jay Fields' implementation (http://blog.jayfields.com/2007/11/ruby-timeis.html)
#
# Usage:
# Time.freeze do |time|
# Time.now.should.equal(time)
# end
class Time
def self.metaclass
class << self; self; end
end
From 7f6cc03fccee270ecb1848880e54b240371c7311 Mon Sep 17 00:00:00 2001
From: Chris Gaffney
Date: Fri, 6 Feb 2009 11:49:47 -0500
Subject: [PATCH] Subcontexts inherit outer context Test::Unit::TestCase by default.
---
lib/test/spec.rb | 4 ++--
test/spec_nestedcontexts.rb | 19 +++++++++++++++++++
2 files changed, 21 insertions(+), 2 deletions(-)
@gaffneyc
gaffneyc / gateway.rb
Created March 3, 2009 02:26
Capistrano recipe for setting gateway from the command line
# Automatically set gateway if it is specified on the command line
if ARGV.detect { |g| g =~ /GATEWAY=(.*)/ }
set :gateway, $1
end
source ~/.vim/common-gvimrc.vim
" 256 color colorscheme
:colorscheme vividchalk
" Maximize both dimensions when going fullscreen
:set fuopt=maxhorz,maxvert
":set transparency=8
command -nargs=0 Zoom :macaction performZoom:
# script/server with Rails 3 support
ss() {
if [ -f ./script/rails ]; then
./script/rails server $@
else
./script/server $@
fi
}
# script/console with Rails 3 support
require 'selenium-webdriver'
class Capybara::Driver::Selenium < Capybara::Driver::Base
def self.driver
unless @driver
@driver = Selenium::WebDriver.for :firefox, :profile => 'webdriver'
at_exit do
@driver.quit
end
end
@driver