Skip to content

Instantly share code, notes, and snippets.

Rails5環境構築とRails Girlsガイド動作確認状況

Windows

irb(main):002:0> require "objspace"
=> true
irb(main):007:0> x = Object.new
=> #<Object:0x007f8bdc1017f0>
irb(main):008:0> ObjectSpace.dump x
=> "{\"address\":\"0x007f8bdc1017f0\", \"type\":\"OBJECT\", \"class\":\"0x007f8bdc0dd9b8\", \"ivars\":0, \"memsize\":40, \"flags\":{\"wb_protected\":true}}\n"
# TensorFlow tutorial
# "MNIST For ML Beginners"
# https://www.tensorflow.org/versions/r0.9/tutorials/mnist/beginners/index.html
# "Deep MNIST for Experts"
# https://www.tensorflow.org/versions/r0.9/tutorials/mnist/pros/index.html
# prepare input data(MNIST_data) before running
# https://www.tensorflow.org/versions/r0.9/tutorials/mnist/beginners/index.html
# from tensorflow.examples.tutorials.mnist import input_data
# mnist = input_data.read_data_sets("MNIST_data/", one_hot=True)
# style= が入ってるファイルを探す。ただしstyle="fill:none"は除く。
paths = Dir.glob("**/*")
paths.each do |path|
File.open(path, "r") do |f|
str = f.read
str.gsub!(/style="fill:none"/, '')
puts path if str =~ /style=/
end
end
class Cat
def hello
"nya"
end
end
class Dog
def hello
"wan"
end
end
module Helloable
def hello
"hello"
end
end
class Cat
def hello
"nya"
end
methods = []
File.open("path_to_ruby_test/test_string.rb", "r") do |f|
f.each_line do |line|
methods << $1 if line =~ /\A\s*def\s+(.+)\s+/
end
end
target_test_methods = methods.map{ |x| x =~ /^test_(.+)\z/ ? $1 : nil }.compact.sort
p target_test_methods
pry(main)> somecode
Error:
from path/to/file.rb:5:in `foo'
pry(main)> somecode rescue [$!, $@]
[Error,
from path/to/file.rb:5:in `foo'
from path/to/file.rb:10:in `bar'
from path/to/file.rb:15:in `baz']]
circumference :: Float -> Float
circumference r = 2 * pi * r
factorial :: Integer -> Integer
factorial n = product [1..n]