Skip to content

Instantly share code, notes, and snippets.

View gist:1007336
require 'rubygems'
require 'sinatra'
require 'geoloqi'
enable :sessions
configure do
Geoloqi.config :client_id => 'YOUR OAUTH CLIENT ID', :client_secret => 'YOUR CLIENT SECRET'
kyledrake / gist:1128433
Created Aug 5, 2011
Rubinius day web server parallelism benchmarking tests
View gist:1128433
### TEST 1: Simple Rack app RAW AND DUMB
class HelloRubinius
def call(env)
return [
{'Content-Type' => 'text/html'},
['Hello #rbxday!']
kyledrake /
Created Aug 23, 2011
Debugging Kirk $stderr issue
require 'rubygems'
require 'sinatra/base'
require 'kirk'
require 'ruby-debug'
run {
get '/' do
# debugger
$stdout.puts 'Testing $stdout!'
$stderr.puts 'Testing $stderr!'
kyledrake / gist:1498932
Last active Aug 2, 2016
Neocities' Rainbows! config file -
View gist:1498932
# This is Neocities' Rainbows! config file. We are using this in production to run all our web apps.
# It works really well for us and has been heavily load tested, so I wanted to share it with the community.
# In my opinion, this is the best way to deploy a ruby web application. Unlike EventMachine based solutions,
# it uses real ruby threads, which allows it to take advantage of the internal non-blocking IO pattern
# in MRI.
# Contrary to popular belief, MRI doesn't block execution to wait on IO when you are using threads, even
# with the GIL. The requests are done concurrently for anything that is based on the IO class. This
# includes things like Net::HTTP and even `system commands`. Grep the MRI Ruby source code for
kyledrake / gist:1566576
Created Jan 5, 2012
Fix for AWS::S3 thread safety issues
View gist:1566576
require 'aws/s3'
class D7Obj < AWS::S3::S3Object
set_current_bucket_to "kd-test"
class S3Handler
:access_key_id => 'ID',
kyledrake / paranoid_delete.rb
Created Feb 22, 2012
Quick and dirty "paranoid delete" for Sequel
View paranoid_delete.rb
module Sequel
module ParanoidDelete
def self.included(base)
# Instead of actually deleting, we just set is_deleted to true,
# and look for it with our default dataset filter.
def delete
kyledrake / gist:2119737
Created Mar 19, 2012
How to rotate logs with Rainbows!
View gist:2119737
# Put this in a logrotate file (like /etc/logrotate.d/yourcompany):
rotate 7
size 5M
kyledrake / gist:2120107
Created Mar 19, 2012
Rainbows! config file for use with EventMachine
View gist:2120107
# This is a configuration script for using Rainbows with EventMachine. I'm providing it incase somebody finds it useful. But honestly, you
# should stop using EventMachine and use threads instead. The ThreadPool version of this is also in my gist list, and I recommend taking a look at that instead.
Rainbows! do
name = 'yourappname'
use :EventMachine
client_max_body_size nil # This is set in nginx
# keepalive_timeout 1
kyledrake / password.rb
Created Jun 6, 2012
Geoloqi's Password Encryption Code
View password.rb
# Due to recent concerns regarding password safety, Geoloqi has decided to publicly release the code
# that we use to do password hashing. After consulting with the community, this code now uses BCrypt for hashing
# (, which is based on blowfish, uses an integrated
# salting mechanism, and makes brute forcing expensive for attackers. It is widely used in the industry for
# production environments.
# Improvement suggestions are always welcome. Geoloqi takes security very seriously, and designs our systems to
# be as security-oriented as practically possible. We also believe in security transparency, because it leads to
# better security than obscurity, and is a more honest interaction with our customers.
kyledrake / gist:3077989
Created Jul 9, 2012
Ruby code for doing P12 to PEM conversion via command line. Supports MRI/JRuby/Rubinius
View gist:3077989
require 'tempfile'
require 'openssl'
require 'escape' # gem install escape
class CommandFailError < StandardError; end
def p12_to_pem_text(p12, pass='')
pass = '' if pass.nil?
# Use shell command for JRuby (see