Skip to content

Instantly share code, notes, and snippets.

View mirek's full-sized avatar
💭
kiss & software craftsmanship

Mirek Rusin mirek

💭
kiss & software craftsmanship
View GitHub Profile
@mirek
mirek / find-and-refresh-rand.js
Created November 19, 2014 21:04
Find random document in MongoDB collection.
// 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.
@mirek
mirek / .rb
Last active December 27, 2015 11:29
nodejs textmate 2 run command
#!/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 .* \( )
@mirek
mirek / passenger.rake
Last active April 3, 2018 12:05
Passenger restart task in Capistrano 3.x with Rails 4.x
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
@mirek
mirek / Async macros
Created June 22, 2010 18:08
GDC async macros (C/C++/Objective-C)
#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 })