Skip to content

Instantly share code, notes, and snippets.

View RobertBrewitz's full-sized avatar

Robert Brewitz RobertBrewitz

View GitHub Profile
@RobertBrewitz
RobertBrewitz / gist:189087
Created September 18, 2009 14:48
Cucumber step definition
##
# Finds a element with the id flash-#{name}
#
# Then I should receive flash success; if an element with id flash-success is displayed it passses.
##
Then /^I should receive flash (.*)$/ do |name|
within("[id=flash-#{name}]"){}
end
@RobertBrewitz
RobertBrewitz / gist:1063682
Created July 4, 2011 17:41
Nginx build options
./configure --with-cpu-opt=amd64 \
--prefix=$PREFIX/nginx \
--user=www-data --group=www-data \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--http-client-body-temp-path=/var/tmp/nginx/body \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
@RobertBrewitz
RobertBrewitz / gist:1063751
Created July 4, 2011 18:34
10240 byte file (10kb)
<!DOCTYPE html>
<html>
<head>
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type'>
<title>Nginx | CloudsAlot</title>
</head>
<body>
<h1>CloudsAlot @ <a href='https://github.com/RobertBrewitz/CloudsAlot' target='_blank'>Github</a></h1>
<p>Nginx was successfully installed and configured.</p>
<p>Lorem ipsum dolor sit ameti, consectetur elit. Proin bibendum velit lacus. Suspendisse at metus leo, vel pretium dolor. Donec dignissim accumsan augue, vel dictum elit placerat ac. Fusce non ligula est. In tempor cursus imperdiet. Nunc ornare, enim at elementum hendrerit, lectus enim volutpat diam, at ornare enim ante sed odio. Fusce ac mauris et diam pharetra tincidunt. In placerat quam quis elit facilisis ut consectetur purus mattis. Nullam vulputate auctor sem, quis ultrices risus ultrices molestie. Maecenas eu urna vitae massa aliquam egestas a ut nibh. Maecenas lacinia aliquam ullamcorper. Integer bibendum suscipit fringilla. Donec mattis turpis eu nunc laoreet vitae scelerisque neque bla
@RobertBrewitz
RobertBrewitz / baseline.conf
Created July 4, 2011 22:09
Baseline configuration
user www-data www-data;
pid /var/run/nginx.pid;
worker_processes 1;
events {
worker_connections 1024;
}
http {
server_tokens off;
@RobertBrewitz
RobertBrewitz / progressive_test
Created July 4, 2011 22:44
How many workers?
1 worker with 8 concurrent connections
autobench --single_host --host1 10.235.50.10 --uri1 /10kb.html --quiet \
--low_rate 8 --high_rate 8 --rate_step 8 --num_call 16 \
--const_test_time 60 --timeout 5 --file 8con_16req_1worker.csv
CPU: ~6%, response time: 1.9ms, timeouts: 0
1 worker with 16 concurrent connections
autobench --single_host --host1 10.235.50.10 --uri1 /10kb.html --quiet \
--low_rate 16 --high_rate 16 --rate_step 16 --num_call 16 \
--const_test_time 60 --timeout 5 --file 16con_16req_1worker.csv
@RobertBrewitz
RobertBrewitz / epoll.sh
Created July 4, 2011 23:13
Epoll build
./configure --with-cpu-opt=amd64 \
--prefix=$PREFIX/nginx \
--user=www-data --group=www-data \
--http-log-path=/var/log/nginx/access.log \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--http-client-body-temp-path=/var/tmp/nginx/body \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
@RobertBrewitz
RobertBrewitz / nginx.baseline.conf
Created July 5, 2011 20:50
Nginx baseline configuration for Amazon EC2 instance after tuning session
user www-data www-data;
pid /var/run/nginx.pid;
worker_rlimit_nofile 58064;
worker_processes 1;
events {
use epoll;
worker_connections 58064;
}
@RobertBrewitz
RobertBrewitz / weekify.sh
Created October 6, 2011 14:36
Sort your download directory into weeks
#! /bin/bash
WEEK=$(/bin/date +%V)
if [ ! -d $HOME/Downloads/week-$WEEK ]; then
mkdir $HOME/Downloads/week-$WEEK
fi
downloadedFiles=($(find $HOME/Downloads -depth 1))
@RobertBrewitz
RobertBrewitz / teaching_myself_boos_tda.rb
Created August 3, 2012 10:31
Understanding the BOOS, "Don't ask tell" from a talk at GORUCO 2012
##
# Growing Object Oriented Software
# Tell, don't ask approach
# Tested and learned the principle
class SomeProgram
def self.runit
# Printer is the main purpose
# Later I might want to Log, IM, Email or Ping something about the printing result.
@RobertBrewitz
RobertBrewitz / when_I_fill_in_all_required_object_fields_step.rb
Created August 4, 2012 01:43
Fill in valid data for a model with Capybara and FactoryGirl
When /^I fill in all required "(.*?)" fields$/ do |model|
klass = model.singularize.camelcase.constantize
# Build the class with valid attributes
# Requires valid factory
valid_model = FactoryGirl.build(model.singularize.to_sym)
# Remove ID field(s)
valid_model.attributes.delete("_id") if valid_model.attributes.include?("_id")
valid_model.attributes.delete("id") if valid_model.attributes.include?("id")