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
#!/usr/bin/env ruby | |
require 'timeout' | |
members = %w(Gatis Jānis Anna Ilze Ieva Kaspars Juris Klāvs Pēteris) | |
takers = [] | |
givers = [] | |
exceptions = { 'Gatis' => 'Jānis'} | |
begin | |
Timeout::timeout(2) do |
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
location @web { | |
proxy_redirect off; | |
proxy_set_header X-FORWARDED_PROTO http; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_pass http://web; | |
} |
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
rails_env = ENV['RAILS_ENV'] || 'development' | |
rails_root = File.expand_path("../", File.dirname(__FILE__)) | |
# threads | |
threads 0,1 | |
# workers | |
case rails_env | |
when 'staging' | |
workers 1 |
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
#!/usr/bin/env bash | |
apt-get -y update | |
apt-get -y upgrade | |
apt-get -y install build-essential zlib1g-dev libssl-dev libreadline-gplv2-dev libyaml-dev libffi-dev | |
apt-get -y install autoconf curl git-core bzip2 | |
apt-get -y autoremove | |
apt-get -y clean | |
cd /usr/local/src | |
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.gz | |
tar -xvzf ruby-2.0.0-p247.tar.gz |
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
check process resque-worker-production | |
with pidfile /home/webmaster/production/shared/pids/resque_worker.pid | |
start program = "/usr/bin/env HOME=/home/webmaster PATH=/usr/local/bin:/usr/local/ruby/bin:/usr/bin:/bin:$PATH /bin/sh -l -c 'cd /home/webmaster/production/current; nohup bundle exec rake environment resque:work RAILS_ENV=production PIDFILE=/home/webmaster/production/shared/pids/resque_worker.pid >> log/resque_worker.log 2>&1'" as uid webmaster and gid webmaster | |
stop program = "/bin/sh -c 'cd /home/webmaster/production/current && kill $(cat /home/webmaster/production/shared/pids/resque_worker.pid) && rm -f /home/webmaster/production/shared/pids/resque_worker.pid; exit 0;'" | |
if totalmem is greater than 300 MB for 10 cycles then | |
exec "/bin/kill -9 $(cat /home/webmaster/production/shared/pids/resque_worker.pid) && rm -f /home/webmaster/production/shared/pids/resque_worker.pid" | |
if 5 restarts within 5 cycles then timeout | |
group resque_workers | |
check process resque-worker-staging |
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
check process elasticsearch with pidfile /var/run/elasticsearch.pid | |
start program = "/etc/init.d/elasticsearch start" | |
stop program = "/etc/init.d/elasticsearch stop" | |
if 5 restarts within 5 cycles then timeout | |
if failed host 127.0.0.1 port 9200 type http then restart |
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
# used as example https://groups.google.com/d/msg/ruby-capybara/XhDAHGjZSjA/VwiW0-2nOIEJ | |
# IMPORTANT! To do the real simulation you need chrome driver - http://code.google.com/p/selenium/downloads/list, download and add to PATH | |
def tinymce_fill_in name, options = {} | |
if page.driver.browser.browser == :chrome | |
page.driver.browser.switch_to.frame("#{name}_ifr") | |
page.find(:css, '#tinymce').native.send_keys(options[:with]) | |
page.driver.browser.switch_to.default_content | |
else | |
page.execute_script("tinyMCE.get('#{name}').setContent('#{options[:with]}')") | |
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
# Example | |
# mute do | |
# puts "Foo" | |
# end | |
# puts "Bar" | |
# | |
# Only Bar will be printed | |
def mute &block | |
orig_stdout = $stdout | |
$stdout = File.new('/dev/null', 'w') |
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
# LOAD RAILS ENV ... | |
def returning(value) | |
yield(value) | |
value | |
end | |
def convert_hash_to_ordered_hash_and_sort(object, deep = false) | |
# from http://seb.box.re/2010/1/15/deep-hash-ordering-with-ruby-1-8/ | |
if object.is_a?(Hash) |
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).bind('cbox_complete', function(){ | |
$("#cboxTitle").hide(); | |
$("<div>"+$("#cboxTitle").html()+"</div>").css({color: $("#cboxTitle").css('color')}).insertAfter(".cboxPhoto"); | |
$.fn.colorbox.resize(); | |
}); |