Skip to content

Instantly share code, notes, and snippets.

View scottwb's full-sized avatar

Scott W. Bradley scottwb

View GitHub Profile
@scottwb
scottwb / gist:366373
Created April 14, 2010 21:38
JS to detect if the user has been to certain URLs.
%div#whereyoubeen{:style => "display:none"}
%a{:href => "http://www.google.com/"} Google
%a{:href => "http://www.amazon.com/"} Amazon
%a{:href => "http://www.yahoo.com/"} Yahoo
%a{:href => "http://www.neimanmarcus.com/"} Neiman Marcus
%a{:href => "http://www.strings.com/"} Strings
%a{:href => "http://www.huffingtonpost.com/"} Huffington Post
:javascript
alert("You have been to: " + $$('#whereyoubeen a:visited').map(function(link) {return link.innerHTML;}).join(','));
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
@scottwb
scottwb / git_config_smartsync
Created April 17, 2010 10:36
Git config to use SmartSynchronize as difftool
[diff]
tool = smartsynchronize
[difftool "smartsynchronize"]
cmd = /Application/SmartSynchronize.app/smartsynchronize.sh "$LOCAL" "$REMOTE"
[difftool]
prompt = false

Gist Clients

Want to create a Gist from your editor, the command line, or the Services menu? Here's how.

Editor Support

@scottwb
scottwb / get_git_branch_sha.sh
Created April 22, 2010 08:34
Get the SHA of some git branch.
# Get the SHA of some branch. There must be a better way to do this.
git log -1 --pretty=oneline origin/somebranch | sed -E "s/^([^[:space:]]+).*/\1/"
@scottwb
scottwb / gist:398321
Created May 12, 2010 08:09 — forked from cypher/gist:150248
Git pre-commit hook to verify only valid ruby.
#!/usr/bin/env ruby
#
# A hook script to verify that only syntactically valid ruby code is commited.
# Called by git-commit with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
#
# Put this code into a file called "pre-commit" inside your .git/hooks
# directory, and make sure it is executable ("chmod +x .git/hooks/pre-commit")
#
# This hosts file is brought to you by Dan Pollock and can be found at
# http://someonewhocares.org/hosts/
# You are free to copy and distribute this file, as long the original
# URL is included. See below for acknowledgements.
# Please forward any additions, corrections or comments by email to
# hosts@someonewhocares.org
# Last updated: May 11th, 2010 at 13:56
@scottwb
scottwb / gist:414979
Created May 26, 2010 20:10
One-liner to show a github log/diff of the changes in master since the last merge to stable.
#!/bin/sh
open http://github.com/strings/ranger_site/compare/stable...master
@scottwb
scottwb / install_gems
Created June 10, 2010 17:59 — forked from troelskn/install_gems
Some code I found for installing missing gems.
#!/usr/bin/env ruby
def parse_missing_required(input)
matches = input.match(/Missing these required gems:([\s\S]*)You're running:/)
matches[1].strip.split("\n").map do |line|
m = line.match(/^\s*(\S+)\s+(\S+\s+[0-9.]+)/)
p line if m.nil?
{:name => m[1], :version => m[2]}
end
end
@scottwb
scottwb / hudson_nginx.conf
Created July 2, 2010 03:55
Nginx config for Hudson CI behind a reverse proxy with SSL.
# Nginx config for Hudson CI behind a virtual host with SSL.
# Replace hudson.example.com with your domain name.
# Upstream Hudson server, e.g.: on port 3001
upstream hudson {
server localhost:3001
}
# Redirect all HTTP requests to HTTPS.
server {