Skip to content

Instantly share code, notes, and snippets.

View jnewland's full-sized avatar

Jesse Newland jnewland

View GitHub Profile
@jnewland
jnewland / Gemfile
Created June 6, 2011 22:49
get the latest installed version of a gem without deprecation warnings
source :rubygems
gem 'rspec'
gem 'aruba', :require => 'aruba/api'
gem 'test-construct', :require => 'construct'
{% line_chart value:calls_per_minute regexp:'Database/Redis/[b-z].*' title:'CPM' %}
{% line_chart value:average_value regexp:'Database/Redis/[b-z].*' title:'Average Time' %}
{% line_chart value:max_value regexp:'Database/Redis/[b-z].*' title:'Max Time' %}
{% line_chart value:calls_per_minute regexp:'Database/Redis/allWeb' title:'Redis Web CPM' %}
{% line_chart value:calls_per_minute regexp:'Database/Redis/allOther' title:'Redis Background CPM' %}
@jnewland
jnewland / Capfile
Created August 22, 2010 20:39
execute capistrano commands serially
server 'localhost', :test
server '127.0.0.1', :test2
task :test_serially do
serially do
run 'date && sleep 5'
end
end
def serially(&block)
@jnewland
jnewland / .caprc
Created August 21, 2010 17:44
toss this in your ~/.caprc, then `cap cowboy staging deploy`. Use carefully.
namespace :cowboy do
desc 'Deploy without SCM'
task :default do
deploy_stage = fetch(:stage, 'none')
set :repository, "."
set :deploy_via, :copy
set :scm, :none
set :stage, deploy_stage
set :cowboy_deploy, true
set :copy_exclude, [".git/*", ".svn/*", "log/*", "vendor/bundle/*"]
# estimate the duration of an ALTER TABLE statement in mysql
# this code estimates the worst case, as most of the time, an ALTER will result in a table that is smaller than the original
percentage = 0
interval = 10
while(true) do
begin
sleep(interval)
new_percentage = (File.size('#sql-137f_5dee5a6.ibd')*1.0 / File.size('users.ibd')*1.0)
change = new_percentage - percentage
require 'webrick'
require 'webrick/httpproxy'
require 'fileutils'
require 'md5'
###
# FakeWebRecorder is an HTTP Proxy that records sessions as calls to FakeWeb.
# The code that FakeWebRecorder generates should be suitable for testing
# interaction with a particular website.
#
# Apache2 Status by Hampton Catlin
#
# Free Use Under the MIT License
#
# Please note, your server must respond to "apache2ctl status"
#
class Apache2Status < Scout::Plugin
OPTIONS=<<-EOS
sample_size:
@jnewland
jnewland / .gitconfig
Created January 11, 2010 22:09 — forked from kneath/._what.md
[alias]
up = !sh -c 'git pull && git log --pretty=format:\"%Cred%ae %Creset- %C(yellow)%s %Creset(%ar)\" HEAD@{1}..'
# Requires Cramp 0.8+
require 'rubygems'
require 'usher'
require 'cramp/controller'
Cramp::Controller::Websocket.backend = :thin
class WebsockAction < Cramp::Controller::Websocket
periodic_timer :send_hello_world, :every => 2
on_data :received_data
class JsonHax
def initialize(app)
@app = app
end
def call(env)
if env['CONTENT_TYPE'] == 'application/json'
env['CONTENT_TYPE'] = 'application/xml'
env['REQUEST_URI'].gsub!(/\.json/, '.xml')