Skip to content

Instantly share code, notes, and snippets.

View jnewland's full-sized avatar

Jesse Newland jnewland

View GitHub Profile
# Package Maintainer: Increment phusion_release to match latest release available
%define phusion_release 20090928
Summary: Ruby Enterprise Edition (Release %{phusion_release})
Name: ruby-enterprise
Vendor: Phusion.nl
Packager: Adam Vollrath <[email protected]>
Version: 1.8.7
Release: 1%{dist}
License: GPL
# git cheat sheet. Pretty much all you need. Corrections to @troyd, credit to @lindvall
# settings
git config --global branch.autosetupmerge true
git config --global push.default current
# create new branch locally
git checkout -b prove-brooks-law-42
# then on remote server
# (requires http://git-wt-commit.rubyforge.org/git-publish-branch in path)
RAILS_ENV=production ruby -r/tmp/require_tracking.rb -e "require 'config/environment'"
Memory used by file:
File KB
------------- --------
config/environment: 209,623
/srv/myapp/releases/20091230003757/app/models/user: 73,653
/srv/myapp/releases/20091230003757/app/models/store: 70,962
./config/boot: 15,021
/srv/myapp/releases/20091230003757/app/models/discount_code: 9,813
/srv/myapp/releases/20091230003757/app/models/order: 9,390
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')
# 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
@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}..'
# 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:
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.
#
# 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
@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/*"]