Skip to content

Instantly share code, notes, and snippets.

@ir-norn
ir-norn / watir_sample.rb
Last active October 22, 2015 12:02
スレたて
#coding:utf-8
require "watir"
nya = [
"スレッドタイトル1" , "内容1" ,
"スレッドタイトル2" , "内容2" ,
].*(10)
time = 1024
agent = Watir::Browser.new :ie
@ir-norn
ir-norn / tes.rb
Last active September 25, 2015 04:19
instance_evalの使い道
#coding:utf-8
# 2015 09 24 Req
require"dxruby"
class O
attr_accessor :x,:y,:d,:f,:task
def initialize h = {}
@x = h[:x]
@y = h[:y]
@d = h[:d]
@ir-norn
ir-norn / task.rb
Last active September 25, 2015 03:25
task
class Task
def initialize
@func =->{yield self}
end
def update
@func.call
end
end
@ir-norn
ir-norn / koron.rb
Last active October 28, 2015 13:24
段落のタグddをメタするやつ
#coding:utf-8
# https://ja.m.wikipedia.org/wiki/Help:%E3%83%9A%E3%83%BC%E3%82%B8%E3%81%AE%E7%B7%A8%E9%9B%86
text=<<TEXT
:コロンで始まる行は字下げされます。改行しない限り、同じ深さで表示されます。
::コロンを追加すると、さらに深く字下げされます。
::同じ個数のコロンを使うと、同じ深さの字下げになります。
:::あまり深くなり過ぎると、
::::読みづらくなるかもしれません。
::Sample
:::文章
require "observer"
require "dxruby"
class Observer
include Observable
end
class O
attr_accessor :x , :y , :d , :func
def initialize x , y , d , func
# coding : utf-8
require "dxruby"
def move x , y , s , a
x += (s * Math::cos(a * Math::PI/180 ))
y += (s * Math::sin(a * Math::PI/180 ))
[x , y , s , a]
end
def DegToRad x
module Rationalize
refine Fixnum do
def /(other)
quo(other)
end
end
end
p 1 / 2
#require "Fiber"
class Enum_Generator
def initialize re , method
@f = Fiber.new do
re.__send__(method) do | n |
Fiber.yield n
end
end
end
nums = [1,2,3,4,5,1,2,2,3]
p nums.itself { |s| s.inject(:+) / s.size.to_f } # => 2.5555555555555554
p nums.inject(:+) / nums.size.to_f # => 2.5555555555555554
p nums.group_by(&:itself) # => {1=>[1, 1], 2=>[2, 2, 2], 3=>[3, 3], 4=>[4], 5=>[5]}
@ir-norn
ir-norn / watir_sample2.rb
Last active October 22, 2015 12:02
2cht
#coding:utf-8
#
# 2015 10 02
# watir_sample.rb
# https://gist.github.com/ir-norn/e1968bb305aa8d03e1e5
#
require "watir"
require "kconv"
require "open-uri"