Skip to content

Instantly share code, notes, and snippets.

View cyrusstoller's full-sized avatar
🏠
Working from home

Cyrus Stoller cyrusstoller

🏠
Working from home
View GitHub Profile
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@michaeldwan
michaeldwan / heroku_deploy.rake
Created July 4, 2010 02:08
Simple Rake task for customizing deployment to Heroku
# List of environments and their heroku git remotes
ENVIRONMENTS = {
:staging => 'myapp-staging',
:production => 'myapp-production'
}
namespace :deploy do
ENVIRONMENTS.keys.each do |env|
desc "Deploy to #{env}"
task env do
@joeyAghion
joeyAghion / match.rb
Created November 29, 2010 07:44
Implements the algorithm used by the National Resident Matching Program (NRMP) to match residency and fellowship applicants to programs.
# Implements the algorithm used by the National Resident Matching Program
# (NRMP) to match residency and fellowship applicants to programs. The
# algorithm is described here:
# http://www.nrmp.org/fellow/algorithm.html
# and again here:
# http://www.nrmp.org/res_match/about_res/algorithms.html
#
# The Test class computes the example match scenario described on those pages.
module Match
@mislav
mislav / gist:938183
Created April 23, 2011 02:28
Faraday SSL example
connection = Faraday::Connection.new('http://example.com') do |builder|
builder.request :url_encoded # for POST/PUT params
builder.adapter :net_http
end
# same as above, short form:
connection = Faraday.new 'http://example.com'
# GET
connection.get '/posts'
@dnagir
dnagir / deploy.rb
Created May 18, 2011 14:55
Flexible Rails deployment with Capistrano and Nginx
set :domain, ENV["domain"]
set :application, domain
set :user, ENV["user"]
set :destination, ENV["destination"] || domain
set :web_conf, ENV["web_conf"] || ENV["environment"] || 'production'
raise "please set domain=app.domain.name.com" unless domain
raise "please set user=server_username" unless user
set :port, ENV["port"] || 1234
set :repository, "."
@henrik
henrik / will_paginate.rb
Created September 13, 2011 14:57 — forked from isaacbowen/will_paginate.rb
Extends will_paginate to play well with Twitter's Bootstrap (http://twitter.github.com/bootstrap/). Suggested location: config/initializers/will_paginate.rb
# https://gist.github.com/1214011
module WillPaginate
module ActionView
def will_paginate(collection = nil, options = {})
options[:renderer] ||= BootstrapLinkRenderer
super.try :html_safe
end
class BootstrapLinkRenderer < LinkRenderer
@brentertz
brentertz / rvm2rbenv.txt
Created November 21, 2011 23:00
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@msabramo
msabramo / gist:1409594
Created November 30, 2011 15:59
brew install growlnotify-1.2.2 on OS X 10.6 (Snow Leopard)
marca@SCML-MarcA:/usr/local$ growlnotify
dyld: Symbol not found: _kSecRandomDefault
Referenced from: /usr/local/bin/growlnotify
Expected in: /System/Library/Frameworks/Security.framework/Versions/A/Security
in /usr/local/bin/growlnotify
Trace/BPT trap
marca@SCML-MarcA:/usr/local$ brew versions growlnotify
1.3 git checkout 2e23ced Library/Formula/growlnotify.rb
1.2.2 git checkout 5fb24f5 Library/Formula/growlnotify.rb
@johnrees
johnrees / _ubuntu_steps.sh
Last active November 29, 2021 01:42
Standard Rails 5.* setup for Ubuntu 14.04 LTS
# As root user
sudo su
# Update the OS
sudo apt-get update -y
# Add this to ~/.bashrc to remove timezone warnings
echo 'export LC_ALL="en_US.UTF-8"' >> ~/.bashrc
source ~/.bashrc
@travisp
travisp / invitations_controller.rb
Created March 9, 2012 15:56
devise_invitable with omniauthable
class InvitationsController < Devise::InvitationsController
# GET /resource/invitation/accept?invitation_token=abcdef
def edit
if params[:invitation_token] && self.resource = resource_class.to_adapter.find_first( :invitation_token => params[:invitation_token] )
session[:invitation_token] = params[:invitation_token]
render :edit
else
set_flash_message(:alert, :invitation_token_invalid)
redirect_to after_sign_out_path_for(resource_name)