Skip to content

Instantly share code, notes, and snippets.

View brentertz's full-sized avatar

Brent Ertz brentertz

View GitHub Profile
@brentertz
brentertz / ab.sh
Created March 27, 2012 14:35
Apache Bench - Load test a protected page
#!/bin/bash
COOKIE_JAR="ab-cookie-jar"
COOKIE_NAME="_myapp_session"
USERNAME="foo@bar.com"
PASSWORD="password"
LOGIN_PAGE_URI="http://localhost:3000/users/sign_in"
TEST_PAGE_URI="http://localhost:3000/dashboard"
echo "Logging in and storing session id."
@brentertz
brentertz / application.rb
Created February 4, 2012 22:43
Rack middleware to redirect WWW to non WWW domain.
# Configure Rack middleware
config.middleware.insert_before 0, 'WwwRedirect'
@brentertz
brentertz / quickleft.zsh-theme
Created November 25, 2011 22:27
An oh-my-zsh theme for QuickLeft
# QuickLeft theme for oh-my-zsh.
# Requires rvm or rbenv plugin (rbenv plugin - https://github.com/robbyrussell/oh-my-zsh/pull/670)
DEFAULT_TEXT_COLOR=$fg[white]
PROMPT_PREFIX_COLOR=$fg[white]
PROMPT_SUFFIX_COLOR=$fg[blue]
PROMPT_DIR_COLOR=$fg[yellow]
RUBY_PROMPT_COLOR=$fg[blue]
RUBY_PROMPT_INFO_COLOR=$fg[yellow]
GIT_PROMPT_COLOR=$fg[blue]
@brentertz
brentertz / rvm2rbenv.txt
Created November 21, 2011 23:00
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@brentertz
brentertz / erb2haml.txt
Created September 16, 2011 14:55
# Convert erb to haml on command line...
gem install hpricot
gem install ruby_parser
# Find and list erb templates to convert, but don't convert
find . -name '*erb' | xargs ruby -e 'ARGV.each { |i| puts "html2haml -r #{i} #{i.sub(/erb$/,"haml")}"}'
# Find and convert erb to haml, (won't delete your erb)
find . -name '*erb' | xargs ruby -e 'ARGV.each { |i| puts "html2haml -r #{i} #{i.sub(/erb$/,"haml")}"}' | bash
@brentertz
brentertz / original_static_assets_middleware.rb
Created September 2, 2011 15:00
heroku_rack - static asset middleware
module Heroku
class StaticAssetsMiddleware
def initialize(app)
@app = app
end
def call(env)
# call returns an array containing [response code, header, Rack::Response]
reply = @app.call(env)
@brentertz
brentertz / blog-db-heroku-db-pull
Created August 12, 2011 15:55
For QuickLeft Blog Post on Heroku/Taps
$ heroku db:pull
...
Receiving schema
Schema: 100% |==========================================| Time: 00:00:00
Receiving indexes
users: 100% |==========================================| Time: 00:00:01
orders: 100% |==========================================| Time: 00:00:00
Receiving data
2 tables, 300 records
Resetting sequences
@brentertz
brentertz / _base.scss
Created July 3, 2011 02:59
Flash messages
/* Flashes
-------------------------------------------------------------- */
.js #flash {
display: none;
}
#flash {
position: absolute;
width: 100%;
z-index: 10000;
@brentertz
brentertz / gist:1061741
Created July 2, 2011 22:42
Google analytics async snippet - in haml
-# mathiasbynens.be/notes/async-analytics-snippet
:javascript
var _gaq=[['_setAccount',"#{ENV['GOOGLE_ANALYTICS_ID']}"],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
@brentertz
brentertz / gist:1045048
Created June 24, 2011 15:40
Google CDN jquery with local fallback
-# Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if needed
%script{:src => "//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"}
:javascript
!window.jQuery && document.write('<script src="/javascripts/jquery.min.js"><\/script>')