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
| # Need to block | |
| begin | |
| json = Timeout.timeout 3 do | |
| Net::HTTP.new(uri.host, uri.port).start do |https| | |
| https.request_get(uri.request_uri) | |
| end | |
| end | |
| rescue Timeout::Error | |
| if @retries >= 3 | |
| return {return: 'Gateway Timeout.', response: 504} |
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
| def mealtimes(meal) | |
| arr = [] | |
| arr << "breakfast" if meal.breakfast | |
| arr << "lunch" if meal.lunch | |
| arr << "dinner" if meal.dinner | |
| arr.join(", ").sub(/(.*),/, "\\1 and") | |
| 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
| # Returns a hash of methods organized by their owner and method type. | |
| module Kernel | |
| def methods | |
| output = {} | |
| syms = [:public_methods, :protected_methods, :private_methods] | |
| syms.each do |sym| | |
| output[sym] = {} | |
| send(sym).each do |m| | |
| key = self.method(m).owner |
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
| #!/usr/bin/env ruby | |
| require "librevox" | |
| require "sequel" | |
| DB = Sequel.connect('postgres://postgres:leenuhks@localhost/freeswitch') | |
| class Outbound < Librevox::Listener::Outbound | |
| def session_initiated | |
| answer |
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
| # Always wanted to chain comparisons the snaky way? | |
| # | |
| # puts 'Right there!' if 5 < x <= 15 | |
| # | |
| # There you go. | |
| class FalseClass | |
| ['<', '>', '<=', '>='].each do |op| | |
| eval "def #{op}(other) false end" | |
| end |
NewerOlder