Skip to content

Instantly share code, notes, and snippets.

@evanphx
evanphx / page.html
Created February 6, 2016 04:20
Weird TWC page
veritas :: vk-git/valar-client> curl -L http://www.google.com
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>Road Runner</title>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<meta content="MSHTML 6.00.2800.1400" name="GENERATOR" />
package log
import "github.com/Sirupsen/logrus"
func InfoK(str string, args ...interface{}) {
f := logrus.Fields{}
for i := 0; i < len(args); i += 2 {
f[args[i].(string)] = args[i+1]
}
require 'json'
class SRailsLogger < SLogger
def emit(opts)
Rails.logger.info JSON.generate(opts)
end
end
SLog = SRailsLogger.new
@evanphx
evanphx / log.rb
Created October 20, 2015 16:28
Structured Logging
require 'json'
class SLogger
def log(event, opts={})
opts[:event] = event.to_s
emit opts
end
def emit(opts)
$stdout.puts JSON.generate(opts)
@evanphx
evanphx / watch_your_back.go
Last active October 5, 2015 22:58
defensive golang channels
select {
case b := <-i.c:
buf.Write(i.header)
buf.Write(nl)
buf.Write(b)
buf.Write(nl)
if buf.Len() > i.Config.FlushThreshold {
flush = true
}
@evanphx
evanphx / gist:acd8681743a2e31d1116
Created September 30, 2015 19:56
fastly logplex log shuttle
<134>2015-09-30T19:46:44Z cache-sjc3131 test-ls[447241]: 108.185.218.101 "-" "-" Wed, 30 Sep 2015 19:46:44 GMT GET / 200
<134>2015-09-30T19:46:44Z cache-sjc3128 test-ls[447241]: 108.185.218.101 "-" "-" Wed, 30 Sep 2015 19:46:44 GMT GET /sponsors.png 304
@evanphx
evanphx / check
Last active September 10, 2015 16:52
Check code
root@ip-172-20-0-217:~# iptables -t nat -C POSTROUTING ! -d 10.0.0.0/8 -m addrtype ! --dst-type LOCAL -j MASQUERADE
iptables: No chain/target/match by that name.
root@ip-172-20-0-217:~# echo $?
1
52.28.77.117$ kill -SUSPEND $consul
52.88.80.220$ curl localhost:8500/v1/kv/hello
members = [
"Evan Phoenix",
"Adam Keys",
"Jeff Casimir",
"Chris Morris",
"Ben Scofield",
"Abby Phoenix",
"Marty Haught",
"Andrew Thorp",
"Dave Sims",
(query (find "a" 1) (find "b" 2) (take 10))