Skip to content

Instantly share code, notes, and snippets.

@technoweenie
technoweenie / github_oauth_busy_developer_guide.md
Created May 30, 2010 18:34
GitHub OAuth Busy Developer's Guide

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:
@mnutt
mnutt / Instrument Anything in Rails 3.md
Created September 6, 2010 06:50
How to use Rails 3.0's new notification system to inject custom log events

Instrument Anything in Rails 3

With Rails 3.0 released a few weeks ago I've migrated a few apps and I'm constantly finding useful new improvements. One such improvement is the ability to log anything in the same way that Rails internally logs ActiveRecord and ActionView. By default Rails 3 logs look slightly spiffier than those produced by Rails 2.3: (notice the second line has been cleaned up)

Started GET "/" for 127.0.0.1 at Mon Sep 06 01:07:11 -0400 2010
  Processing by HomeController#index as HTML
  User Load (0.2ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`id` = 3) LIMIT 1

Rendered layouts/_nav.html.erb (363.4ms)

@joeyAghion
joeyAghion / simple_redis_profile.rb
Created October 13, 2010 16:00
By sampling keys from your redis databases, this script tries to identify what types of keys are occupying the most memory.
#!/usr/bin/env ruby
# Evaluates a sample of keys/values from each redis database, computing statistics for each key pattern:
# keys: number of keys matching the given pattern
# size: approximation of the associated memory occupied (based on size/length of value)
# percent: the proportion of this 'size' relative to the sample's total
#
# Copyright Weplay, Inc. 2010. Available for use under the MIT license.
@igrigorik
igrigorik / faraday-em-http.rb
Created January 30, 2011 01:12
using Faraday with EM-Synchrony & EM-Http
require 'faraday'
require 'net/http'
require 'pp'
# Repos:
# https://github.com/technoweenie/faraday
# https://github.com/pengwynn/faraday_middleware
# Blog posts:
# http://adventuresincoding.com/2010/09/writing-modular-http-client-code-with-faraday
@rtomayko
rtomayko / gist:942910
Created April 26, 2011 19:21 — forked from schacon/gist:942899
delete all remote branches that have already been merged into master
$ git branch -r --merged |
grep origin |
grep -v -e '>' -e master |
xargs -L1 |
awk '{split($0,a,"/"); print a[2]}' |
xargs git push origin --delete
# Extend jQuery objects with Underscore collection methods.
#
# Each collection method comes in two flavors: one prefixed
# with _, which yields a bare DOM element, and one prefixed
# with $, which yields a jQuery-wrapped element.
#
# So if `this` is a jQuery object, instead of:
#
# _.max @, (el) -> $(el).height()
#
@javan
javan / gist:1168475
Created August 24, 2011 16:32
Fix iPhone home button
Found this tip in comment here: http://www.tipb.com/2011/01/04/tipb-bug-home-button-working-iphone/
1.) Open any application
2.) Press and hold the power button until the slide to shutdown swipe bar appears.
3.) Release Power button
4.) Press and hold Home button Lightly
until screen returns to icon screen
@igrigorik
igrigorik / Gemfile
Created August 26, 2011 06:33
HTML5 SSE / EventSource demo with Goliath
source :gemcutter
gem 'goliath', :git => 'git://github.com/postrank-labs/goliath.git'
gem 'em-synchrony', :git => 'git://github.com/igrigorik/em-synchrony.git'
require 'em-http'
EM.run do
def dispatch(uri, retries = 0)
h = EM::HttpRequest.new(uri).get
h.callback { |rep| [:success, rep.response]; EM.stop }
h.errback do |rep|
p [:fail, rep]
@rkh
rkh / sinatra_app_instance_in_spec.rb
Created October 27, 2011 05:45 — forked from duien/sinatra_app_instance_in_spec.rb
Get access to the Sinatra application instance that ran the current test in Rack::Test. Created by @bsiggelkow
describe LeadService do
LeadService.configure(:test) do
before { settings.set(:instance, self) }
end
# Required for Rack::Test
#
def app
LeadService