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
#/ Usage: ruby timeout.rb <seconds> -- command arg arg arg | |
timeout, separator, *command = ARGV | |
timeout = timeout.to_f | |
if timeout <= 0.0 || separator != '--' || command.empty? | |
system "cat #$0 | grep ^#/ | cut -c4-" | |
exit 1 | |
end | |
trap(:CHLD) { exit 0 } |
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
source 'https://rubygems.org' | |
# Graph memory use. | |
gem 'stripmem' | |
gem 'typhoeus', :git => 'https://github.com/spraints/typhoeus', :ref => 'stream' | |
gem 'ethon', :git => 'https://github.com/spraints/ethon', :ref => 'streaming' | |
gem 'em-http-request' |
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
worker_pool 6 | |
queue '*' | |
before_fork do | |
require File.expand_path('config/environment') | |
Rails.application.eager_load! | |
ActiveRecord::Base.connection.disconnect! | |
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
# add this to app/controllers/application_controller.rb: | |
def cache | |
options = { | |
'no-store' => 'no-store', | |
'no-cache' => 'no-cache', | |
'zero-age' => 'max-age=0', | |
} | |
if cc = options[params[:id]] | |
headers['Cache-Control'] = cc | |
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
require 'multi_json' | |
require 'stringio' | |
require 'zlib' | |
def gz(infile) | |
outfile = infile + '.gz' | |
File.open(outfile, 'w') do |f| | |
f << `gzip -9 -c #{infile}` | |
end | |
outfile |
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
20:09:53 (0) [master] >>> cat | |
] | |
== | |
]]]]] | |
^[[B\\\\=] | |
\\\\=] | |
'[ | |
'\\'\\\\ | |
'\\;'[-0kkkkkkkkkk[i-k-=k;/. \\m['''' |
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 | |
# Make sure sudoing works first, because tcpdump is going in the background | |
sudo -p "Root privileges are required in order to run tcpdump. Password: " test | |
pcap=$TMPDIR/nethog.$$.pcap | |
# 10.0.1.1 is my LAN's AirPort Extreme, so it gets lots of backup traffic. | |
sudo tcpdump -i en0 -w $pcap not host 10.0.1.1 >&/dev/null & | |
tcpdump_pid=$! |
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
def a | |
[1,2,3].each do |x| | |
return :a if x == 2 | |
end | |
:not_a | |
end | |
def a2 | |
block = lambda { |x| return :a if x == 2 } | |
[1,2,3].each(&block) |
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
original: | |
T1 ----- T2 ----- T3 ----- T4 | |
\ | |
----- G1 ----- G2 | |
after rcheckin, how it works now: | |
T1 ----- T2 ----- T3 ----- T4 ----- G1' ----- G2' |