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
| class ResponsePadder | |
| def initialize (app, minlength, pad=' ', &condition) | |
| @app = app | |
| @minlength = minlength | |
| @pad = pad | |
| @condition = condition | |
| end | |
| def call (env) | |
| response = @app.call(env) |
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
| fib' :: (Integral a) => a -> (a, a) | |
| fib' 0 = (0, 0) | |
| fib' 1 = (0, 1) | |
| fib' x = (b, a + b) | |
| where (a, b) = fib'(x-1) | |
| fib :: (Integral a) => a -> a | |
| fib x = result | |
| where (_, result) = fib'(x) |
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
| class Lupin::Test | |
| dynamic_method :foo do |g| | |
| ast = Lupin::Parser.parse("1+4- -10", :root => :expression).value | |
| Lupin::Compiler.compile(ast, g) | |
| g.ret | |
| end | |
| end | |
| puts Lupin::Test.new.foo #=> 15.0 |
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
| %%{ | |
| machine telnet_nvt_common; | |
| alphtype unsigned char; | |
| # Special bytes that must be handled differently from normal text: | |
| CR = "\r"; # Only \0 or \n may follow | |
| IAC = 255; # Telnet command marker | |
| special_byte = CR | IAC; | |
| # The only bytes that may follow a CR: |
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
| class Integer | |
| def factor_of? (other) | |
| other % self == 0 | |
| end | |
| end | |
| 1.upto(100) do |x| | |
| bt = (3.factor_of?(x) ? "" :"not ") + "divisible by 3" | |
| bf = (5.factor_of?(x) ? "" : "not ") + "divisible by 5" | |
| puts "The value #{x} is #{bt} and is #{bf}" |
NewerOlder