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/ruby | |
require 'rubygems' | |
require 'mq' | |
EM.run { | |
amq = MQ.new | |
amq.topic('evp-started') | |
amq.topic('evp-stopped') |
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
Digest::SHA1.hexdigest(`/sbin/ip route get 8.8.8.8`.split("\n")[0].split.last) |
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 ApplicationController < ActionController::Base | |
helper :all # include all helpers, all the time | |
protect_from_forgery # See ActionController::RequestForgeryProtection for details | |
# Scrub sensitive parameters from your log | |
# filter_parameter_logging :password | |
protected | |
# | |
def forward_action(action_name) |
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
# Ubuntu upstart file at /etc/init/mongodb.conf | |
start on runlevel [2345] | |
stop on runlevel [06] | |
exec /usr/local/mongodb/bin/mongod --config /usr/local/mongodb/mongod.conf |
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
#!/bin/bash | |
# basic amazon s3 operations | |
# Licensed under the terms of the GNU GPL v2 | |
# Copyright 2007 Victor Lowther <[email protected]> | |
# print a message and bail | |
die() { | |
echo $* | |
exit 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
EM.run { | |
wq = EM::WorkQueue.new(10) | |
rqueue = [] | |
push_loop = proc { | |
wq.push do |sig| | |
rqueue << 1 | |
EM.add_timer(rand(10) / 100.0){ | |
sig.return | |
} | |
end if !wq.closed? |
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
# Run 10 times at most. | |
# % retry 10 echo "xxx" | |
# | |
# Run multiple lines of command in here document. | |
# % retry 10 <<'_END_' | |
# echo 1 | |
# echo 2 | |
# _END_ | |
function retry { |
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
#!/bin/sh | |
# This script converts HUP signal from parent shell to TERM signal. | |
# Terminate the running process which can not be halted with HUP (closing at a GNU screen window). | |
# Usage: | |
# hup2term.sh /usr/sbin/nginx -g \'daemon off\;\' | |
trap 'kill -TERM $wpid;' 1 | |
echo "$*" |
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 StateTrack | |
def initialize | |
@state = :initialized | |
end | |
# Expected state transition: | |
# :initialized -> :starting -> :running -> :shuttingdown -> :terminated | |
def process_event(ev, *args) | |
case [ev, @state] | |
when [:on_start, :initialized] |
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 ApplicationController < ActionController::Base | |
protect_from_forgery | |
protected | |
def local_session | |
session[params[:controller].to_s] ||= {} | |
end | |
def reset_local_session | |
session.delete(params[:controller].to_s) |
OlderNewer