Skip to content

Instantly share code, notes, and snippets.

View andrew's full-sized avatar

Andrew Nesbitt andrew

View GitHub Profile
@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
@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
@remy
remy / vat.md
Last active September 14, 2015 14:15
Testing logic for when VAT is applied

VAT Rules

Capture:

  • COUNTRY
  • VAT (optional and validated)
IF country IS "GB"
  ADD_VAT
IF country IS IN (eu) AND vat IS EMPTY
@andrew
andrew / rails3_template.rb
Created October 10, 2010 10:20
rails 3 template
# Delete unnecessary files
run "rm public/index.html"
run "rm app/views/layouts/application.html.erb"
run "rm public/favicon.ico"
run "rm public/images/rails.png"
run "rm public/javascripts/application.js"
run "rm public/javascripts/prototype.js"
run "rm public/javascripts/effects.js"
run "rm public/javascripts/dragdrop.js"
run "rm public/javascripts/controls.js"
@semanticart
semanticart / rails3-skeletor.rb
Created October 14, 2010 22:20
a rails 3 template app that gives you a few nifty items
# usage: rails new APP_NAME -m http://gist.github.com/627198.txt -TJ
# the -T drops test-unit and the -J drops prototype
gem "pg"
gem "omniauth"
gem "paperclip"
gem "haml"
gem "sass"
@ralphholzmann
ralphholzmann / iframe-facebook.js
Created November 13, 2010 19:44
Modernizr tests to detect if you're in an iframe or facebook iframe
Modernizr
.addTest('iframe', function() {
return window.top.location != window.location;
})
.addTest('facebook', function() {
return !! ~ location.href.indexOf( 'fb_sig_in_iframe=1' );
});
@netpro2k
netpro2k / gist:709570
Created November 22, 2010 05:39
libfreenect homebrew formula
# install homebrew (details here: https://github.com/mxcl/homebrew/wiki/installation or just run the following command)
ruby -e "$(curl -fsSL https://gist.github.com/raw/323731/install_homebrew.rb)"
# install xcode: http://developer.apple.com/technologies/xcode.html
# install homebrew formulas (this should eventually be in official homebrew repo)
cd /usr/local/Library/Formula
curl --insecure -O "https://github.com/OpenKinect/libfreenect/raw/master/platform/osx/homebrew/libfreenect.rb"
curl --insecure -O "https://github.com/OpenKinect/libfreenect/raw/master/platform/osx/homebrew/libusb-freenect.rb"
@thattommyhall
thattommyhall / gist:953400
Created May 3, 2011 14:14 — forked from andykent/gist:925458
Nginx Upstart
description "nginx http daemon"
start on runlevel [2345]
stop on runlevel [!2345]
exec /opt/nginx/sbin/nginx -g "daemon off;"
respawn
@chriseppstein
chriseppstein / 1_sprite_input.css
Created May 5, 2011 23:34
A snippet of sprites on my latest feature at work.
@import "local/provider/databar-icon/*.png";
#databar {
.data-field {
.icon {
@include databar-icon-sprite(default);
@include databar-icon-sprite-dimensions(default);
float: left;
margin: 9px 3px 0 0;
}