Rubyチートシート
の編集
Top
/
Rubyチートシート
[
トップ
] [
編集
|
凍結
|
差分
|
添付
|
リロード
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
Active
Rubyチートシート
成果物リスト
勉強会ログ
↑
アイデア
Webサービス案
Androidアプリ案
電子工作案
GreaseMonkey案
contribute
編集
↑
Recent
2023-11-12
自動車保険
2023-08-04
HDDリスト
2023-08-03
docker
2023-05-17
Rubyチートシート
2023-03-30
RAID5/トラブル20230324
2023-03-25
PC/misuzu
2023-03-24
PC
2023-03-23
PC/DESKTOP-7SL5J8R
2022-12-16
Linux
2022-11-09
Linux/ディスクイメージ取得
2021-05-23
CTF
2021-03-17
PC/misumi
2020-08-31
COMP
2020-03-28
PC/misumi/ubuntu
Windows 10
2018-06-04
Microsoft decode 2018 2日目
Microsoft decode 2018 1日目
2018-04-07
カメラ
2018-01-06
電力自由化
2017-12-21
CROSS×BEATS
B
I
U
D
H
[[]]
<br>
--
* 外部プロセスを並列実行 ---( require "open3" require "thwait" class Runner def initialize @failed_cmds = [] end def run_parallel(cmds) contexts = [] threads = [] cmds.each do |cmd| stdin, stdout, stderr, wait_thread = *Open3.popen3(cmd) stdin.close contexts << { "cmd" => cmd, "stdout" => stdout, "stderr" => stderr, "wait_thread" => wait_thread, } threads << wait_thread end ThreadsWait.all_waits(*threads) ret = true contexts.each do |context| puts context["cmd"] puts context["stdout"].read.encode(Encoding::UTF_8, Encoding::Shift_JIS) puts context["stderr"].read.encode(Encoding::UTF_8, Encoding::Shift_JIS) unless context["wait_thread"].value.success? @failed_cmds << context["cmd"] ret = false end end ret end attr_reader :failed_cmds end runner = Runner.new runner.run_parallel(cmds) if runner.failed_cmds.empty? puts "全コマンドの実行に成功しました" else puts "下記のコマンドの実行に失敗しました" puts runner.failed_cmds.join("\n") end ---)
タイムスタンプを更新
テキスト整形のルールを表示する
Last-modified: 2023-05-17(水) 09:09:06