Skip to content

Instantly share code, notes, and snippets.

View richhollis's full-sized avatar

Richard Hollis richhollis

View GitHub Profile
@cowboy
cowboy / jquery_plugin_org_1.js
Created January 8, 2010 20:52
View revisions from oldest -> newest
// Creating a plugin with $.myNS.public_method1() and $.myNS.public_method2() methods, a few different ways.
(function($){
var private_var,
myNS = $.myNS = {},
public_method2;
myNS.public_method1 = function(){
private_method();
@a-chernykh
a-chernykh / application_controller.rb
Created June 22, 2011 19:43
devise force https for sign in and sign up routes
class ApplicationController < ActionController::Base
before_filter :ensure_proper_protocol
protected
def ssl_allowed_action?
(params[:controller] == 'users/sessions' && ['new', 'create'].include?(params[:action])) ||
(params[:controller] == 'users/registrations' && ['new', 'create', 'edit', 'update'].include?(params[:action])) ||
(params[:controller] == 'users/omniauth_callbacks')
end
@newbamboo
newbamboo / gist:1261956
Created October 4, 2011 15:36 — forked from christoomey/gist:1206762
Linode Ubuntu 10.04 (Lucid) with passenger & nginx for rails hosting
#################################################################
# #
# A guide to setting up a linode Ubuntu VPS for #
# Ruby on Rails hosting with nginx & passenger #
# #
# Compiled by Chris Toomey [ctoomey.com] on Sept. 9 2011 #
# #
#################################################################
# Start with base 10.04 image. Setup the DNS for any domains you
@olivoil
olivoil / module.coffee
Created January 19, 2012 20:19
Mixins/Modules behavior in coffeescript. Thought of to be used with Backbone.js applications
# define module behavior
class Module
keywords = ['extended', 'included', 'initialize']
@extend = (obj) ->
for key, value of obj when key not in keywords
@[key] = value
obj.extended?.apply(@)
this
@simeonwillbanks
simeonwillbanks / Gemfile
Created January 26, 2012 23:18
#gemfile rails 3, rspec-rails, capybara, capybara-webkit, headless in order to run request specs that can test javascript
source 'https://rubygems.org'
gem 'rails', '3.2.0'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
@chetan
chetan / test_helper.rb
Created February 13, 2012 22:02
spork+simplecove rails3.2
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
require File.expand_path(File.dirname(__FILE__)) + "/test_prefork"
end
@sasimpson
sasimpson / gist:1112739
Created July 28, 2011 22:37
Ruby Net:HTTP chunked transfer
require 'uri'
require 'net/http'
class Chunked
def initialize(data, chunk_size)
@size = chunk_size
if data.respond_to? :read
@file = data
end
end
@dblock
dblock / capybara_wait_until.rb
Created July 24, 2013 07:38
Re-implementation of Capybara wait_until.
class Capybara::Session
def wait_until(timeout = Capybara.default_wait_time)
Timeout.timeout(timeout) do
sleep(0.1) until value = yield
value
end
end
end
@guilleiguaran
guilleiguaran / application_helper.rb
Created August 15, 2011 20:44
CoffeeScript inside your views templates
# coffee_script_tag
# Usage:
#
# <%= coffee_script_tag do %>
# alert 'Hello World'
# <% end %>
#
#
# You will get in your page:
#
@maccman
maccman / juggernaut_channels.rb
Created June 26, 2012 04:56
Sinatra Server Side Event streaming with private channels.
# Usage: redis-cli publish message.achannel hello
require 'sinatra'
require 'redis'
conns = Hash.new {|h, k| h[k] = [] }
Thread.abort_on_exception = true
get '/' do