Skip to content

Instantly share code, notes, and snippets.

Kuniaki Igarashi igaiga

Block or report user

Report or block igaiga

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View ruby_de_ruby_8_interp.rb
require "minruby"
def evaluate(tree, genv, lenv)
# pp(tree)
case tree[0]
when "func_def"
genv[tree[1]] = ["user_defind", tree[2], tree[3]]
when "lit"
tree[1]
when "+"
View ruby_de_ruby_6_renshumondai.rb
require "minruby"
def evaluate(tree, env)
# pp(tree)
case tree[0]
when "lit"
tree[1]
when "+"
evaluate(tree[1], env) + evaluate(tree[2], env)
when "-"
View ruby_de_ruby_6.rb
require "minruby"
def evaluate(tree, env)
# pp(tree)
case tree[0]
when "lit"
tree[1]
when "+"
evaluate(tree[1], env) + evaluate(tree[2], env)
when "-"
View ruby_de_ruby_6.rb
require "minruby"
def evaluate(tree, env)
# pp(tree)
case tree[0]
when "lit"
tree[1]
when "+"
evaluate(tree[1], env) + evaluate(tree[2], env)
when "-"
View interp.rb
# $ ruby interp.rb test.rb
# test.rb
# plus_count=0
# x = 1+2+3
# p(plus_count) #=> 2
# x = 1+2+3
# p(plus_count) #=> 4
require "minruby"
View remobe_method.rb
class A
def foo
"A"
end
end
class B < A
def foo
"B" + super
end
end
View privare.rb
# ruby 2.7.0preview2 (2019-10-22 master 02aadf1032) [x86_64-darwin18]
class Foo
private def foo
"foo!!"
end
def bar
self.foo
end
end
View method_or_not.rb
# Rubyでメソッドと、そうではないもの(式とか)の見分け方
# methodメソッドで取得できたらメソッド
method(:p) #=> #<Method: main.p>
# ↑とれたのでメソッド
method(:for)
#=> NameError: undefined method `for' for class `#<Class:#<Object:0x00007fd82d0d22f0>>'
# ↑とれないのでメソッドではない
View ss.rb
# $ gem i selenium-webdriver
require "selenium-webdriver"
options = Selenium::WebDriver::Chrome::Options.new
options.add_argument('--headless')
# headless指定すると普段Chromeで指定しているフォント指定が効かなくなる
driver = Selenium::WebDriver.for :chrome, options: options
driver.get("https://igarashikuniaki.net/diary/")
driver.save_screenshot("ss.png")
View gem_source.txt
## rubyforge
$ gem sources -l
*** CURRENT SOURCES ***
http://gems.rubyforge.org/
$ gem i awesome_print
ERROR: While executing gem ... (TypeError)
You can’t perform that action at this time.