Skip to content

Instantly share code, notes, and snippets.

View textgoeshere's full-sized avatar

Dave Nolan textgoeshere

View GitHub Profile
@textgoeshere
textgoeshere / splitter example conf
Created October 4, 2012 13:49
basic nginx conf for continuous experimentation
upstream _a {
server 127.0.0.1:8000;
}
upstream _b {
server 127.0.0.1:8001;
}
upstream _c {
server 127.0.0.1:8002;
port = lambda do |env|
body = "Hello from variant #{ENV['VARIANT']} on #{env['SERVER_NAME']}:#{env['SERVER_PORT']} at #{env['HTTP_X_TIME']}"
[200, {"Content-Type" => "text/html"}, [body]]
end
run port
@textgoeshere
textgoeshere / request_start_variable.patch
Created August 20, 2012 04:29 — forked from rkbodenner/request_start_variable.patch
Add a 'start_time' variable to nginx 0.8.33 to support an X-REQUEST-START header. This header is used by New Relic RPM to record queue time.
--- src/http/ngx_http_variables.c.orig 2010-01-11 03:21:46.000000000 -0800
+++ src/http/ngx_http_variables.c 2010-02-18 10:01:32.000000000 -0800
@@ -93,6 +93,9 @@
static ngx_int_t ngx_http_variable_pid(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
+static ngx_int_t ngx_http_variable_start_time(ngx_http_request_t *r,
+ ngx_http_variable_value_t *v, uintptr_t data);
+
/*
@textgoeshere
textgoeshere / graphline.sh
Created July 20, 2012 14:36 — forked from mrtazz/graphline.sh
shell function to quickly check a graphite graph
#
# shell function to print graphite graphs as sparklines in the terminal
# needs https://github.com/holman/spark
#
function graphline() {
GRAPHITEHOST="graphite.example.com"
if [ ! -n "$1" ]; then print "Usage: $0 metric [minutes]"; return 1; fi
if [ ! -n "$2" ]; then MINUTES=10 ; else MINUTES=$2; fi
curl -s "${GRAPHITEHOST}/render?from=-${MINUTES}minutes&target=${1}&format=raw" | cut -d"|" -f 2 | spark ;
}
@textgoeshere
textgoeshere / grr
Created October 4, 2011 21:31
quick and dirty script to "growl" notify outcome of long-running command
#!/bin/bash
# create an array from the params
declare -a CMD=($*)
# execute the command given by the params
${CMD[@]}
# notify the outcome given by the exit code
if [ $? == 0 ]
then
notify-send "${CMD[0]} passed" -i gtk-dialog-info
@textgoeshere
textgoeshere / script.js
Created July 13, 2011 09:45
console killer
if (typeof window.console == "undefined") {
if (!window.console || !console.firebug)
{
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
window.console = {};
for (var i = 0; i < names.length; ++i)
window.console[names[i]] = function() {}
}
module Firebug
VERSION = "1.6.2"
end
Capybara.register_driver :selenium_with_firebug do |app|
require 'selenium/webdriver'
profile = Selenium::WebDriver::Firefox::Profile.new
profile.add_extension("spec/support/firebug-#{Firebug::VERSION}.xpi")
@textgoeshere
textgoeshere / 1.8.7@rails2
Created June 21, 2011 14:53
Ruby 1.9.2@rails3 is 8x slower than 1.8.7@rails2
Using /home/dave/.rvm/gems/ruby-1.8.7-p334 with gemset rails2-3-10
$ time spec spec/views/people/_header.haml_spec.rb
No server is running
Running specs locally:
......
Finished in 1.522537 seconds
6 examples, 0 failures
# Force backtraces from Thin to output to STDERR
# workaround for http://stackoverflow.com/questions/4627928/get-rails-exceptions-to-show-using-capybara-and-selenium
module Thin::Logging
def log_error(e=$!)
STDERR.print "#{e}\n\t" + e.backtrace.join("\n\t")
end
end
#!/bin/sh
echo "adding xPUD 0.9.2" >&2
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry "xPUD 0.9.2" {
set isofile="/boot/iso/xpud-0.9.2.iso"
loopback loop (hd0,1)$isofile