Skip to content

Instantly share code, notes, and snippets.

View mguterl's full-sized avatar

Mike Guterl mguterl

View GitHub Profile
#!/bin/bash
echo "Setting up chef..."
sudo apt-get -y update
sudo apt-get -y install ruby ruby1.8-dev libopenssl-ruby1.8 rdoc ri irb build-essential wget ssl-cert
cd /tmp
wget http://rubyforge.org/frs/download.php/57643/rubygems-1.3.6.tgz
tar zxf rubygems-1.3.6.tgz
# Because Unicorn is such a brilliant piece of software, it wraps older,
# non-Rack versions of Rails in a Rack handler. That way Unicorn
# itself can target Rack and not have to worry about monkey patching
# Rails' dispatcher.
#
# This means we can do the same, and even more.
#
# Starting Rackhub locally:
#
# Thin:
require 'sunspot'
require 'sunspot/session_proxy/abstract_session_proxy'
require 'resque'
require 'resque-retry'
class SunspotResqueSessionProxy < Sunspot::SessionProxy::AbstractSessionProxy
attr_reader :session
delegate :config, :delete_dirty?, :dirty?,
:new_search, :search,
# backup redis databases to s3 on the engineyard platform
require 'zlib'
require 'rubygems'
require 'crack/json'
require 'aws/s3'
class Redis2S3
DATABASE = '/db/redis/redis_state.rdb'
* executing `deploy'
* executing `deploy:update'
** transaction: start
* executing `deploy:update_code'
updating the cached checkout on all servers
executing locally: "git ls-remote git@github.com:ryw/peoplebest.git master"
* executing "if [ -d /home/deploy/public_html/peoplebest/shared/cached-copy ]; then cd /home/deploy/public_html/peoplebest/shared/cached-copy && git fetch -q origin && git reset -q --hard e18b14000c60255f8a438bba465f25c11899a44c && git submodule -q init && for mod in `git submodule status | awk '{ print $2 }'`; do git config -f .git/config submodule.${mod}.url `git config -f .gitmodules --get submodule.${mod}.url` && echo Synced $mod; done && git submodule -q sync && git submodule -q update && git clean -q -d -x -f; else git clone -q git@github.com:ryw/peoplebest.git /home/deploy/public_html/peoplebest/shared/cached-copy && cd /home/deploy/public_html/peoplebest/shared/cached-copy && git checkout -q -b deploy e18b14000c60255f8a438bba465f25c11899a44c && git submodule -q ini
require 'uri'
require 'psych'
require 'net/http'
require 'meme' # Install meme_generator
module Campfire
class API
attr_reader :uri, :token, :pass
@mguterl
mguterl / BusinessStore.rb
Created November 24, 2011 22:32 — forked from Justinwceo/BusinessStore.rb
Sunspot: How to filter?
class BusinessStore < ActiveRecord::Base
attr_accessible :website, :name, :address, :phone_number, :online_store
has_many :products
end
@mguterl
mguterl / .rvmrc
Created February 21, 2012 23:19 — forked from st23am/urinal_etiquette.rb
Test Problem
#!/usr/bin/env bash
# This is an RVM Project .rvmrc file, used to automatically load the ruby
# development environment upon cd'ing into the directory
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
# Only full ruby name is supported here, for short names use:
# echo "rvm use 1.9.3" > .rvmrc
environment_id="ruby-1.9.3-p0@cincirb_katas"
@mguterl
mguterl / newrelic_outline.mkd
Created September 12, 2012 19:36 — forked from queso/newrelic_outline.mkd
New Relic Outline

Don't be blind when making adjustments for performance. Measure, measure, measure.

Overview

New Relic is a great product for monitoring the peformance of your application. They provide performance management for Ruby, PHP, .Net, Java and Python. Today's presentation is going to focus on Ruby and specifically Rails, however, the basic New Relic overview will be applicable to any of the platforms mentioned. Integrating New Relic into your Rails application is as easy as signing up and adding the gem to your Rails application's Gemfile.

Apdex

When measuring performance in the browser or on the server New Relic provides Apdex scores. Apdex is

@mguterl
mguterl / latency.txt
Created February 12, 2013 12:42 — forked from jboner/latency.txt
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms