ruby

botっぽいpostをする手抜きスクリプト

必要なもの : MeCab require 'twitterにpostできるライブラリ何か' require 'MeCab' require 'csv' words = [] out = [] CSV.parse(MeCab::Tagger.new("-Ochasen").parse(ARGV[0].chomp), ?\t) do |line| words << line.to_a[0].to_s end words.delete_at(wo…

上書きされない

実行環境 OS : MacOSX 10.5.7 ruby : 1.8.6 class Hoge attr_reader :foo def initialize @foo = fuga @foo = fugafuga end def fuga puts 'bar' end def fugafuga puts 'buz' end end Hoge.new.foo実行結果 bar buzなんでだろう追記 @rosylillyに教えてもら…

idが被る

実行環境 OS : MacOSX 10.5.7 ruby : 1.8.6 objs = [] strs = [] 100000.times do |i| objs << Object.new.object_id.to_s strs << String.new.object_id.to_s print objs[i], " ", strs[i], " ", i, "\r\n" end print objs.uniq.size, " ", strs.uniq.size,…