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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# $ 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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
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.
- Redirect to this link to request GitHub access:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |