This file contains hidden or 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
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
This file contains hidden or 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
#!/bin/sh | |
rm -rf `find . -type d -name .svn` |
This file contains hidden or 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
# | |
# http://www.developerit.com/2010/05/07/creating-a-multi-tenant-application-using-postgresqls-schemas-and-rails | |
# | |
module SchemaUtils | |
def self.add_schema_to_path(schema) | |
conn = ActiveRecord::Base.connection | |
conn.execute "SET search_path TO #{schema}, #{conn.schema_search_path}" | |
end | |
def self.reset_search_path |
This file contains hidden or 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
module AccessControl | |
extend self | |
def configure(&block) | |
instance_eval(&block) | |
end | |
def definitions | |
@definitions ||= Hash.new | |
end |
This file contains hidden or 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
module ActiveSupport | |
module Callbacks | |
module ClassMethods | |
def define_callbacks(*callbacks) | |
config = callbacks.last.is_a?(Hash) ? callbacks.pop : {} | |
callbacks.each do |callback| | |
class_attribute "_#{callback}_callbacks" | |
send("_#{callback}_callbacks=", CallbackChain.new(callback, config)) | |
__define_runner(callback) | |
end |
This file contains hidden or 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
module Test | |
module Unit | |
TestCase = RSpec::Core::ExampleGroup | |
end | |
end | |
class Test::Unit::TestCase | |
def self.inherited(host) | |
host.set_it_up host.name.gsub(/(Spec|Test)/,'') | |
def host.method_added(name) |
This file contains hidden or 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
#!/bin/bash | |
# *************************************************************** | |
# Name: install_chef_client.sh | |
# Purpose: Install chef client and register with the chef | |
# server. | |
# Notes: This script must be run as root | |
# This script installs the chef repo in the /root home | |
# directory | |
# Assumes these files exist in the same directory: | |
# <-c input>.pem |
This file contains hidden or 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
# http://rubypond.com/blog/useful-flash-messages-in-rails | |
FLASH_NOTICE_KEYS = [:error, :notice, :warning] | |
def flash_messages | |
return unless messages = flash.keys.select{|k| FLASH_NOTICE_KEYS.include?(k)} | |
formatted_messages = messages.map do |type| | |
content_tag :div, :class => type.to_s do | |
message_for_item(flash[type], flash["#{type}_item".to_sym]) | |
end |
This file contains hidden or 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
# -*- mode: ruby; coding: utf-8 -*- | |
if defined? Rails | |
railsrc = __FILE__ + '.rails' | |
load railsrc if File.exist? railsrc | |
envrc = File.join( Rails.root, '.irbrc' ) | |
load envrc if File.exist? envrc | |
end |
This file contains hidden or 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
# Modify this file accordingly for your specific requirement. | |
# http://www.thegeekstuff.com | |
# 1. Delete all existing rules | |
iptables -F | |
# 2. Set default chain policies | |
iptables -P INPUT DROP | |
iptables -P FORWARD DROP | |
iptables -P OUTPUT DROP |