Skip to content

Instantly share code, notes, and snippets.

require 'tokyotyrant'
module Rack
module Session
class Tyrant < Abstract::ID
include TokyoTyrant
attr_reader :mutex, :pool
DEFAULT_OPTIONS = Abstract::ID::DEFAULT_OPTIONS.merge :tyrant_server => "localhost:1978"
def initialize(app, options = {})
super
module Rack
class MemoryBloat
def initialize(app, logger)
@app = app
@logger = logger
end
def call(env)
memory_usage_before = memory_usage
result = @app.call(env)
module Rack
# Renders a valid robots.txt according to http://www.robotstxt.org
# This is an example of over-engineering. But it's simple example of
# how you might test your middleware.
class RobotsTxt
def initialize(app)
@app = app
end
def call(env)
~$ ARCHFLAGS='-arch i386 -arch x86_64'
~$ rvm install 1.8.7 --debug --reconfigure -C --enable-shared=yes
~$ wget http://sourceforge.net/projects/rubycocoa/files/RubyCocoa/1.0.0/RubyCocoa-1.0.0.tar.gz/download
~$ tar xzf RubyCocoa-1.0.0.tar.gz && rm RubyCocoa-1.0.0.tar.gz && cd RubyCocoa-1.0.0
~/RubyCocoa-1.0.0$ ruby install.rb config --build-universal=yes
~/RubyCocoa-1.0.0$ ruby install.rb setup
~/RubyCocoa-1.0.0$ sudo ruby install.rb install
# Pattern matcher
# Usage
# When pattern matched, block is yielded with argument is hash that maps
# symbol to value.
#
# mat = Matcher.new
# mat.pattern([:a, :b]) {|hash|
# p hash
# }
# mat.match([1, 2])
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
# -*- coding: utf-8 -*-
module SelectTagHelper
##
## Generate <select> tag. Both <option> and <opttags> are supported.
##
## ex.
## <% values = {'H'=>'Haruhi', 'M'=>'Mikuru', 'Y'=>'Yuki'} %>
;; htmlutil - Some useful tools for working with HTML text and HTTP URLs
; This module provides tools for escaping HTML text, with HTML
; entities for special characters; and for escaping strings to be
; safely included into URLS; and back.
;; Primary commands:
; html-escape-str - Escape (quote) a character for HTML
; html-unescape-str - Un-escape an HTML entity string
; url-quote-str - Quote special characters in a URL string
anonymous
anonymous / oshi.rb
Created July 8, 2010 08:18
require 'rubygems'
require 'eventmachine'
require 'em-websocket'
require 'json'
class Connection
attr_accessor :socket, :user_id
def initialize(socket, user_id)
@socket = socket