Skip to content

Instantly share code, notes, and snippets.

View filterfish's full-sized avatar

Richard Heycock filterfish

View GitHub Profile
### Keybase proof
I hereby claim:
* I am filterfish on github.
* I am filterfish (https://keybase.io/filterfish) on keybase.
* I have a public key whose fingerprint is F5B0 52EC 4A87 7DE1 018F 522A C844 E023 1400 0CBC
To claim this, I am signing this object:
traceroute to <host> (<ip addr>), 30 hops max, 60 byte packets
1 192.168.7.1 (192.168.7.1) 1.130 ms lns20.syd6.on.ii.net (150.101.199.159) 23.889 ms 192.168.7.1 (192.168.7.1) 1.135 ms
2 lns20.syd6.on.ii.net (150.101.199.159) 25.223 ms 26.224 ms 27.827 ms
3 xe-0-0-1.cr1.syd4.on.ii.net (150.101.195.138) 29.365 ms 30.807 ms 32.019 ms
4 lns20.syd7.on.ii.net (150.101.195.14) 32.486 ms 33.934 ms 35.337 ms
5 te3-1-120.cor2.syd6.on.ii.net (150.101.199.241) 36.642 ms 37.821 ms 39.470 ms
6 te4-1.cor2.syd6.on.ii.net (150.101.120.226) 40.460 ms 23.936 ms 25.134 ms
7 xe-0-2-1.cr1.syd4.on.ii.net (150.101.197.2) 26.207 ms 26.945 ms 28.618 ms
8 lns20.syd7.on.ii.net (150.101.195.14) 29.774 ms 30.949 ms 31.684 ms
9 te3-1-120.cor2.syd6.on.ii.net (150.101.199.241) 34.049 ms 35.369 ms 36.124 ms
append_if_no_such_line = lambda do |pattern,file,line|
unless Regexp.new(pattern).match(File.read(file))
File.open(file, "a") { |f| f.puts line }
end
end
append_if_no_such_line.call('^net.ipv4.conf.default.proxy_arp', '/etc/sysctl.conf', 'whatever')
#!/usr/bin/env ruby
# Copyright (c) 2006 Bradley Taylor, bradley@fluxura.com
# Modified by Richard Heycock to support thin. rgh@roughage.com.au
require 'optparse'
def run(command, verbose, clean=false)
bin = 'thin'
opts = "--all #{@options[:conf_path]}"
opts += " --clean" if clean
@filterfish
filterfish / Light weight rvm
Created July 16, 2010 00:38
Lightweigh version of rvm.
#!/usr/bin/env ruby
require 'pp'
require 'pathname'
search_paths = ['/usr/local']
Conf_file = "#{ENV['HOME']}/.lrvm"
def write_path(path)
@filterfish
filterfish / gist:1213336
Created September 13, 2011 07:32
jekyll post-receive hook
#!/bin/sh
while read stdin; do
refname=$( echo $stdin | awk '{print $3}')
done
branch=$(basename $refname)
cd ..
env -i git reset --hard $branch
@filterfish
filterfish / pipe-client.rb
Created December 2, 2011 23:55
EventMachine Pipe Clinet/Server
#!/usr/bin/env ruby
require 'pathname'
uri = ARGV[0] || (puts "usage: #{$0} <uri>"; exit 1)
Pathname.new('pipe').open("w") do |fd|
fd.puts(uri)
end
@filterfish
filterfish / README.md
Created June 25, 2012 02:49
Debian Unicorn startup script.

A Debian (or any Debian derivative) start up script for unicorn. You will to change: the name of the /etc/{default,init.d}/unicorn to reflect the name of the application; the lines that check and then source /etc/default/unicorn (lines 5 & 6) and the INIT INFO line: "Provides" & "Short-Description" lines (8 & 13). There should be no reason to change anything anything else in /etc/init.d/unicorn.

h2.Bundler

You might find that bundler just works (unlikely) or (more likely) you will have to fuck around until it does. So if it doesn't work the following:

  • add ruby_path=/bin to /etc/defaults/unicorn
  • sed 's/^DAEMON=.*$/DAEMON=$ruby_path/bundle exec unicorn"

probably will.

@filterfish
filterfish / riemann.clj
Created December 22, 2015 11:38
riemann flapping
(udp-server {:host "::"})
(periodically-expire 1)
(let [index (index)]
(streams
index
(match :service #"^serf"
(changed-state {:init "ok"}
@filterfish
filterfish / riemman-alert.rb
Created December 24, 2015 03:14
riemann flapping — II
require 'riemann/client'
DEFAULT = {:host => 'ch01', :metric => nil, :service => "serf", :ttl => 10}
CLIENT = Riemann::Client.new
def event(e)
CLIENT << DEFAULT.merge(e).tap { |p| puts "#{Time.now} — #{e}" }
end
delay = (ARGV[0] || 2).to_i