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 A { | |
| private B b; | |
| private C c; | |
| private D d; | |
| private E e; | |
| public A () { | |
| b = new B (); | |
| c = new C (); | |
| d = new D (); |
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 "bigdecimal" | |
| class Node | |
| def initialize(name) | |
| @name = name | |
| @children = [] | |
| end | |
| attr_reader :name |
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 EventHandler | |
| def initialize | |
| @callbacks = Hash.new { |h,k| h[k] = [] } | |
| end | |
| def on(event, callback) | |
| @callbacks[event] << callback | |
| end | |
| def trigger(event, *args) |
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 EventHandler | |
| def initialize | |
| @callbacks = Hash.new { |h,k| h[k] = [] } | |
| end | |
| def on(event, callback) | |
| @callbacks[event] << callback | |
| end | |
| def trigger(event, *args) |
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 EventHandler | |
| def initialize | |
| @callbacks = Hash.new { |h,k| h[k] = [] } | |
| end | |
| def on(event, callback) | |
| @callbacks[event] << callback | |
| end | |
| def trigger(event, *args) |
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 FormattedTable | |
| def initialize(table) | |
| @table = table | |
| end | |
| def to_s | |
| @table.map { |row| row.join(" | ") }.join("\n") | |
| end | |
| 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
| def generate_options(condition) | |
| case condition.to_s | |
| when "invalid_reg_exp" | |
| {:response_msg => "Validation Failed(NON-SMTP)",:status=>"FAILED",:email_status=>"INVALID"} | |
| when "free_domain" | |
| {:response_msg => "Free Domain",:status=>"FAILED",:email_status=>"NEUTRAL"} | |
| when "server_failure" | |
| {:response_msg => "Mail Server Not Connected",:status=>"FAILED",:email_status=>"NEUTRAL"} | |
| when "valid" | |
| {:response_msg => condition.response,:status=>"VERIFIED",:email_status=>"VALID"} |
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 'socket' | |
| module EventEmitter | |
| def _callbacks | |
| @_callbacks ||= Hash.new { |h, k| h[k] = [] } | |
| end | |
| def on(type, &blk) | |
| _callbacks[type] << blk | |
| self |
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 | |
| PATTERNS = { "gg" => "http://google.com/search?q=", | |
| "gmap" => "http://maps.google.com/maps?q=", | |
| "wp" => "http://en.wikipedia.org/?search=", | |
| "m" => "http://www.google.com/movies?near=" } | |
| app = lambda do |env| | |
| command, *args = URI.unescape(env["QUERY_STRING"]).gsub("+", " ").split |
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 "simple_uuid" | |
| class UUIDTracer < SimpleUUID::UUID | |
| def initialize(*a, &b) | |
| p [a, b] # replace this with a logger | |
| super | |
| end | |
| end | |
| SimpleUUID::UUID = UUIDTracer |