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
Calculating ------------------------------------- | |
keys.index 1794 i/100ms | |
has_key? 1822 i/100ms | |
------------------------------------------------- | |
keys.index 4036912.9 (±10.4%) i/s - 8691930 in 2.275054s | |
has_key? 6605458.9 (±9.1%) i/s - 25340376 in 3.878441s | |
Comparison: | |
has_key?: 6605458.9 i/s | |
keys.index: 4036912.9 i/s - 1.64x slower |
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 api_request(action, params = {}) | |
Rails.logger.info "Started request #{host_root} action: #{action}" | |
# Rails.logger.info " Params: #{params.inspect}" | |
t1 = Time.now | |
n = 0 | |
begin | |
res = Faraday.post do |req| | |
req.url "http://api.kanbox.com" | |
req.body = Kanbox::Param.parse(action, params) | |
req.options[:open_timeout] = 30 |
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
## Before | |
user system total real | |
Index 1,000 items 2.160000 0.820000 2.980000 ( 4.633564) | |
## After (0.9.6) | |
user system total real | |
Index 1,000 items 0.780000 0.070000 0.850000 ( 0.851309) |
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' | |
total_times = 30000 | |
items1 = [] | |
items2 = [] | |
items3 = [] | |
Benchmark.bm do |x| | |
x.report("include?") { | |
total_times.times do |i| |
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 'grape' | |
class API < Grape::API | |
before do | |
@log_start_t = Time.now | |
Rails.logger.info " Parameters: #{params.to_hash.except("route_info")}" | |
end | |
after do | |
@log_end_t = Time.now |
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
[ "{*.yml,*.yml.default}" ] | |
fileType = source.yaml | |
[ "{Capfile,Gemfile,Gemfile.lock,Guardfile}" ] | |
fileType = source.ruby | |
[ *_spec.rb ] | |
fileType = source.ruby.rspec | |
[ "{app/{models,controllers,mailers,helpers,cells,uploaders}/**/*.rb,*_controller.rb,*_helper.rb,*_mailer.rb}" ] |
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
#!/bin/bash | |
# | |
# god Startup script for god (http://god.rubyforge.org) | |
# | |
# chkconfig: - 85 15 | |
# description: God is an easy to configure, easy to extend monitoring \ | |
# framework written in Ruby. | |
# | |
CONF=/usr/local/etc/god.rb |
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 "fileutils" | |
root_dir = "/Users/jason/Downloads/images" | |
Dir.chdir(root_dir) | |
puts Dir.pwd | |
Dir.glob("**/*.{jpg}").each do |fname| | |
tfname = fname.split("/").last | |
if fname.match("[small|large|normal]_") | |
tfname = fname.split("_").last | |
end | |
p1,p2 = tfname[0,1],tfname[1,1] |
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
GIT=/usr/bin/git | |
INFO_PLIST=$BUILT_PRODUCTS_DIR/$WRAPPER_NAME/Contents/Info.plist | |
BUILD_SUFIX="" | |
if [ $CONFIGURATION == Debug ] | |
then | |
BUILD_SUFIX="D" | |
fi |
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
#!/bin/bash | |
mv "$1" "old_$1" | |
cat <( sqlite3 "old_$1" .dump | grep "^ROLLBACK" -v ) <( echo "COMMIT;" ) | sqlite3 "$1" |