Skip to content

Instantly share code, notes, and snippets.

require 'capybara/poltergeist'
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, js_errors: false, timeout: 5000)
end
session = Capybara::Session.new(:poltergeist)
session.driver.headers = {
'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2564.97 Safari/537.36'
require 'open-uri'
require 'csv'
require 'pp'
# http://okzk.org/blog/openuri_treat_under_10kb
# Don't allow downloaded files to be created as StringIO.
# Force a tempfile to be created.
if OpenURI::Buffer.const_defined?('StringMax')
OpenURI::Buffer.send :remove_const, 'StringMax'
end
CSV.open('syukujitsu.csv', encoding: 'CP932')
.map{|row| row.each_slice(2).to_a }[0..-3]
.transpose.map{|year, header, *body| {year.first => body.map{|i| header.zip(i).to_h}}}
@yppp
yppp / asseting.rb
Last active November 29, 2016 13:21
module Asserting
class AssertionError < StandardError; end
module Asserter
def assert(condition)
return if condition.respond_to?(:empty?) ? !condition.empty? : !!condition
_, caller_filename, caller_lineno, _ = *caller[0].match(/^(.+?):(\d+)(?::in `(.*)')?/)
code_line = ''
if File.exists?(caller_filename)
@yppp
yppp / .reek
Created November 25, 2016 03:17
---
IrresponsibleModule:
enabled: false
DuplicateMethodCall:
allow_calls:
- 'Rails.logger'
@yppp
yppp / .rubocop.yml
Last active November 25, 2016 03:11
inherit_from: .rubocop_todo.yml
AllCops:
Include:
- '**/Rakefile'
- '**/config.ru'
Exclude:
- 'db/**/*'
- 'config/**/*'
- 'script/**/*'
- 'bundle_bin/*'
class Module
def const_missing(name)
name_str = name.to_s
cooked_str = name_str[/\A[A-Z]+?_([A-Z]|_)\z/].present? ?
name_str.gsub(/(?<=.)(?=_.|\z)/, '[A-Z]*?') :
name_str.gsub(/(?<=.)(?=[A-Z]|\z)/, '[a-z]*?')
end
finded_const_name = constants.grep(/\A#{cooked_str}\z/).max
@yppp
yppp / dos_arg.asm
Last active March 31, 2016 03:58
dos_arg.asm
org 100h
start:
mov al, [82h]
sub al, '0'
mov cl, al
mov [hellolen], al
startloop:
@yppp
yppp / hello_dos.asm
Created March 29, 2016 12:31
hello_dos.asm
org 100h
start:
mov dx, msg
mov ah, 09h
int 21h
mov ah,4Ch
int 21h
msg db 'Hello World', 0Dh, 0Ah, '$'
@yppp
yppp / int10h_hello.asm
Created March 29, 2016 12:30
int10h_hello.asm
org 100h
start:
mov si, msg
printloop:
lodsb
mov ah, 0eh
mov bh, 00h
mov bl, 07h
int 10h