Skip to content

Instantly share code, notes, and snippets.

# Customizing your Responder to always redirect to the collection path (index action).
class AppResponder < ActionController::Responder
protected
# Overwrite navigation_behavior to redirect to the collection_location.
def navigation_behavior(error)
if get?
raise error
elsif has_errors? && default_action
render :action => default_action

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access:
# this code snippet was inspired by
# http://www.igvita.com/2010/04/15/non-blocking-activerecord-rails/
require 'fiber' # needed to use Fiber.current
require 'rubygems'
require 'mysqlplus'
require 'eventmachine'
require 'em-mysqlplus'
def query(sql)
# see http://github.com/intridea/oauth2
require 'rubygems'
require 'sinatra'
require 'oauth2'
require 'json'
class ConnectionLogger < Faraday::Middleware
def call(env)
env[:response].on_complete do |env|
puts "RESULT: #{env[:status]}\n#{env[:body]}"
#!/usr/bin/env ruby
require 'rubygems'
require 'aws/s3'
S3_CREDENTIALS = File.expand_path(File.join('~', '.s3', 'auth.yml'))
APP = 'darkblog'
BUCKET = 's3.blog.darkhax.com'
def bundle
Old way:
$ git checkout -b preandpost_fork_hooks scotttam/preandpost_fork_hooks
Branch preandpost_fork_hooks set up to track remote branch preandpost_fork_hooks from scotttam.
Switched to a new branch 'preandpost_fork_hooks'
New way:
$ git checkout preandpost_fork_hooks
Branch preandpost_fork_hooks set up to track remote branch preandpost_fork_hooks from scotttam.
@ncr
ncr / .bashrc
Created July 8, 2009 22:48 — forked from defunkt/.bashrc
# $ tweet Hi mom!
#
# Put this in ~/.bashrc or wherever.
# If it doesn't work, make sure your ~/.netrc is right
#
# (Thanks to @anildigital and @grundprinzip for curl-fu)
function tweet {
curl -n -d status="$*" https://twitter.com/statuses/update.xml --insecure &> /dev/null
echo "tweet'd"

Note to Self

Be Confident

Tests build confidence. Write 'em. They'll save your ass, and they'll let you take a chainsaw to your code without being afraid of unintended consequences.

Be Lazy