This file contains hidden or 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 "test/unit" | |
| require "contest" | |
| require "rack/test" | |
| require "sinatra/base" | |
| require "nakajima" | |
| class MyApp < Sinatra::Base | |
| set :environment, :test | |
| get "/" do |
This file contains hidden or 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 Operations | |
| def self.list | |
| @list ||= [] | |
| end | |
| class Base | |
| def self.inherited(klass) | |
| Operations.list << klass | |
| end |
This file contains hidden or 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 | |
| # | |
| # A Rack middleware for automatically removing the format token at the end | |
| # of a request path and adding its media type to the HTTP_ACCEPT header. | |
| # | |
| # MIT-License - Rein Henrichs | |
| # | |
| class FormatAccepts | |
| def initialize(app) | |
| @app = app |
This file contains hidden or 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
| # not to be a dick, just for fun | |
| res = %w(one two three one two one).inject(Hash.new(0)) do |counts, t| | |
| counts[t] += 1 | |
| counts | |
| end | |
| p res |
This file contains hidden or 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
| [*1..99].reverse.each do |i| | |
| phrase = ["#{i} bottles of beer on the wall", | |
| "#{i} bottles of beer", | |
| "You take one down", | |
| "You pass it around", | |
| "#{i - 1} bottles of beer on the wall.."].join(".. ") | |
| `say #{phrase}` | |
| end |
This file contains hidden or 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
| $.fn.transitionToNext = function() { | |
| ({ | |
| entry: function() { | |
| // do whatever is needed to transition to entry | |
| $(this).data('state.next', 'captcha'); | |
| return false; | |
| }, | |
| captcha: function() { | |
| $(this).removeClass('entry').addClass('captcha'); |
This file contains hidden or 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
| HTTPMachine.service_access(:threads => 3) do |data| | |
| data.pages << YahooBOSS.web_search("paul dix").get_pages | |
| end |
This file contains hidden or 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 'nokogiri' | |
| class Nokogiri::XML::Node | |
| def method_missing name, *args, &block | |
| if args.empty? | |
| list = xpath("//#{name}") | |
| elsif args.first.is_a? Hash | |
| hash = args.first | |
| if hash[:css] |
This file contains hidden or 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
| "up and atom!" |
This file contains hidden or 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
| Running with tiny string | |
| - only scanning then injecting: 0.0131118297576904 seconds | |
| - scanning groups and injecting: 0.0120480060577393 seconds | |
| - scanning then splat hashing: 0.0159380435943604 seconds | |
| - splitting then splat hashing: 0.00326204299926758 seconds | |
| Running with medium string | |
| - only scanning then injecting: 0.13988208770752 seconds | |
| - scanning groups and injecting: 0.12324595451355 seconds | |
| - scanning then splat hashing: 0.242349147796631 seconds |