This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'pp' | |
require 'socket' | |
host, port = 'localhost', 3333 | |
insert = -> clause { | |
TCPSocket.open(host, port) do |s| | |
s.puts "assert(#{clause})." | |
s.gets | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
文法: 数字 '.' (例:「1.」「12.」などは妥当。「.1」などは不正) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = 10 | |
p [1,2,3].map {|n| n * a } #=> [10, 20, 30] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby sample-ivar.rb | |
foo は呼ばないでください. | |
foo は呼ばないでください. | |
foo は呼ぶなッ!!3 度目!! | |
-------- | |
foo は呼ばないでください. | |
foo は呼ばないでください. | |
foo は呼ぶなッ!!3 度目!! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: | |
: while_exist で「xxx.part」が消えるまで待って、それから warm_halt でシャットダウンします | |
: | |
$ while_exist xxx.part ; warm_halt | |
: | |
: 上のコマンドは返って来ません。このまま出かけましょう。 | |
: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p [].array? #=> true # [].kind_of?(Array) と同じこと | |
p {}.array? #=> false # {}.kind_of?(Array) と同じこと |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ lsb_release -a | |
No LSB modules are available. | |
Distributor ID: Ubuntu | |
Description: Ubuntu 14.04.1 LTS | |
Release: 14.04 | |
Codename: trusty |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p :key.eql? 'key' #=> false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
module Notifier | |
attr_reader :listeners | |
def on(event, *xs, &b) | |
@listeners ||= Hash.new {|h,k| h[k] = []} | |
@listeners[event].push *xs, b | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby sample2.rb | |
W, [2014-12-31T15:59:36.757060 #24309] WARN -- : (警告) foo は呼び出さないでください | |
E, [2014-12-31T15:59:36.757153 #24309] ERROR -- : (異常) bar は呼び出したらダメ!! |