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 Tetoroid | |
def self.recognize(inputs) | |
return "-" if inputs.uniq.size != 4 | |
coordinates = inputs.map {|n| n.divmod(10) } | |
# g means gravity | |
gx, gy = coordinates.transpose.map {|array| array.inject(&:+).to_f / array.size } | |
distances = coordinates.map {|x, y| (x - gx)**2 + (y - gy)**2 }.sort # dare not sqrt |
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 Dispatchable | |
def self.included(base) | |
base.module_eval { | |
def self.method_added(name) | |
suffix = self.name.split("::").last.downcase | |
return if name.to_s.end_with?(suffix) | |
module_eval %{ | |
alias #{name}_#{suffix} #{name} | |
undef #{name} |
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
# -*- coding: utf-8 -*- | |
class Shell < BasicObject | |
def initialize(name, *args, &block) | |
_push(name, *args) | |
end | |
attr_accessor :_result | |
attr_writer :_queue | |
def to_s |
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
require "selenium/webdriver" | |
require "selenium/webdriver/chrome" | |
module Selenium | |
module WebDriver | |
module Chrome | |
class Bridge | |
def create_capabilities(opts) | |
caps = opts.delete(:desired_capabilities) { Remote::Capabilities.chrome } | |
args = opts.delete(:args) || opts.delete(:switches) |
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
$ npx wdio --watch --spec test.js | |
[15:00:44] COMMAND POST "/session" | |
[15:00:44] DATA {"desiredCapabilities":{"javascriptEnabled":true,"locationContextEnabled":true,"handlesAlerts":true,"rotatable":true,"maxInstances":5,"browserName":"chrome","loggingPrefs":{"browser":"ALL","driver":"ALL"},"requ | |
estOrigins":{"url":"http://webdriver.io","version":"4.12.0","name":"webdriverio"}}} | |
[15:00:46] INFO SET SESSION ID b0083dcf4ed26c3e9de5873e9b7d2393 | |
[15:00:46] RESULT {"acceptInsecureCerts":false,"acceptSslCerts":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"browserName":"chrome","chrome":{"chromedriverVersion":"2.36.540469 (1881fd7f8641508feb5166b7 | |
cae561d87723cfa8)","userDataDir":"/var/folders/c7/7pqwpv895y31b3n67b4l2tj5hwytzk/T/.org.chromium.Chromium.E1IHhg"},"cssSelectorsEnabled":true,"databaseEnabled":false,"handlesAlerts":true,"hasTouchScreen":false,"javascriptEnabled":true,"locati | |
onContextEnabled":true,"mobileEmulationEnabled":false,"nativ |
OlderNewer