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
# https://twitter.com/i4mwh4ti4m/status/1258768719972454400?s=21 | |
# しすすすすしおおおすし | |
# 11文字目でおすしがでました | |
l = %w(お す し) | |
result = "" | |
expect = l.join("") | |
begin | |
result += "#{l.sample}" | |
end while !result.include?(expect) |
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
// https://twitter.com/i4mwh4ti4m/status/1258768719972454400?s=21 | |
// しすすすすしおおおすし | |
// 11文字目でおすしがでました | |
using System; | |
using System.Collections.Generic; | |
namespace _3charsCharenge | |
{ | |
class Program |
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 RunnerBase | |
class RunnerClassRuleError < StandardError; end | |
def self.included(base) | |
base.extend(ClassMethods) | |
raise RunnerClassRuleError.new("#{base.name}: Please Rename Runner Class") unless base.name.include?("Runner") | |
end | |
module ClassMethods | |
def run(*args) |
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 Client { | |
get(url) { | |
return this._invoke("GET", url, {}); | |
} | |
post(url, params = {}) { | |
return this._invoke("POST", url, params); | |
} | |
put(url, params = {}) { |
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 './demo_http.rb' | |
client = DemoHttp::Client.new do |configure| | |
configure.open_timeout = 5 | |
configure.read_timeout = 9 | |
configure.max_attempts = 5 | |
configure.url = "https://httpstat.us" | |
end | |
paths = %w(200 404 500) |
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
# spec/models/user_spec_rb/request!/example.comにリクエストができること.yml にファイルが作成されます。 | |
# また、:(コロン)が含まれる場合、MacのFinderからでは/(スラッシュ)に見えます。 | |
## https://qiita.com/uasi/items/996b24185dffb003105a | |
# rails_helperなどでvcr_helper.rbを使えるようにしている前提のコードになります。 | |
require 'rails_helper' | |
RSpec.describe User, type: :model do | |
describe 'request!' do | |
it 'example.comにリクエストができること' do |example| | |
VCR.use_cassette(VcrHelper.cassette_name_from_example(example)) do |
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
ActiveRecord::ReadonlyAttributes::ClassMethods.module_eval do | |
def attr_readonly(*attributes) | |
self._attr_readonly = Set.new(attributes.map(&:to_s)) + (_attr_readonly || []) | |
attributes.each do |attr| | |
define_method attr.to_s + "=" do |text| | |
raise NoMethodError.new("NoMethodError: undefined method `#{__method__}' for #{self}", __method__, text) unless new_record? | |
super | |
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 PayjpModalHelpers | |
def payment_payjp(card_number: '4242 4242 4242 4242', | |
expiration_month: '12', expiration_year: '20', cvc: "123", card_name: "YUI ARAGAKI") | |
sleep(1) # wait for the js to create the popup in response to pressing the button | |
within_frame 'payjp-checkout-iframe' do # must be selenium | |
driver = page.driver.browser | |
sleep 2 |
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
# This selenium script will automatically fill out payjp's checkout popup modal | |
require 'selenium-webdriver' | |
require 'rspec/expectations' | |
def setup | |
@driver = Selenium::WebDriver.for :chrome | |
end | |
def teardown |
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 Nick | |
class NickError < StandardError; end | |
class NoCustomerError < NickError; end | |
class NoCardError < NickError; end | |
class NoMoneyError < NickError; end | |
end | |
begin | |
raise Nick::NoMoneyError.new() | |
rescue Nick::NickError => e |