Skip to content

Instantly share code, notes, and snippets.

View supairish's full-sized avatar
🏂
Shreddin

Chris Irish supairish

🏂
Shreddin
View GitHub Profile
@joahking
joahking / confirm_dialog_steps.rb
Created March 2, 2011 15:03
bypass confirm dialog
Then /^(.+) and I confirm dialog box$/ do |step|
bypass_confirm_dialog
Then step
end
@PanosJee
PanosJee / refinery_omniauth.rb
Created March 17, 2011 22:58
Login / Register to Refinery with Omniauth (facebook, twitter, openid, etc)
# Create a role user (no perms). Fire up the console rails c
$> Role.create(:title=>'User')
# In your Gemfile add
gem 'oa-oauth', :require => 'omniauth/oauth'
# At the beginning of devise.rb. You can also create a yaml file and instantiate when Rails begin
# For shake of simplicity I added the credentials at devise.rb
Facebook = Rails.env.development? ? {:app_id => 2621xxx, :secret => 'e81f33d042xxxxx'} :
{:app_id => 1749xxx9, :secret => '13c11be6628dc1xxxx'}
@parndt
parndt / gist:1011435
Created June 7, 2011 00:32
How to cache pages and clear them in Refinery CMS
# put in config/application.rb
config.to_prepare do
::PagesController.module_eval do
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
end
::Page.module_eval do
after_save :clear_static_caching!
after_destroy :clear_static_caching!
@thomasmaas
thomasmaas / gist:1013101
Created June 7, 2011 20:39 — forked from parndt/gist:1011435
How to cache pages and clear them in Refinery CMS
# put in config/application.rb
config.to_prepare do
::PagesController.module_eval do
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
end
::Page.module_eval do
after_save :clear_static_caching!
after_destroy :clear_static_caching!
@ericallam
ericallam / gist:1019446
Created June 10, 2011 18:35
How to log all queries for a PostgreSQL homebrew install on OS X

Open the postgresql.conf config file:

$> mate /usr/local/var/postgres/postgresql.conf

Uncomment the line with 'log_destination' and set it to 'syslog'

log_destination = 'syslog'

Open the syslog config:

# Pass in the name of the site you wich to create a cert for
domain_name = ARGV[0]
if domain_name == nil
puts "Y U No give me a domain name?"
else
system "openssl genrsa -out #{domain_name}.key 1024"
system "openssl req -new -key #{domain_name}.key -out #{domain_name}.csr -subj '/C=US/ST=NJ/L=Monroe/O=MyCompany/OU=IT/CN=#{domain_name}'"
system "cp #{domain_name}.key #{domain_name}.key.bak"
@ngauthier
ngauthier / test_helper.rb
Created July 12, 2011 21:29
exceptions are displayed in the console when integration testing with capybara
# Given an application, yield to a block to handle exceptions
class ExceptionRaiserApp
def initialize(app, &block)
@app = app
@block = block
end
def call(env)
@app.call(env)
rescue => e
@travis
travis / gist:1084767
Created July 15, 2011 14:16
testing facebook connect with capybara and rspec
require 'mogli'
module FacebookIntegrationHelpers
shared_context "with unconnected facebook user" do
let(:fb_user) { create_test_user(installed: false) }
after { fb_user.destroy }
end
def app_client
Mogli::AppClient.new(AppConfig.facebook.access_token, AppConfig.facebook.app_id)
@benatkin
benatkin / Global.sublime-settings
Created July 20, 2011 04:26
excluding node_modules from Sublime Text 2
// Place user-specific overrides in this file, to ensure they're preserved
// when upgrading
{
"folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", "node_modules"]
}
@beccasaurus
beccasaurus / evaluate_multiline_script.rb
Created August 11, 2011 00:07
Capybara helper for calling evaluate_script with multiple lines of JavaScript, supporting short-circuit return statements, etc etc. Just wraps your JS in a function and then calls it.
# Given a multiline script, this will wrap the script in a function and then
# call it so Capybara's evaluate_script knows how to get the return value properly.
# By default, Capybara just prepends a 'return ' to your script.
#
# Usage:
#
# value = page.evaluate_multiline_script %{
# var foo = [];
# $('li').each(function(i, li) {
# foo[foo.length] = $(li).text();