Skip to content

Instantly share code, notes, and snippets.

View nviennot's full-sized avatar

Nicolas Viennot nviennot

View GitHub Profile
pafy@bisou ~ % schedtool -h
get/set scheduling policies - v1.3.0, GPL'd, NO WARRANTY
USAGE: schedtool PIDS - query PIDS
schedtool [OPTIONS] PIDS - set PIDS
schedtool [OPTIONS] -e COMMAND - exec COMMAND
set scheduling policies:
-N for SCHED_NORMAL
-F -p PRIO for SCHED_FIFO only as root
-R -p PRIO for SCHED_RR only as root
#!/usr/bin/env ruby
require 'rethinkdb'
include RethinkDB::Shortcuts
c = r.connect(:host => 'localhost', :port => 28015, :db => 'db').repl
100.times do
r.db_drop('db').run(c) rescue nil
r.db_create('db').run(c)
r.table_create('table').run(c)
#!/usr/bin/env ruby
require 'rethinkdb'
include RethinkDB::Shortcuts
10.times.map do |i|
Thread.new do
begin
db = i.to_s
c = r.connect(:host => 'localhost', :port => 28015, :db => db).repl
100.times do
#
# Cookbook Name:: redis
# Recipe:: _server_install_from_source
include_recipe "build-essential"
redis_source_tarball = "redis-#{node.redis.source.version}.tar.gz"
redis_source_url = "#{node.redis.source.url}/#{redis_source_tarball}"
user node.redis.user
Signal.trap 'SIGUSR2' do
# Using a thread because we cannot acquire mutexes in a trap context in
# ruby 2.0
Thread.new do
Thread.list.each do |thread|
next if Thread.current == thread
puts '----[ Threads ]----' + '-' * (100-19)
if thread.backtrace
puts "Thread #{thread} #{thread['label']}"
def controller_action
center = some_point
models = Model.where(:location.near => {:point => center :max_distance => 100})
render :json => models.map { |m| :distance => SomeGeoGem.distance(m.location, center), :name => m.name }
end
def synchronize
begin
lock
rescue Recovered
# don't care
end
begin
block.call
ensure
#!/usr/bin/env ruby
require 'optparse'
require 'fileutils'
####################
# Global vars
####################
$skip_upload=false
$skip_screenshot=false
#!/usr/bin/env ruby
# `Gemfile` should have the following:
# source 'https://rubygems.org'
# gem 'goliath'
# gem 'nobrainer', :github => 'nviennot/nobrainer'
require 'bundler'
Bundler.require
# NoBrainer configuration.
require 'bundler'
Bundler.require
NoBrainer.configure do |config|
config.app_name = 'test'
config.environment = 'dev'
config.logger = Logger.new(STDERR).tap { |l| l.level = Logger::DEBUG }
end
NoBrainer.drop!