This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~$ 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* 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 = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
module SelectTagHelper | |
## | |
## Generate <select> tag. Both <option> and <opttags> are supported. | |
## | |
## ex. | |
## <% values = {'H'=>'Haruhi', 'M'=>'Mikuru', 'Y'=>'Yuki'} %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'eventmachine' | |
require 'em-websocket' | |
require 'json' | |
class Connection | |
attr_accessor :socket, :user_id | |
def initialize(socket, user_id) | |
@socket = socket |
OlderNewer