Skip to content

Instantly share code, notes, and snippets.

@michaelfeathers
michaelfeathers / gist:1855765
Created February 17, 2012 22:19
Five lines that turn Ruby into a different language
class Object
def method_missing m, *args
Object.respond_to?(m, true) ? Object.send(m, self, *args) : super
end
end
@burke
burke / 0-readme.md
Created January 27, 2012 13:44 — forked from funny-falcon/cumulative_performance.patch
ruby-1.9.3-p327 cumulative performance patch for rbenv

ruby-1.9.3-p327 cumulative performance patch for rbenv

This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.

Requirements

You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf using homebrew.

@macks
macks / restart-unicorn.rb
Created December 29, 2011 12:57
Graceful restart script for Unicorn
#!/usr/bin/ruby
# restart-unicorn: Graceful restart for Unicorn
# depends on Linux's proc(5)
#
# MIT License: Copyright(c)2011 MATSUYAMA Kengo
require 'scanf'
require 'timeout'
class ProcFS
@lukasz-kaniowski
lukasz-kaniowski / thor.sh
Created November 8, 2011 15:37
thor_completion - bash completion for thor
_thorcomplete() {
COMPREPLY=($(compgen -W "`thor list | grep thor | cut -d " " -f 2`" -- ${COMP_WORDS[COMP_CWORD]}))
return 0
}
complete -o default -o nospace -F _thorcomplete thor
var chatData = JSON.stringify({
timestamp: (currentDate.getTime() - currentDate.getMilliseconds()) / 1000
, chat: {
employee_id: employeeId
, created_at: chat.created_at
, username: chat.chatname
, message: chat.message
}
});
@josevalim
josevalim / omniauth_controller.rb
Created October 8, 2011 10:58
Dynamic omniauth
class OmniauthController < ApplicationController
def start
request_phase(:facebook, client_id, client_secret)
end
def callback
callback_phase(:facebook, client_id, client_secret) do
render :text => "Done!"
end
end
@matiasfha
matiasfha / index.html
Created June 2, 2011 20:19
nodejs + thrift +socket.io + couchdb
<!DOCTYPE>
<html>
<head>
<title>Test</title>
</head>
<body>
<div id="mensajes">
Hola Mundo
@jjb
jjb / gist:996510
Created May 28, 2011 02:00
How to set the certificate file for Net::HTTP library-wide

In my previous post I described how to securely acquire the Mozilla list of root certificates and convert them to a form usable by curl and various libraries which don't ship with them.

Next, I want to point Net:HTTP at this file library-wide, so that it is used by all invocations of methods accessing https resources (in particular, Kernel#open, which in ruby 1.8.7 does not have a ca_file option and is therefore unusable with https). I hunted around the ruby standard library for a couple hours and came up with this:

require 'open-uri'
require 'net/https'

module Net
 class HTTP
<style media="print">
#printed-image { content: url(/path/to/image.png); }
</style>
<img id="printed-image" src="/images/spacer.gif">
@unixcharles
unixcharles / nginx.conf
Last active April 10, 2025 21:52
nginx config for http/https proxy to localhost:3000
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;