- Browser
- Proxy
- Gateway
TODO Difference between proxy and gateway caches.
| class Hash | |
| def to_html | |
| [ | |
| '<ul>', | |
| map { |k, v| ["<li><strong>#{k}</strong>", v.respond_to?(:to_html) ? v.to_html : "<span>#{v}</span></li>"] }, | |
| '</ul>' | |
| ].join | |
| end | |
| end |
| #!/usr/bin/env ruby | |
| def match_message(regexp) | |
| m = Module.new | |
| (class << m; self; end).instance_eval do | |
| define_method(:===) do |error| | |
| regexp === error.message | |
| end | |
| end | |
| m |
| ActionController::UnknownHttpMethod exception found under rails 3.0.1 | |
| $ cat lib/http_method_not_allowed.rb | |
| # Render 405 response for ActionController::UnknownHttpMethod exceptions like: | |
| # (ActionController::UnknownHttpMethod) "CONNECT, accepted HTTP methods are get, head, put, post, delete, and options" | |
| # (ActionController::UnknownHttpMethod) "PROPFIND, accepted HTTP methods are get, head, put, post, delete, and options" | |
| class HttpMethodNotAllowed | |
| def initialize(app) | |
| @app = app |
| module Colors | |
| def colorize(text, color_code) | |
| "\033[#{color_code}m#{text}\033[0m" | |
| end | |
| { | |
| :black => 30, | |
| :red => 31, | |
| :green => 32, | |
| :yellow => 33, |
| context 'performance' do | |
| before do | |
| require 'benchmark' | |
| @posts = [] | |
| @users = [] | |
| 8.times do |n| | |
| user = Factory.create(:user) | |
| @users << user | |
| aspect = user.aspects.create(:name => 'people') | |
| connect_users(@user, @aspect0, user, aspect) |
| ActionView::Base.field_error_proc = Proc.new do |html_tag, instance| | |
| html = %(<div class="field_with_errors">#{html_tag}</div>).html_safe | |
| # add nokogiri gem to Gemfile | |
| elements = Nokogiri::HTML::DocumentFragment.parse(html_tag).css "label, input" | |
| elements.each do |e| | |
| if e.node_name.eql? 'label' | |
| html = %(<div class="clearfix error">#{e}</div>).html_safe | |
| elsif e.node_name.eql? 'input' | |
| if instance.error_message.kind_of?(Array) | |
| html = %(<div class="clearfix error">#{html_tag}<span class="help-inline"> #{instance.error_message.join(',')}</span></div>).html_safe |
| #!/bin/bash | |
| # Bash shell script for generating self-signed certs. Run this in a folder, as it | |
| # generates a few files. Large portions of this script were taken from the | |
| # following artcile: | |
| # | |
| # http://usrportage.de/archives/919-Batch-generating-SSL-certificates.html | |
| # | |
| # Additional alterations by: Brad Landers | |
| # Date: 2012-01-27 |
| // adds mobile class, and mobile os to html tag | |
| jQuery(document).ready(function($){ | |
| var deviceAgent = navigator.userAgent.toLowerCase(); | |
| if (deviceAgent.match(/(iphone|ipod|ipad)/)) { | |
| $('html').addClass('ios'); | |
| $('html').addClass('mobile'); | |
| } | |
| if (deviceAgent.match(/android/)) { |
This script installs a patched version of ruby 1.9.3-p0 with patches to make ruby-debug work again (#47) and boot-time performance improvements (#66 and #68), and runtime performance improvements (#83 and #84).
Huge thanks to funny-falcon for the performance patches.