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
class HighlightEscapedHTML | |
def initialize(app) | |
@app = app | |
end | |
def call(env) | |
dup._call(env) | |
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
rake | |
/Users/murphy/.rvm/rubies/ruby-1.8.7-p352/bin/ruby -I"lib:test" -I"/Users/murphy/.rvm/gems/ruby-1.8.7-p352@chiliproject/gems/rake-0.9.2.2/lib" "/Users/murphy/.rvm/gems/ruby-1.8.7-p352@chiliproject/gems/rake-0.9.2.2/lib/rake/rake_test_loader.rb" "test/unit/**/*_test.rb" | |
(Test LDAP server not configured) | |
* DEFERRED: #link_to_if_authorized authorized user should be tested. | |
* DEFERRED: #link_to_if_authorized unauthorized user should be tested. | |
* DEFERRED: IssuesHelper#show_detail with a estimated hours attribute should format the time into two decimal places. | |
* DEFERRED: IssuesHelper#show_detail with a estimated hours attribute should format the old time into two decimal places. | |
* DEFERRED: IssuesHelper#show_detail should test custom fields. | |
* DEFERRED: IssuesHelper#show_detail should test attachments. | |
* DEFERRED: #number_of_rows with one project should return the number of rows just for that project. |
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
> rvm 1.8.7,ree-1.8.7-2011.03,1.9.2,1.9.3 do "ruby -v; time rails runner 'nil'" | |
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin10.8.0] | |
real 0m1.404s | |
user 0m1.195s | |
sys 0m0.207s | |
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin11.0.0], MBARI 0x6770, Ruby Enterprise Edition 2011.03 | |
real 0m1.347s | |
user 0m1.135s |
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
# Usage: link_to …, prompt: { message: 'Some message', default: 'default value', param: 'name of parameter' } | |
# The prompt will ask for "message" and use "default" as the default value. | |
# Unless user selects cancel, "param"=<new value> will be sent to the given path. | |
# Optionally, you can just use `prompt: "message"`. | |
$.rails.prompt = (message, defaultValue) -> | |
window.prompt message, defaultValue | |
$.rails.handlePrompt = (element) -> | |
config = element.data 'prompt' |
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
$ ruby -v | |
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0] | |
$ ruby test/scanners/suite.rb | grep Average | |
Average speed for C scanner: 2997 kB/s scanning / 1315 kB/s highlighting to HTML page. | |
Average speed for Clojure scanner: 3103 kB/s scanning / 1051 kB/s highlighting to HTML page. | |
Average speed for C++ scanner: 4761 kB/s scanning / 1180 kB/s highlighting to HTML page. | |
Average speed for CSS scanner: 3160 kB/s scanning / 1494 kB/s highlighting to HTML page. | |
Average speed for Delphi scanner: 2865 kB/s scanning / 991 kB/s highlighting to HTML page. | |
Average speed for diff output scanner: 1433 kB/s scanning / 668 kB/s highlighting to HTML page. |
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
class Array | |
def slice_before | |
[].tap do |chunks| | |
each do |item| | |
chunks << [] if yield(item) || chunks.empty? | |
chunks.last << item | |
chunks | |
end | |
end | |
end |
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 Math | |
class << self | |
def fac n | |
return 1 if n < 2 | |
(1..n).inject { |prod, i| prod * i } | |
end | |
def choose n, k | |
fac(n) / (fac(n-k) * fac(k)) | |
end |
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
class Foo < BasicObject | |
def test_block_given? | |
block_given? | |
end | |
private | |
def method_missing(method, *args, &block) | |
3.send(method, *args, &block) | |
end | |
end |
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
function srtTimeToSeconds(time) { | |
var match = time.match(/(\d\d):(\d\d):(\d\d),(\d\d\d)/); | |
var hours = +match[1], | |
minutes = +match[2], | |
seconds = +match[3], | |
milliseconds = +match[4]; | |
return (hours * 60 * 60) + (minutes * 60) + (seconds) + (milliseconds / 1000); | |
} |
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
class Human | |
def self.speak what | |
what | |
end | |
end | |
class Pirate < Human | |
def self.speak what | |
proc { super }.call | |
end |
OlderNewer