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
// Install packages: | |
// npm install mongodb async | |
// Add index in mongo: | |
// db.ensureIndex('mycollection', { rand: 1 }) | |
var mongodb = require('mongodb') | |
var async = require('async') | |
// Find n random documents by using "rand" field. |
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
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -wKU | |
require "#{ENV["TM_SUPPORT_PATH"]}/lib/escape" | |
require "#{ENV['TM_SUPPORT_PATH']}/lib/tm/save_current_document" | |
require "#{ENV["TM_SUPPORT_PATH"]}/lib/tm/executor" | |
TextMate.save_if_untitled('cs') | |
TextMate::Executor.run(e_sh(ENV['TM_NODEJS'] || 'node'), ENV['TM_FILEPATH']) do |str, type| | |
if type == :err | |
if str =~ / | |
( ^ .* \b at \b .* \( ) |
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
namespace :deploy do | |
after :restart, :restart_passenger do | |
on roles(:web), in: :groups, limit: 3, wait: 10 do | |
within release_path do | |
execute :touch, 'tmp/restart.txt' | |
end | |
end | |
end | |
after :finishing, 'deploy:restart_passenger' | |
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
#define ASYNC(what) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ what }) | |
#define MAIN_ASYNC(what) dispatch_async(dispatch_get_main_queue(), ^{ what }) |