Skip to content

Instantly share code, notes, and snippets.

56k: "https://123.campfirenow.com/images/56k.gif"
bell: ":bell:"
bezos: ":laughing::thought_balloon:"
bueller: "anyone?"
clowntown: "https://123.campfirenow.com/images/clowntown.gif"
crickets: "hears crickets chirping"
dangerzone: "https://123.campfirenow.com/images/dangerzone.png"
danielsan: ":fireworks: :trophy: :fireworks:"
deeper: "https://123.campfirenow.com/images/top.gif"
drama: "https://123.campfirenow.com/images/drama.jpg"
@rkh
rkh / index.js
Created December 17, 2012 19:30 — forked from aledbf/index.js
var program = require('commander'),
request = require('request'),
fs = require('fs'),
ursa = require('ursa');
program.on('--help', function() {
console.log(' Alternative to https://gist.github.com/fbb99b638e9da27fe24d (generate secure environment variables)');
console.log(' Example:');
console.log('');
console.log(' $ node index -r github-user/user-repo -v SECURE=value');
@rkh
rkh / hack.rb
Created May 17, 2012 16:31 — forked from lmarburger/hack.rb
Possible for a module included somewhere to override a class's instance method?
class Base
def call
'call'
end
end
p Base.new.call #=> "call"
# Monkeypatching "works" but doesn't provide access to #super
@rkh
rkh / gist:2225573
Created March 28, 2012 11:43 — forked from ffeldhaus/gist:2225345
Logging with ActiveSupport
require 'sinatra'
require 'active_support'
require 'logger'
class SinatraTest < Sinatra::Application
module RedirectedLogger
def self.logger=(value)
Thread.current['sinatra.logger'] = value
end
@rkh
rkh / Gemfile
Created December 14, 2011 11:16 — forked from blambeau/Gemfile
jquery-sinatra-streaming
source "http://rubygems.org/"
gem "sinatra", "~> 1.3.0"
gem "thin"
@rkh
rkh / rack_example.ru
Created December 8, 2011 16:19 — forked from mattetti/rack_example.ru
Very basic rack application showing how to use a router based on the uri and how to process requests based on the HTTP method used.
#########################################
# Very basic rack application showing how to use a router based on the uri
# and how to process requests based on the HTTP method used.
#
# Usage:
# $ rackup rack_example.ru
#
# $ curl -X POST -d 'title=retire&body=I should retire in a nice island' localhost:9292/ideas
# $ curl -X POST -d 'title=ask Satish for a gift&body=Find a way to get Satish to send me a gift' localhost:9292/ideas
# $ curl localhost:9292/ideas
@rkh
rkh / rack_example.ru
Created December 8, 2011 16:16 — forked from mattetti/rack_example.ru
Very basic sinatra application showing how to use a router based on the uri and how to process requests based on the HTTP method used.
#########################################
# Very basic sinatra application showing how to use a router based on the uri
# and how to process requests based on the HTTP method used.
#
# Usage:
# $ ruby rack_example.rb
#
# $ curl -X POST -d 'title=retire&body=I should retire in a nice island' localhost:4567/ideas
# $ curl -X POST -d 'title=ask Satish for a gift&body=Find a way to get Satish to send me a gift' localhost:4567/ideas
# $ curl localhost:9292/ideas
@rkh
rkh / game.rb
Created October 30, 2011 06:44
Rock, paper, scissors in Sinatra
require 'sinatra'
# before we process a route, we'll set the response as
# plain text and set up an array of viable moves that
# a player (and the computer) can perform
before do
content_type :txt
@defeat = {rock: :scissors, paper: :rock, scissors: :paper}
@throws = @defeat.keys
end
@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
// class version 51.0 (51)
// access flags 0x21
public class example extends org/jruby/ast/executable/AbstractScript {
// compiled from: example.rb
// debug info: /home/tim/example.rb
// access flags 0x100A
private static setPosition(Lorg/jruby/runtime/ThreadContext;I)V
ALOAD 0