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
var entries = $$("div[data-entryid]"); | |
var ids = extract_ids(entries); | |
streets.service("reader").askMarkEntriesAsRead(ids); |
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 'benchmark/ips' | |
require 'lotus/utils/string' | |
simple = Lotus::Utils::String.new("Lotus") | |
alternate = Lotus::Utils::String.new("Lotus::(Utils|App)") | |
Benchmark.ips do |x| | |
x.report "simple" do | |
simple.tokenize {} | |
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
require 'benchmark/ips' | |
Benchmark.ips do |x| | |
x.report "hash simple" do | |
Hash[:foo, 1, :bar, 2] | |
end | |
x.report "hash splat" do | |
Hash[*[:foo, 1, :bar, 2]] | |
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
require 'benchmark/ips' | |
require 'lotus/entity' | |
def attributes_for(times) | |
times.times.map { |i| :"field#{i}" } | |
end | |
def hash_for(times) | |
Hash[times.times.map { |i| [:"field#{i}", i] }] | |
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
def extract_log(dir) | |
`(cd #{dir} && git log --oneline --shortstat --pretty=format:%aE)` | |
end | |
def extract_stats(log_string) | |
log_string.split(/\n\n/).map do |log_entry| | |
StatEntry.new log_entry | |
end | |
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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
require_relative 'setup' | |
run "Loading ONE user object" do |x| | |
x.expect { |user| user.name == 'name 1' } | |
x.report("AR") { ARUser.by_name('name 1').first } | |
x.report("ROM") { users.by_name('name 1').first } | |
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
require 'set' | |
require 'benchmark/ips' | |
KEYS = (:a .. :z).to_a | |
SET = Set.new(KEYS) | |
HASH = Hash[KEYS.product([true])] | |
Benchmark.ips do |x| | |
x.report "set.include" do | |
SET.include?(:z) | |
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
require 'allocation_tracer' | |
ObjectSpace::AllocationTracer.setup(%i{path line type}) | |
ObjectSpace::AllocationTracer.trace | |
at_exit{ | |
results = ObjectSpace::AllocationTracer.stop | |
sum = Hash.new { |hash, key| hash[key] = [0] * 6 } | |
puts ObjectSpace::AllocationTracer.header.join("\t") | |
results.sort_by{|k, v| v[0]}.each{|k, v| | |
path, line, type = k |
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 'minitest/spec' | |
require 'minitest/autorun' | |
require 'ostruct' | |
describe "Failure" do | |
it "fails with value" do | |
data = OpenStruct.new(:value => "bar") | |
assert_equal "bar", data.value | |
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
# apt-get install crystal | |
Reading package lists... Done | |
Building dependency tree | |
Reading state information... Done | |
E: Unable to locate package crystal |
OlderNewer