Skip to content

Instantly share code, notes, and snippets.

View tors's full-sized avatar
:octocat:

Tors tors

:octocat:
  • Vim
View GitHub Profile
@tors
tors / application_controller.rb
Created March 27, 2012 07:42
Rails 3.1 - Adding custom 404 and 500 error pages
class ApplicationController < ActionController::Base
# ...
unless Rails.application.config.consider_all_requests_local
rescue_from Exception, with: :render_500
rescue_from ActionController::RoutingError, with: :render_404
rescue_from ActionController::UnknownController, with: :render_404
rescue_from ActionController::UnknownAction, with: :render_404
rescue_from ActiveRecord::RecordNotFound, with: :render_404
end
@tors
tors / .gitignore
Created April 4, 2012 06:06 — forked from nulltask/.gitignore
cluster-io
.DS_Store
._*
node_modules/
@tors
tors / auth_in_a_box.rb
Created May 31, 2012 09:17 — forked from canton7/Sample DataMapper model.rb
Sinatra Auth in a Box
# Adapted from https://gist.github.com/1444494
# Things you need to do before using this lib:
# require 'sinatra/flash' (gem sinatra-flash)
# register Sinatra::Flash
# register Sinatra::AuthInABox
# enable :sessions optionally configuring your favourite sessions settings
# Have a User model, which has the methods self.authenticate(user, pass) and is_admin?
# In your forms (login, signup, etc) make sure you display flash[:errors]
@tors
tors / capybara.md
Created June 5, 2012 05:54 — forked from steveclarke/capybara.md
RSpec Matchers

Capybara

Matchers

have_button(locator)

have_checked_field(locator)
@tors
tors / configuration.rb
Created June 5, 2012 10:36 — forked from youngbrioche/configuration.rb
Small configuration DSL
module Foo
module Configuration
require 'ostruct'
extend ActiveSupport::Concern
included do
#
end
module ClassMethods
@tors
tors / README.md
Created June 11, 2012 08:04 — forked from keikubo/README.md
Nginx + Unicorn for Rails on Rackhub

Nginx + Unicorn for Rails on Rackhub

Description:

This script enables you to launch your Rails application in production environment (port:80) with Nginx and Unicorn.

Installation:

Please make sure that your Gemfile in your rails application includes unicorn.

@tors
tors / facebook_oauth.rb
Created June 20, 2012 05:52 — forked from t-kashima/facebook_oauth.rb
SinatraとOAuthとFacebook
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'koala'
configure do
APPLICATION_ID = "facebook_application_id"
APPLICATION_SECRET = "facebook_application_secret"
set :sessions, true
@tors
tors / deploy.rb
Created August 3, 2012 06:57 — forked from mrrooijen/deploy.rb
Capistrano with Foreman Capfile
# encoding: utf-8
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
require 'rvm/capistrano'
set :application, "hirefireapp"
set :repository, "git@codeplane.com:meskyanichi/myapp.git"
set :branch, "develop"
set :rvm_ruby_string, "1.9.2"
@tors
tors / mixins.scss
Created August 10, 2012 06:06 — forked from jpmckinney/mixins.scss
CSS3 SCSS Mixins
// blog post: http://blog.slashpoundbang.com/post/15096433153/css3-scss-mixins
// Mixins ----------------------------------------------------------------------
// http://css3please.com/
@mixin background-rgba($red, $green, $blue, $opacity, $rgba) {
background-color: transparent;
background-color: rgba($red, $green, $blue, $opacity);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$rgba}',endColorstr='#{$rgba}');
zoom: 1;
}
# test/support/custom_capybara_expectations.rb
module CustomCapybaraExpectations
def has_flash_message?(message)
within '#flash' do
has_content? message
end
end
end
Capybara::Session.send :include, CustomCapybaraExpectations
CustomCapybaraExpectations.public_instance_methods(false).each do |name|