Skip to content

Instantly share code, notes, and snippets.

View elithrar's full-sized avatar
🌐
Helping make the Internet better.

Matt Silverlock elithrar

🌐
Helping make the Internet better.
View GitHub Profile
@elithrar
elithrar / stripe-config.js
Created November 27, 2013 00:40
Example Stripe Checkout - Custom Integration for #stripe
// Disable the payment/submit button until everything has loaded
// (if Stripe fails to load, we can't progress anyway)
$(document).ready(function() {
$("#payment-button").prop('disabled', false)
})
var handler = StripeCheckout.configure("customButtonA", {
key: '<yourpublishablekey',
token: function(token, args){
var $input = $('<input type=hidden name=stripeToken />').val(token.id);
@elithrar
elithrar / use.go
Last active December 29, 2015 02:29
use.go — the little HTTP middleware helper that could.
// use provides a cleaner interface for chaining middleware for single routes.
// Middleware functions are simple HTTP handlers (w http.ResponseWriter, r *http.Request)
//
// r.HandleFunc("/login", use(loginHandler, rateLimit, csrf))
// r.HandleFunc("/form", use(formHandler, csrf))
// r.HandleFunc("/about", aboutHandler)
func use(h http.HandlerFunc, middleware ...func(http.HandlerFunc) http.HandlerFunc) http.HandlerFunc {
for _, m := range middleware {
h = m(h)
}
require 'bundler/setup'
require 'sinatra/base'
require 'rack/contrib'
# The project root directory
$root = ::File.dirname(__FILE__)
class SinatraStaticServer < Sinatra::Base
get(/.+/) do