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
| Calculating ------------------------------------- | |
| each_char 924.000 i/100ms | |
| each_codepoint 1.381k i/100ms | |
| ------------------------------------------------- | |
| each_char 9.320k (± 5.1%) i/s - 47.124k | |
| each_codepoint 13.857k (± 3.6%) i/s - 70.431k | |
| Comparison: | |
| each_codepoint: 13857.4 i/s | |
| each_char: 9319.5 i/s - 1.49x slower |
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/ips' | |
| Benchmark.ips do |x| | |
| x.report "nothing" do | |
| [1, 2, 3] | |
| end | |
| x.report "#-" do | |
| [1, 2, 3] - [3] | |
| 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
| class Array | |
| def to_proc | |
| ->(obj) { obj[first] } | |
| end unless method_defined?(:to_proc) | |
| end | |
| users = [ | |
| {name: "Matz"}, | |
| {name: "DHH"}, | |
| {name: "Yuki"} |
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/ips' | |
| Benchmark.ips do |x| | |
| NEGATIVE = "-1" | |
| ZERO = "0" | |
| ONE = "1" | |
| TWO = "2" | |
| x.report("Array#max ( -1)") { [NEGATIVE.to_i, 1].max - 1 } | |
| x.report("Array#max ( 0)") { [ ZERO.to_i, 1].max - 1 } |
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 ApplicationController < ActionController::Base | |
| before_filter :override_request_formats | |
| def override_request_formats | |
| request.formats = [:json] | |
| 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
| log/ |
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 BaseNotifier < ActivePush::Base | |
| self.notifier_name = "base_notifier" | |
| default gcm: {collapse_key: '...', delay_while_idle: false}, | |
| wp: { | |
| message_id: 'message id', | |
| notification_class: 'notification class', | |
| windowsphone_target: 'target' | |
| } |
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
| alias gti="git" | |
| alias gst="git status" | |
| alias gbr="git branch" | |
| alias glg="git log" | |
| alias gfu="git fetch upstream" | |
| alias gfo="git fetch origin" | |
| alias gpo="git push origin" | |
| alias gpu="git push upstream" |
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
| BRANCH=0.16-stable; M=`git log --pretty=format:'%s' master | sort`; B=`git log --pretty=format:'%s' $BRANCH | sort`; diff <(echo "${MASTER}") <(echo "${B}") | grep "^>" |
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
| # config/application.rb | |
| config.exceptions_app = ->(env) { ErrorsController.action(:show).call(env) } |