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
# members_controller.rb | |
class MembersController < ApplicationController | |
def destroy | |
if !checkadmin? then return end | |
@member = Member.find(params[:id]) | |
@member.destroy | |
respond_to do |format| | |
format.html { redirect_to members_url } | |
format.json { head :no_content } |
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
class Post | |
def initialize(title, body) | |
@title, @body = title, body | |
end | |
def render | |
<<-EOS | |
<article> | |
<h1>#{@title}</h1> | |
<p>#{@body}</p> |
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
require 'benchmark' | |
def normal_selector(array, word) | |
array.select{|hash| hash[:name].match "#{word}"}.to_a | |
end | |
def lazy_selector(array, word) | |
array.lazy.select{|hash| hash[:name].match "#{word}"}.to_a | |
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
require 'benchmark' | |
def each_commit(size) | |
project = Project.create!(name: "each_commit #{size}") | |
size.times.with_index(1) do |_, index| | |
project.tasks.create!(name: "Task #{index}") | |
end | |
end | |
def transaction(size) |
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
require 'benchmark' | |
require 'mongo' | |
def generate_parts(size) | |
area_patterns = [['main'], ['sub'], ['header', 'footer']] | |
enable_patterns = [true, false] | |
level_patterns = ['/level1', '/level1/level2', '/level1/level2/level3'] | |
(1..size).map do |n| | |
{ |
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
class ProjectsController < ApplicationController | |
def index | |
@projects = Project.all | |
end | |
def show | |
@project = Project.find(params[:id]) | |
end | |
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
source 'https://rubygems.org' | |
gem 'rails', '4.1.7' | |
gem 'pg', group: :production | |
gem 'rails_12factor', group: :production | |
gem 'uglifier', '>= 1.3.0' | |
gem 'jbuilder', '~> 2.0' | |
gem 'enumerize' | |
gem 'inherited_resources' |
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
require 'ruby-jmeter' | |
test name: 'JMX Sample' do | |
threads count: 5, loops: 5 do | |
cookies | |
visit name: 'Login Page', url: 'http://0.0.0.0:3000/users/sign_in' do | |
extract name: 'csrf-token', xpath: "//meta[@name='csrf-token']/@content", tolerant: true | |
extract name: 'csrf-param', xpath: "//meta[@name='csrf-param']/@content", tolerant: true | |
end | |
http_header_manager name: 'X-CSRF-Token', value: '${csrf-token}' |
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
# Rails 3.2.13以前のバージョン + Ruby2.0の組み合わせだと適切にDirectiveをパースできない不具合がある | |
# ref: https://github.com/sstephenson/sprockets/issues/352 | |
directive_pattern = / | |
^ \W* = \s* (\w+.*?) (\*\/)? $ | |
/x | |
Sprockets::DirectiveProcessor.class_eval do | |
remove_const(:DIRECTIVE_PATTERN) | |
const_set(:DIRECTIVE_PATTERN, directive_pattern) | |
def directives |