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
APP_NAME = 'Send Mail Using the Gmail API' | |
# | |
# To run this program, we need two files. | |
# | |
# 1. clent_secret.json | |
# | |
# Create credentials in your Google Developers Console and download it. | |
# Details for see 'Google Developers Console' web page. | |
# | |
# 2. credential.yaml |
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
module ArrayTraversable | |
def traverse(each=:each, *args, &block) | |
visit = -> y, obj=self, idx=[] do | |
idx.push 0 | |
obj.send(each, *args) do |x| | |
if x.kind_of?(Array) | |
visit.(y, x, idx) | |
else | |
y << [x, idx] | |
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 prolog_parser.rb 'f(x,y) :- a(b(c(d,e,f),!),[1,2,X|Y])' | |
{:":-"=> | |
[{:f=>[:x, :y]}, | |
{:a=>[{:b=>[{:c=>[:d, :e, :f]}, :!]}, {[1, 2, {nil=>:X}]=>[{nil=>:Y}]}]}]} |
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 C.ancestors #=> [C::Logging, C, Object, Kernel, BasicObject] |
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
$ pry -r drb # 'drb' を require する | |
: |
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 prolog_server.rb # デフォルトでポート 53340/tcp を LISTEN | |
# 起動したままになる。停止するには Ctrl-C | |
# --log ログファイル名 を付けて起動するとログ出力します |
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 'prolog_translator' | |
SERVER = 'server.pro' | |
PORT = Prolog::Proxy::PORT | |
# | |
# Prolog サーバへの起動と設定 | |
# | |
desc 'Prolog サーバの起動' | |
task:server, [:port, :server_program] do |t, args| |
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
$ make | |
racc -g -o prolog_parser.rb prolog_parser.ry |
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
RACC := racc | |
RACCFLAGS := -g | |
SOURCES := prolog_parser.ry | |
TARGETS := ${patsubst %.ry, %.rb, ${SOURCES}} | |
.SUFFIXES : .rb .ry | |
%.rb : %.ry |
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 t1.rb | |
hello # 子スレッドで表示 | |
hello # 〃 | |
hello # 〃 |
NewerOlder