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' | |
n = 1_000_000 | |
Benchmark.bm do |x| | |
x.report('[[1]]') { n.times { [[1]].flatten } } | |
x.report('Array([1])') { n.times { Array([1]) } } | |
x.report('[1]') { n.times { [1].flatten } } | |
x.report('Array(1)') { n.times { Array(1) } } | |
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' | |
# Benchmarking Array#compact & Array#join | |
n = 1_000_000 | |
Benchmark.bm do |x| | |
x.report('3 elements + nil') { n.times { ['a', 'b', 'c', nil].compact.join('::') } } | |
x.report('3 elements') { n.times { ['a', 'b', 'c'].compact.join('::') } } | |
end | |
# user system total real |
This file has been truncated, but you can view the full file.
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
4 processes for 77 specs, ~ 19 specs per process | |
.....DEPRECATION WARNING: Active Admin: ActiveAdmin.default_namespace is deprecated. Please use ActiveAdmin.application.default_namespace. (called from block (3 levels) in <top (required)> at /Users/goshakkk/Projects/active_admin/spec/unit/active_admin_spec.rb:8) | |
.............................................................................Running JSLint: | |
......................***** | |
No JS errors found. | |
..............................DEPRECATION WARNING: ActiveAdmin::Dashboard is deprecated and will be removed in the next version | |
...........................................................................................................................F*.....................................................*.........................................................................................*..*.......*............................................................*......... | |
Pending: |
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
i = Injector.new first: 'First Name', last: 'Last Name', power: 2 | |
def full_name(first, last) | |
"#{first} #{last}" | |
end | |
def random_to_power(power) | |
4 ** power | |
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
# Doing this | |
def a(&block) | |
block.call if block_given? | |
end | |
a { p 1 } | |
# is equivalent to doing this | |
def b | |
proc.call if block_given? |
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
# with current DSL | |
folder '~/Downloads' do | |
kind 'Movie' do | |
downloaded_from %r{destroyallsoftware} do | |
# do stuff | |
end | |
end | |
end | |
# with better matching DSL & label matcher |
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 'formula' | |
class ErlangInstalled < Requirement | |
def message; <<-EOS.undent | |
Erlang is required to install. | |
You can install this with: | |
brew install erlang | |
Or you can use an official installer from: |
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
dynamo_demo(master)$ mix iex | |
Interactive Elixir (0.7.0.dev) - press Ctrl+C to exit | |
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false] [dtrace] | |
iex(1)> System.build_info | |
{"0.7.0.dev","fatal: Not a git repository (or any of the parent directories): .git","Tue, 21 Aug 2012 21:29:41 GMT"} | |
iex(2)> |
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
dynamo_demo(master)$ mix do clean, iex | |
Compiled lib/dynamo_demo.ex | |
Compiled lib/dynamo_demo/app.ex | |
Generated dynamo_demo.app | |
Interactive Elixir (0.7.0.dev) - press Ctrl+C to exit | |
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false] [dtrace] | |
iex(1)> DynamoDemo.start | |
Running DynamoDemo.App on port 3000 with Cowboy | |
:ok |
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
# When compiled with `NODE_ENV=production PUSHER_APP_KEY=123abc API_ENDPOINT_HOST=api.app.com brunch build` | |
# the following is produced and included into build. | |
config = {api: {}} | |
config.env = "production" | |
config.pusher_app_key = "123abc" | |
config.api.endpoint = "api.app.com" | |
module.exports = config |