Skip to content

Instantly share code, notes, and snippets.

nnoremap <Leader>yf :let @*=expand("%:p")<cr>:echo "Copied file name to clipboard"<cr>
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@moklett
moklett / chargify-webhook-reflector.rb
Created November 13, 2013 20:55
Chargify Webhook Reflector. Sinatra app I use in dev to get warm fuzzies as the webhooks fly by. Since Chargify will only post to ports 80 or 443 in production, you'll need to run this on a web accessible box on one of those ports. http://docs.chargify.com/webhooks
require 'sinatra'
require 'openssl'
require 'json'
post '/' do
body = request.body.read
puts "Time : #{Time.now}"
puts "Actual Signature : #{request.env['HTTP_X_CHARGIFY_WEBHOOK_SIGNATURE_HMAC_SHA_256']}"
puts "Computed Signature: #{signature(body)}"
@steveklabnik
steveklabnik / beer.rb
Last active December 20, 2015 08:59
99 bottles of metaprogrammed beer
class Beer
def sing(start, finish = 0)
start.downto(finish).collect do |number|
verse(number) + "\n"
end.join
end
def verse(number)
Kernel.const_get("Beer::Verse#{number}")
end
@jch
jch / geocoding-google.rb
Created July 24, 2013 22:54
Simple Google Geocoding API V3 client. All I needed was a state name given a postal code. Might be interesting to build this out, but felt I'd share the basics first.
require 'uri'
require 'multi_json'
require 'net/http'
# Simple client wrapper around Google Geocoding API V3
# https://developers.google.com/maps/documentation/geocoding
#
# geo = Geocoding::Google.geocode('91106')
# geo.state
#
@glv
glv / trouble-free-bundler.md
Last active March 16, 2018 14:50
This is a thing I wrote over a year ago for the internal LivingSocial wiki. There's nothing LS-specific about it, and it seems generally useful, so …

Trouble-Free Bundler

Every couple of weeks, I hear someone complaining about some difficulties with Bundler. Yesterday, it happened twice. But somehow I just never have those difficulties. I'm not saying Bundler is perfect; certainly in its early days it wasn't even close. But for the past two years it's been incredibly solid and trouble-free for me, and I think a large part of the reason is the way I use it. Bundler arguably does too much, and just as with Git, a big part of it is knowing what not to do, and configuring things to avoid the trouble spots.

@ragingwind
ragingwind / Backend Architectures Keywords and References.md
Last active July 17, 2026 16:57
Backend Architectures Keywords and References
migrate () {
local zeus_command=""
if _zeus-installed
then
zeus_command="zeus"
fi
$zeus_command rake db:migrate && $zeus_command rake db:rollback && $zeus_command rake db:migrate && $zeus_command rake db:test:prepare
}
@ahoward
ahoward / kew.rb
Created April 23, 2013 22:49
portable (jruby / ruby) queue that should work in ruby 2.0, planning to use handling signals pushed via trap(sig){ ... }
class Kew
require 'thread'
require 'socket'
def initialize
@pipes = UNIXSocket.pair(:STREAM, 0)
@mutex = Mutex.new
end
def pipe
@javan
javan / development.rb
Created April 16, 2013 15:33
Toggle features in development mode by touching various tmp/*.txt files.
# Touch tmp/caching.txt to turn on caching
if Rails.root.join('tmp/caching.txt').exist?
config.action_controller.perform_caching = true
config.cache_store = :mem_cache_store
else
config.action_controller.perform_caching = false
config.cache_store = :null_store
end
# Touch tmp/precompile.txt to test with asset precompiles. Run