2017-11-01から1ヶ月間の記事一覧

Ruby--スレッド処理

# スレッド処理 threads=[] txtfilelist = %w{yamazon.txt yamazon2.txt} for txtfile in txtfilelist threads << Thread.new(txtfile) do |txt| File.open(txt, "a") do |file| file.puts "hello" end end end # 待ち合わせ threads.each do |each_thread| …

Ruby--ファイル読み書き、ファイバー

# 書き込み File.open("yamazon.txt", "w") {|file| file.puts "hello";file.puts "a"} # 書き込み 追記 File.open("yamazon.txt", "a") {|file| file.puts "h i j k";file.puts "a hello"} # ファイルオープン 改行区切りで読み込み表示 File.open("./yamaz…

McAfee VirusScan Enterprise 8.xのウイルススキャンで、ネットワークドライブ接続先をスキャンするためのメモ。

エージェントの入っているWindows7端末から、ネットワークドライブマウントしているXP端末のローカルドライブをスキャンする必要があり、調べた。 結論 McAfeeが行うスキャンはユーザー単位に行う エージェントを入れている7端末でローカルディスク(CやD)を…

Ruby => 正規表現検索、置換①

# 文字列 string = 'cccbbbaaaddd' # 正規表現 pattern = 'a.*' # 検索 string.match(pattern) # => #<MatchData "aaaddd"> string.match(pattern).to_s # => "aaaddd" string.match(pattern).to_s[-1] # => "d" string.match(pattern).to_s[0] # => "a" string.match(pattern).p</matchdata>…

Ruby => 日付時刻

require "date" # 2017/8/19 start_date = Date.new(2017,8,19) => #<Date: 2017-08-19 ((2457985j,0s,0n),+0s,2299161j)> #today end_date = Date.today => #<Date: 2017-11-03 ((2458061j,0s,0n),+0s,2299161j)> # diff (end_date - start_date).to_i => 76 # to_s end_date.to_s => "2017-11-03" start_date.to_s => "20…</date:></date:>

Windows Powershell => 引数にブロックを与える

関数定義での引数を[scriptblock]型に指定しておき、 関数内では"&"を使って呼び出します。 関数呼び出しの際には引数にブロック{} を記述し、中にコマンドを記載します。 # if-elseからメッセージ出力する共通関数 function message ([scriptblock]$conditi…