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
#188s | |
(0..10000).each do | |
document1.sub_documents << document2 | |
end | |
#119s | |
(0..10000).each do | |
document1.push(:sub_document_ids, document2._id) | |
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
JSON.pretty_generate(JSON.parse(obj.to_json)) |
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
{ | |
"auto_complete": false, | |
"auto_match_enabled": false, | |
"bold_folder_labels": true, | |
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme", | |
"drag_text": false, | |
"draw_white_space": "selection", | |
"fold_buttons": false, | |
"font_face": "M+ 1M thin", | |
"font_size": 16.0, |
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
1xx Informational | |
100 Continue :continue | |
101 Switching Protocols :switching_protocols | |
102 Processing :processing | |
2xx Success | |
200 OK :ok | |
201 Created :created | |
202 Accepted :accepted | |
203 Non-Authoritative Information :non_authoritative_information |
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
defaults write com.apple.Dock autohide-delay -float 0 && killall Dock |
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' | |
first_name = "first" | |
last_name = "last" | |
Benchmark.bm do |x| | |
x.report { 100000.times do; "#{first_name} #{last_name}" ; end; } | |
x.report { 100000.times do; [first_name, last_name].join(' ') ; end; } | |
x.report { 100000.times do; '%s %s' % [first_name, last_name] ; end; } | |
x.report { 100000.times do; first_name + ' ' + last_name ; 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
s = %Q{ | |
Maximum connect burst length: 1 | |
Total: connections 20000 requests 20000 replies 20000 test-duration 592.676 s | |
Connection rate: 33.7 conn/s (29.6 ms/conn, <=1 concurrent connections) | |
Connection time [ms]: min 10.8 avg 29.6 max 11652.5 median 11.5 stddev 217.1 | |
Connection time [ms]: connect 27.6 | |
Connection length [replies/conn]: 1.000 |
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 'json' | |
require 'yajl' | |
data = '' | |
f = File.open("test.json", "r") | |
f.each_line do |line| | |
data += line | |
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
#To see how many models in a Rails project are not using attr_accessible: | |
$find app/models -type f -name \*.rb | wc -l | |
$grep -r -m1 "attr_accessible app/models | wc -l |
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 'ipaddr' | |
require 'benchmark' | |
def iptoint1(ip) | |
IPAddr.new(ip, Socket::AF_INET).to_i | |
end | |
def iptoint2(ip) | |
if (ip.kind_of?(String) && | |
ip =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)\.([0-9]+)$/) |