Skip to content

Instantly share code, notes, and snippets.

View andrew's full-sized avatar

Andrew Nesbitt andrew

View GitHub Profile
@andrew
andrew / rails_template.rb
Created April 2, 2009 12:39 — forked from ioptics/gist:88895
Rails template
# Delete unnecessary files
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/images/rails.png"
run "rm public/javascripts/prototype.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/controls.js"
# Copy database.yml for distribution use
@mislav
mislav / template-uri.rb
Created September 27, 2009 15:31
URI templates are, like, super-useful
# https://github.com/sporkmonger/addressable/
require 'addressable/template'
# http://dev.twitter.com/doc/get/statuses/followers
template = Addressable::Template.new 'http://{host=twitter.com}' +
'/statuses/followers{-prefix|/|id}.{format=json}' +
'?{-join|&|user_id,screen_name,cursor}'
template.expand(:id => 'mislav')
# => http://twitter.com/statuses/followers/mislav.json?
module Rack
class ZombieShotgun
ZOMBIE_AGENTS = [
/FrontPage/,
/Microsoft Office Protocol Discovery/,
/Microsoft Data Access Internet Publishing Provider/
].freeze
ZOMBIE_DIRS = ['_vti_bin','MSOffice','verify-VCNstrict','notified-VCNstrict'].to_set.freeze
@defunkt
defunkt / connection_fix.rb
Created November 19, 2009 20:00
MySQL server has gone away fix
# 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/
@MarkLodato
MarkLodato / git-snapshot.sh
Created February 13, 2010 00:22
git-snapshot-sh - a script to save junk code
#!/bin/sh
#
# git-snapshot.sh - save junk code to a snapshots branch
#
# USAGE: git-snapshot.sh [-m message] [files...]
#
# Run `git add files` and then create a new commit on branch 'snapshot'
# with two parents, the previous snapshot and HEAD.
#
# If -m is given, the 'message' is used as the commit message; otherwise
/*
* Bookmarklet for viewing source in iPad Safari
*/
javascript:(function(){
var w = window.open('about:blank'),
s = w.document;
s.write('<!DOCTYPE html><html><head><title>Source of ' + location.href + '</title><meta name="viewport" content="width=device-width" /></head><body></body></html>');
s.close();
@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:
@andykent
andykent / forward.coffee
Created July 3, 2010 17:39
Super simple, round robin, TCP port forwarding with node.js
net: require "net"
sys: require "sys"
LISTEN_PORT: 10000
SERVER_ADDRESS: '127.0.0.1'
AVAILABLE_PORTS: [10001, 10002, 10003, 10004, 10005, 10006]
CONNECTION_COUNTER: 0
reservePort: (callback) ->
if AVAILABLE_PORTS.length > 0
@ryanflorence
ryanflorence / gitrss.rb
Created July 14, 2010 18:37
Create an RSS 2.0 feed from a git log
# Adapted by Ryan Florence (http://ryanflorence.com)
# original by Chris Dinger: http://www.houseofding.com/2009/03/create-an-rss-feed-of-your-git-commits/
#
# Takes one, two, or three arguments
# 1. Repository path (required) - the path to the repository
# 2. The url to put as the <link> for both channel and items
# 3. the repository name, defaults to directory name of the repository
#
# Command line usage:
# ruby gitrss.rb /path/to/repo > feed.rss
// HOWTO: load LABjs itself dynamically!
// inline this code in your page to load LABjs itself dynamically, if you're so inclined.
(function (global, oDOC, handler) {
var head = oDOC.head || oDOC.getElementsByTagName("head");
function LABjsLoaded() {
// do cool stuff with $LAB here
}