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
document.body.addEventListener('DOMSubtreeModified', function(e) { console.log(e.target); }); |
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
mysqldump DB -hHOST > OUTFILE.sql | |
# copy to local | |
rsync -avPz --progress USER@HOST:/PATH/TO/OUTFILE.sql . | |
# import to local db | |
mysql -uroot -p -DDATABASE < OUTFILE.sql |
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
# Gemfile | |
gem 'ruby-prof' | |
# code to profile | |
require 'ruby-prof' | |
RubyProf.start | |
# run code | |
result = RubyProf.stop | |
printer = RubyProf::CallStackPrinter.new(result) |
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
# this is ugly and terrible, don't do this | |
module ActiveRecord | |
module ConnectionAdapters | |
class TableDefinition | |
def column(name, type, options = {}) | |
name = name.to_s | |
type = type.to_sym | |
column = self[name] || new_column_definition(@base, name, type) |
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
/** | |
* Builder pattern for factories, mimic use of FactoryGirl traits. | |
* usage: factories.boostedBoost({retweets: 1}).twitter().withdrawn().geo(11217).generate(); | |
* must call `generate` as last step | |
* may pass options to initial method call, as well as subsequent method calls | |
*/ | |
function addFactory(factoryName, config) { | |
// add trait function to generated Factory | |
function addTrait(k, Factory, config) { | |
Factory.prototype[k] = function() { |
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
Benchmarking 127.0.0.1 (be patient) | |
Finished 450 requests | |
Server Software: | |
Server Hostname: 127.0.0.1 | |
Server Port: 3080 | |
Document Path: /api/v1/users/1/cabinets/1/drinks | |
Document Length: 801 bytes |
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
Benchmarking 127.0.0.1 (be patient) | |
Finished 199 requests | |
Server Software: | |
Server Hostname: 127.0.0.1 | |
Server Port: 3080 | |
Document Path: /api/v1/users/1/cabinets/1/drinks | |
Document Length: 801 bytes |
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
Benchmarking 127.0.0.1 (be patient) | |
Finished 390 requests | |
Server Software: thin | |
Server Hostname: 127.0.0.1 | |
Server Port: 3080 | |
Document Path: /api/v1/users/1/cabinets/1/drinks | |
Document Length: 801 bytes |
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
Benchmarking 127.0.0.1 (be patient) | |
Finished 448 requests | |
Server Software: WEBrick/1.3.1 | |
Server Hostname: 127.0.0.1 | |
Server Port: 3080 | |
Document Path: /api/v1/users/1/cabinets/1/drinks | |
Document Length: 801 bytes |
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
class Array | |
def take_select n, &block | |
count = 0 | |
res = [] | |
select do |x| | |
r = yield x | |
if r == true | |
count += 1 | |
res << x | |
end |