This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################# | |
# # | |
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem 'rails', '3.2.0' | |
# Bundle edge Rails instead: | |
# gem 'rails', :git => 'git://github.com/rails/rails.git' | |
gem 'sqlite3' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'uri' | |
require 'net/http' | |
class Chunked | |
def initialize(data, chunk_size) | |
@size = chunk_size | |
if data.respond_to? :read | |
@file = data | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coffee_script_tag | |
# Usage: | |
# | |
# <%= coffee_script_tag do %> | |
# alert 'Hello World' | |
# <% end %> | |
# | |
# | |
# You will get in your page: | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
OlderNewer