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 'test_helper' | |
describe PagesController do | |
before{ sign_in } | |
subject{ PagesController.new } | |
%w{some_page another_page}.each do |page| | |
describe "rendering the #{page} page" do | |
it 'should render successfully' do |
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
# Minitest and Rspec will need separate environments because both gems define 'describe' | |
# 'm' is a nice test runner gem. It lets you run 'm test/models/foo.rb:21' | |
# Gemfile | |
group :minitest do | |
gem 'minitest-rails' | |
gem 'minitest-rails-capybara' | |
gem 'factory_girl_rails' | |
gem 'm' |
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
# Add your own tasks in files placed in lib/tasks ending in .rake, | |
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. | |
require File.expand_path('../config/application', __FILE__) | |
require 'rake' | |
require 'rake/testtask' | |
Web::Application.load_tasks | |
Rake::TestTask.new do |t| |
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
set tabstop=2 | |
set shiftwidth=2 | |
set expandtab | |
set ai | |
syntax on | |
set ruler | |
set smarttab | |
nnoremap <F7> :call TogglePasteMode()<CR> | |
inoremap <F7> <ESC><F7> | |
function TogglePasteMode () |
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
-- Calculate the number of days within a range overlapped by an arbitrary number of other ranges. | |
SELECT | |
COUNT(active_day), | |
action_id | |
FROM ( | |
SELECT | |
DISTINCT( | |
GENERATE_SERIES( | |
start_at, |
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
# With before filter | |
class FoosController < ApplicationController | |
before_filter :find_foo, :only => [:edit, :show, :update] | |
def create | |
end | |
def edit | |
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
# ApplicationController | |
# Source: http://stackoverflow.com/questions/31320/how-to-profile-a-rails-controller-action | |
around_filter :profile if Rails.env.development? | |
def profile | |
if params[:profile] && result = RubyProf.profile { yield } | |
out = StringIO.new | |
RubyProf::GraphHtmlPrinter.new(result).print out, :min_percent => 0 | |
self.response_body = out.string |
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
#!/usr/bin/python | |
def is_user_good_enough(username): | |
return False |
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
# config/initializers/squelch_asset_pipeline.rb | |
if Rails.env.development? | |
Rails::Rack::Logger.class_eval do | |
def call_with_quiet_assets(env) | |
previous_level = Rails.logger.level | |
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0 | |
call_without_quiet_assets(env).tap do | |
Rails.logger.level = previous_level | |
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
# Assuming you have high-voltage installed | |
# routes.rb | |
match 'long-blitz-string' => 'pages#forty_two' | |
# app/controllers/pages_controller.rb | |
def forty_two | |
'42' | |
end |