トップ 最新 追記

ヨタの日々

2001|08|09|10|11|12|
2002|01|02|03|04|05|06|07|08|09|10|11|12|
2003|01|02|03|04|05|06|07|08|09|10|11|12|
2004|01|02|03|04|05|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|07|08|09|10|11|12|
2019|01|02|03|04|05|06|07|08|09|10|11|12|
2020|01|02|03|04|05|06|07|08|09|10|11|12|
2021|01|02|03|04|05|06|07|08|09|10|11|12|
2022|01|02|03|04|05|06|07|08|09|10|11|12|
2023|01|02|03|04|05|06|07|08|12|
2024|01|02|03|

2014-02-01 :-)

_ 読書メーター

2014年1月の読書メーター 読んだ本の数:4冊 読んだページ数:1379ページ ナイス数:8ナイス 学戦都市アスタリスク 04. 追憶闘破 (MF文庫J)学戦都市アスタリスク 04. 追憶闘破 (MF文庫J)感想 綾斗がもう覚醒してしまった。もうしばらく剣術で勝ち進んでほしかった。剣術では綺凛が最強か。他校の対戦相手に序列1位2位が参加してないのはやはり今後の大会に備えて控えてるんでしょうかね。 読了日:1月5日 著者:三屋咲ゆう
Java言語で学ぶデザインパターン入門 マルチスレッド編Java言語で学ぶデザインパターン入門 マルチスレッド編感想 マルチスレッド設計集。実装はJavaだけど一般化して捉えれば何にでも応用できる。読めば「あー、アレのことか」というのが分かる(Worker ThreadはApache web serverでもお馴染みだし、Producer Consumerはタスク管理だ)。スレッドローカルストレージとかよく分かってなかったんだけど腑に落ちた 読了日:1月4日 著者:結城浩
日本軍艦ハンドブック (光人社NF文庫)日本軍艦ハンドブック (光人社NF文庫)感想 軍艦の一覧。写真は冒頭にいくつかある。各艦の説明は文章で数行。当たり前だがほとんどの艦は「沈没」「消息不明」など沈んでいるので読むのが辛い。駆逐艦の名前を眺めると日本人の自然に対する感性の多さに感嘆する。日本語は美しいな 読了日:1月1日 著者:雑誌「丸」編集部
学戦都市アスタリスク 03 鳳凰乱武 (MF文庫J)学戦都市アスタリスク 03 鳳凰乱武 (MF文庫J)感想 相変わらずレスターが噛ませ役じゃないですか 読了日:1月1日 著者:三屋咲ゆう
読書メーター

_ 午前

0930 起床 && 部屋掃除

1030 おひる。うどん

1100 アニメ消化

_ 午後

1300 アニメ消化

1500 買い物

1600 散歩

IMG_3738

_

1700 アニメ消化

1900 マルチスレッドがどうのこうの

2100 飯。アジの開き

2200 読書

_ [艦これ]艦これ

4-3 レベル上げじゃなくて攻略のために出撃してみた。ボスに辿り着かない。

摩耶を改造した


2014-02-02 :-)

_ 午前

0930 起床

1020 おひる。スパゲティ

1100 読書

_ 午後

1200 読書

1300 アニメ消化

1400 散歩

IMG_3749

_

1700 読書

1800 アニメ消化

1900 読書

2130 飯。青椒牛肉絲 豚肉ですが

_ 買い物

amazon

4798028169

4041011698

_ [艦これ]艦これ

加賀さんを改造した

金剛を改二にした。

_ 買い物

iTunes Store

いろいろ衝動買いした。misterioso なんて聞いてるだけで涙が出てくる。


2014-02-03 :-(

_ 午前

0530 起床

0830 出勤 || デバッグしTARI

_ 午後

1300 デバッグしTARI

_

1700 残業アワー

2145 退勤

2230 飯。ブリの照り焼き


2014-02-04 :-(

_ 午前

0530 起床

0830 出勤 || デバッグしTARI

_ 午後

1300 デバッグしTARI

_

1700 残業アワー

2145 退勤

2230 飯

_ 「ビジネスモデル創造こそ究極の設計だ!!!」というとで体験と気づき - 山本大@クロノスの日記

100 万回読んでおく。

  • 「提供する価値」で強いものを持っていると軸になるので模索のブレが少ない
  • 「※ただし摩擦係数は0と考える」な企画では通用しない、動きださないと企画ですらない
  • 正解が成功するとは限らない
  • 関わる1人だけが必要性を感じてるようなものでは、成り立たない
  • 「課題」が強ければ強いほど解決する意味がある
  • 顧客に価値を伝えるには、提案書だけでは響かない。実感してもらうのが強い

_ 買い物

amazon

4797371285

4873116562


2014-02-05 :-(

_ 午前

0530 起床

0830 出勤 || デバッグしTARI

_ 午後

1300 デバッグしTARI

_

1700 退勤

1800 飯

_ 客先歓送迎会

叶え家

5 年ぶり 2 回目の仕事場について

写真のホワイトバランスを間違えた。

037.JPG

038.JPG

040.JPG

041.JPG

042.JPG

044.JPG

045.JPG

046.JPG

048.JPG

049.JPG

_ ココロコネクト

Microsoft Windows 7 Proffesional な OS において

  • python で smtp するとメール送信可能
  • ruby で smtp するとメール送信失敗

という現象があり、結局 connect(2) が EPERM で失敗している。ようだ。

ruby と python のコード( C のコード )を見比べても差異はなさそうなんだがよく分からん。

_ KAMATA ANGELUS

RIDGE RACERS2 - スペシャルマシン - バンダイナムコゲームス公式サイト

リッジレーサー7 の ANGELUS は【お察しください】なのでこっち。

アルティメットまどかのシルエットに似ているとか似ていないとかというツッコミ[ 20131123#c01 ]があったので見てみたが

img1_1.jpg

むしろレインを思い出す(via. トレジャーハンターG - adovoの日記 )

20090504172515.jpg


2014-02-06 :-(

_ 午前

0530 起床

0830 出勤 || デバッグしTARI

_ 午後

1300 デバッグしTARI

_

1700 残業アワー

2000 退勤

2100 飯

_ FF6

大破壊とか

死闘とか。アルテマウェポン戦はこんなに苦戦した記憶がない


2014-02-07 :-)

_ 午前

0530 起床

0830 出勤 || デバッグしTARI

_ 午後

1300 デバッグしTARI

_

1700 退勤

1800 池袋 || 仕事場から池袋の東京芸術劇場までドア・ツー・ドアで 1 時間のようだ

2130 終了

2230 帰宅

2240 飯

_ [ワーグナー][ニーベルングの指輪][ドラゴンクエスト][すぎやまこういち]すぎやまこういちのドラゴンクエストvsワーグナーのニーベルングの指輪

@東京芸術劇場 コンサートホール

ゲストに堀井雄二! ということで平日だけど脊髄反射でチケットを買ったら、前から 2 列目だった。すぎやまこういちと堀井雄二なんて、すげえ組み合わせなのにこんなものか。まあいいや。

ニーベルングの指輪は飯守泰次郎指揮。すぎやまこういちはドラクエ指揮。指揮を交代しながらドラゴンクエストの曲とニーベルングの指輪を演奏する。

ニーベルングの指輪は先日ラノベで「ジークフリート」の部分だけ読んだ程度のゆとり教育のおっさんですが、ニーベルングの指輪はすべての話を見ると西洋の他の神話と同じように基本的に神がクズである。女にだらしないというか、それにより嫉妬などで揉め事が起きて殺人(殺神?)に発展するという安定の流れです。カンピオーネ!では「神は傍若無人であり自分勝手に行動し周囲にとてつもない影響を及ぼす。迷惑そのものだ」などと表現していた。

曲とか

  • 序曲(DQ1)
  • 演奏対決1 駆けめぐる
    • 広い世界へ~大平原のマーチ(DQ7)
    • ワーグナー ワルキューレの騎行~楽劇「ワルキューレ」第3幕から
  • 演奏対決2 不気味なキャラクター
    • 洞窟に魔物の影が(DQ5)
    • 大魔王(DQ5)
    • ワーグナー ジークフリートの角笛と目を覚ます洞窟の大蛇~楽劇「ワルキューレ」第2幕から
  • 演奏対決3 戦い
    • ワーグナー ジークフリートと大蛇の戦い~楽劇「ワルキューレ」第2幕から
    • 戦闘のテーマ~アレフガルドにて~勇者の挑戦(DQ3)
  • ドラクエの生みの親 堀井雄二氏とすぎやまこういち氏のスペシャルトークコーナー
  • 演奏対決4 ファンタスティックなシーン
    • ワーグナー 森のささやき~楽劇「ワルキューレ」第2幕から
    • おおぞらをとぶ(DQ3)
  • 演奏対決5 旅
    • 冒険の旅(DQ3)
    • 海図を広げて(DQ4)
    • ワーグナー 夜明けとジークフリートのラインへの旅~楽劇「神々のたそがれ」序幕と第1幕から
  • 演奏対決6 エンディング
    • そして伝説へ(DQ3)
    • ワーグナー フィナーレ~楽劇「神々のたそがれ」序幕と第3幕から
  • アンコール
    • この道わが旅(DQ2)

トーク

飯守泰次郎「私もドラゴンクエストは好きです。それが今回一緒にやれるということで嬉しい」

すぎやまこういち「僕はワーグナーなんて恐れ多い。ワーグナーとドラゴンクエストの出会い {だっけ} くらいでやりましょう」

すぎやまこういち「僕はワーグナーの CD は持ってないんですが、学生のころ、昭和 26 年という終戦後すぐなんですが。この会場に昭和 26 年はまだ生まれてなかったひと、手を上げて。1236 人ですね笑 まあその昭和 26 年にオーケストラやるからこの指止まれ と言ったら 40 人集まりまして。すごいです。さすがボンボン。僕は奨学金で入学したんですが、みんな金持ちだから奨学金が全然使われなかったそうです。僕が奨学金を使うと言ったら喜ばれました笑」

トーク

飯守泰次郎「ニーベルングの指輪は全部で 15 時間くらいの演奏があります。今回はダイジェストでお送りします。ドラゴンクエストもけっこう長いのではないですか?」

すぎやまこういち「ドラゴンクエストの曲は 11 時間あります。」

トーク

すぎやまこういち「僕ももう 83 歳になります。長い旅です。ドラゴンクエストには若い女の子とおじいさんも登場して、『ピチピチギャルはええのう』なんて言ったりするんですが、その気持が分かりました」

堀井雄二とすぎやまこういち

堀井雄二がスライムのぬいぐるみを抱えて登場( 超ビッグなスライムぬいぐるみLLサイズが登場!! )

s00.jpg

すぎやまこういち「ゲーム作家の堀井雄二さんです。スライムというと海外だとオドロオドロしい絵ですよね。このスライムは堀井さんがそういう絵にしたんですか?」

堀井雄二「いえ。僕も最初はドロドロした絵を書いたんです。それが鳥山さん(鳥山明)から返ってくると、こうなった」

すぎやまこういち「先ほど女の子の話題を出したんですが、堀井さんは一番最初の女の子との出会いは何でしたか?」

堀井雄二「いろいろインタビューされてきましたけど、こんな質問されるのは初めてです笑 小学生のころに同級生の女の子ですね。活発な子でした。」

すぎやまこういち「でも成果は無しと笑」

堀井雄二「ありませんでしたね笑」

すぎやまこういち「堀井さんは学生のころ何をやっていたんでしょう { すぎやまこういちが学生のころ音楽やってたから、その流れだったかな }

堀井雄二「僕は漫画家になろうとしてたんです。それで高校のころも漫画を書いてて {だったかな} 大学に行って漫画研究部に入った」

すぎやまこういち「その漫画の経験がドラゴンクエストにも活かされているんですね。ドラゴンクエストはセリフが少ない。最低限のセリフだけで話が分かる」

堀井雄二「漫画はセリフで話が進むんですが、ドラゴンクエストもセリフを少なくするようにしました。長いセリフは読まないですから {とかなんとか}」

トーク

アンコール

すぎやまこういち「たくさんの拍手に応えて、アンコールやります。『この道わが旅』83年です。」

最後の挨拶

終演後 再びスライムのぬいぐるみを持って現れた堀井雄二が客席先頭のひとにぬいぐるみを渡していた。いいなあ

_ [艦これ]艦これ

鈴谷を改造した。


2014-02-08 :-)

_ 午前

1100 起床 || 部屋掃除

雪、積もってるよ

IMG_3763

_ 午後

1200 おひる。うどん

1300 アニメ消化

_

1700 アニメ消化

1800 読書

2100 飯。きすけ の牛たんカレー

IMG_3770


2014-02-09 :-)

_ 午前

0930 起床

1000 おひる。スパゲティ

IMG_3791

雪、積もってた

IMG_3792

_ 午後

1300 散歩しつつ

1400 どこぞ

1430 どこぞの試飲会 || 飲み過ぎたか || 帰宅時にすでに頭がいたい

IMG_3799

_

1600 アニメ消化

2100 飯。ブリの照り焼き


2014-02-10 :-(

_ 午前

0530 起床

0830 出勤 || デバッグしTARI

_ 午後

1300 デバッグしTARI

_

1700 残業アワー

1800 退勤 || 客先へ報告メールを投げた直後に「違う。問題の本質はそこじゃない」ということに気づいたんだが気づいたときには既に敷地の改札口を出ていた

1900 川崎

2100 飯

2200 読書

_ 買い物

アニメイト川崎

B00I0CEMTU

_ [ruby][queue]queue (1)

がんばって自力で

#: coding: utf-8

class Queue
  def initialize(size)
    @queue = Array.new(size)
    @head = 0
    @tail = 0
  end
  
  def get()
    item = @queue[@head]
    @head = (@head + 1) % @queue.length
    return item
  end
  
  def put(item)
    @queue[@tail] = item
    @tail = (@tail + 1) % @queue.length
  end
  
  def size()
    return @queue.length
  end
end

def main(argv)
  max = 5
  queue = Queue.new(max)
  0.upto(max - 1) {|n|
    queue.put(n)
  }
  
  0.upto(queue.size() - 1) {|n|
    puts queue.get()
  }
end

main(ARGV)
>ruby queue0.rb
0
1
2
3
4

_ [ruby][queue]queue (2)

Array が全部持ってるわけですが

#: coding: utf-8

class Queue
  def initialize()
    @queue ||= []
  end
  
  def get()
    return nil if @queue.empty?
    return @queue.shift()
  end
  
  def put(item)
    @queue.push(item)
  end
end

def main(argv)
  max = 5
  queue = Queue.new()
  0.upto(max - 1) {|n|
    queue.put(n)
  }
  
  0.upto(max -1) {|n|
    puts queue.get()
  }
end

main(ARGV)
>ruby queue1.rb
0
1
2
3
4

_ 尽きる

たまに聞くと心が安らぐ。


2014-02-11 :-)

_ 午前

0930 起床

1020 おひる。スパゲティ

1100 アニメ消化

_ 午後

1200 買い物

1400 アニメ消化

IMG_3806

_

1700 読書

1900 マルチスレッドがどうのこうの

2100 飯。きすけ の牛たん

_ 買い物

iTuns Store

桐崎千棘・小野寺小咲(東山奈央・花澤香菜)「本命アンサー - Single」 ニセコイ キャラクターソング

_ [NetBSD][マニュアル][man][PDF]NetBSD マニュアルの PDF を作成する

hubertf が「マニュアル印刷して持ち歩こうぜ」と言っていた[ 20140117#p06 ]のでやってみた。

とりあえず make

% cd /usr/src/share/man/man0
% make
/bin/sh mkman
Preparing data ...
 :
Chewing on man7pages.pdf
sh: /usr/src/tooldir.NetBSD-6.1.2-i386/bin/nbsed: not found
ps2pdf: not found
Chewing on man8pages.pdf
sh: /usr/src/tooldir.NetBSD-6.1.2-i386/bin/nbsed: not found
ps2pdf: not found
Chewing on man9pages.pdf
sh: /usr/src/tooldir.NetBSD-6.1.2-i386/bin/nbsed: not found
ps2pdf: not found

エラー

ps2pdf ってなんだよ

ググる

pkgsrc.se - ./meta-pkgs/netbsd-www

netbsd-www ぽい?

cd /usr/pkgsrc/meta-pkgs/netbsd-www

Makefile を見たらそれっぽいのあった。これらしい。

USE_TOOLS+=     perl:run ps2pdf:run

netbsd-www を make する。

 :
/bin/sh ./config.status --recheck
  CXX      libgv_lua_la-gv_lua.lo
In file included from gv_lua.cpp:1525:0:
../../config.h:568:0: warning: "NO_POSTSCRIPT_ALIAS" redefined
<command-line>:0:0: note: this is the location of the previous definition
gv_lua.cpp:5733:1: error: elements of array 'const luaL_reg swig_commands []' have incomplete type
gv_lua.cpp:5733:1: error: storage size of 'swig_commands' isn't known
gv_lua.cpp: In function 'int luaopen_gv(lua_State*)':
gv_lua.cpp:6029:19: error: 'LUA_GLOBALSINDEX' was not declared in this scope
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/graphics/graphviz/work/graphviz-2.34.0/tclpkg/gv
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/graphics/graphviz/work/graphviz-2.34.0/tclpkg/gv
cd .. && /usr/bin/make  am--refresh
/bin/sh ./config.status --recheck
make: don't know how to make gv/pkgIndex.tcl. Stop

make: stopped in /usr/pkgsrc/graphics/graphviz/work/graphviz-2.34.0/tclpkg
*** Error code 1

Stop.
make: stopped in /usr/pkgsrc/graphics/graphviz/work/graphviz-2.34.0/tclpkg

おこなの

「pkgsrc でエラーになるならバイナリパッケージを入れればいいじゃない」( Re: meta-pkgs/xfce4 XML::Parser... configure: error ) と言われたこともあるので pkg_add する。

設定

PATH="/usr/pkg/sbin:$PATH"
PKG_PATH="ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/6.1.2/All/"
export PATH PKG_PATH

以降 エラーになるやつはすべて pkg_add していく。netbsd-www も pkg_add すればいいじゃない とか言わない。

pkg_add graphviz-2.34.0nb5
pkg_add doxygen-1.8.5
pkg_add boehm-gc-7.2e
pkg_add jasper-1.900.1nb7
 :

netbsd-www を入れ終えたら再度作る。

作ってみたものの PDF が 3KB しかなかった。

make のログを見たら怒られていた。

 :
grops:<standard input> (<standard input>):459122: duplicate `x res' command
grops:<standard input> (<standard input>):459122:warning: too many arguments on current line
grops:<standard input> (<standard input>):459123: duplicate `x init' command
grops:<standard input> (<standard input>):460678:warning: no final `x stop' command
for i in 1 2 3 4 5 6 7 8 9 ; 					 do							 echo Chewing on man${i}pages.pdf ;		 /usr/src/tooldir.NetBSD-6.1.2-i386/bin/nbsed 					 -e '/^\/level0 0 def/d' 		 -e '/^\/level0 save/d' 			 -e '/^level0 restore/d' 			 <man${i}pages.ps >man${i}pages.ps.tmp ;  ps2pdf man${i}pages.ps.tmp man${i}pages.pdf ;	 rm man${i}pages.ps.tmp ; 			 done
Chewing on man1pages.pdf
sh: /usr/src/tooldir.NetBSD-6.1.2-i386/bin/nbsed: not found
Chewing on man2pages.pdf
sh: /usr/src/tooldir.NetBSD-6.1.2-i386/bin/nbsed: not found
Chewing on man3pages.pdf
sh: /usr/src/tooldir.NetBSD-6.1.2-i386/bin/nbsed: not found
Chewing on man4pages.pdf
sh: /usr/src/tooldir.NetBSD-6.1.2-i386/bin/nbsed: not found
Chewing on man5pages.pdf
sh: /usr/src/tooldir.NetBSD-6.1.2-i386/bin/nbsed: not found
Chewing on man6pages.pdf
sh: /usr/src/tooldir.NetBSD-6.1.2-i386/bin/nbsed: not found
Chewing on man7pages.pdf
sh: /usr/src/tooldir.NetBSD-6.1.2-i386/bin/nbsed: not found
Chewing on man8pages.pdf
sh: /usr/src/tooldir.NetBSD-6.1.2-i386/bin/nbsed: not found
Chewing on man9pages.pdf
sh: /usr/src/tooldir.NetBSD-6.1.2-i386/bin/nbsed: not found

nbsed が無いらしい。nbsed は /usr/src/tooldir にあるらしいので tools を作る。なぜ tools の sed なんて使うんだ?と思ったが man0 が /usr/src/share/man/man0 にあるから tools に依存させてるのか。

% cd /usr/src
% ./build.sh tools

再度 make

% cd /usr/src/share/man/man0
% make

今度こそ ok


2014-02-12 :-(

_ 午前

0530 起床

0830 出勤 || デバッグしTARI

_ 午後

1300 デバッグしTARI

_

1700 退勤

1900 マルチスレッドがどうのこうの

2100 飯

_ 買い物

iTunes Store

坂本真綾の曲を買うのは 10 年ぶりくらいか。

たぶんこの辺が最後。2003 年リリースだからほんとに 10 年だった。まあいろいろあった

B0035NO6LI

_ [Java][Ruby][マルチスレッド][デザインパターン]Java言語で学ぶデザインパターン入門マルチスレッド編 Single Threaded Execution - この橋を渡れるのは、たった一人

写経するために Ruby で書きなおしてみた。Java から Ruby へ

Ruby ぽく書ける箇所は多々あるんだろうけど愚直に 1 対 1 対応させる。

Java の Synchronize は Ruby には無いので Monitor を使う。

同時に 1 つのスレッドのみが処理を実行できる。クリティカルセクションとか呼ばれる

コード

# coding: utf-8

#
# 『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』 http://www.hyuki.com/dp/dp2.html
# 
# Single Threaded Execution - この橋を渡れるのは、たった一人
#

require 'thread'
require 'monitor'

class Gate
  def initialize()
    @counter = 0
    @name = "Nobody"
    @address = "Nowhere"
    @lock = Monitor.new
  end

  def pass(name, address)
    @lock.synchronize {
      @counter += 1
      @name = name
      @address = address
      check()
    }
  end

  def to_s()
    @lock.synchronize {
      return "No. #{@counter}: #{@name} #{@address}"
    }
  end
  
  def check()
    puts to_s()
    if @name[0] != @address[0]
      puts "***** BROKEN ***** " + to_s()
    end
  end
end

class UserThread < Thread
  def initialize(gate, myname, myaddress)
    @gate = gate
    @myname = myname
    @myaddress = myaddress
    
    super() {
      puts @myname + " BEGIN"
      while true
        @gate.pass(@myname, @myaddress)
        sleep(1)
      end
    }
    
  end
end

def main(argv)
  gate = Gate.new
  threads ||= []

  threads << UserThread.new(gate, "Alice", "Alaska")
  threads << UserThread.new(gate, "Bobby", "Brazil")
  threads << UserThread.new(gate, "Chris", "Canada")
  threads.each {|t|
    t.join()
  }
end

main(ARGV)
% ruby SingleThreadedExecution.rb
Alice BEGIN
No. 1: Alice Alaska
Bobby BEGIN
No. 2: Bobby Brazil
Chris BEGIN
No. 3: Chris Canada
No. 4: Alice Alaska
No. 5: Bobby Brazil
No. 6: Chris Canada
No. 7: Chris Canada
No. 8: Bobby Brazil
No. 9: Alice Alaska
No. 10: Chris Canada
No. 11: Alice Alaska
No. 12: Bobby Brazil
No. 13: Alice Alaska
No. 14: Bobby Brazil
No. 15: Chris Canada
No. 16: Chris Canada
No. 17: Alice Alaska
No. 18: Bobby Brazil
以下略

著作権

Copyright (C) 2002,2006 Hiroshi Yuki.
http://www.hyuki.com/dp/dp2.html
hyuki@hyuki.com

This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is not
required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

参考

『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』

4797331623


2014-02-13 :-(

_ 午前

0530 起床

0830 出勤 || デバッグしTARI

_ 午後

1300 デバッグしTARI

_

1700 残業アワー

2030 退勤

2200 飯

_ [Java][Ruby][マルチスレッド][デザインパターン]Java言語で学ぶデザインパターン入門マルチスレッド編 Immutable - 壊したくとも、壊せない

インスタンスが不変であることを保証する。Synchroinze を使わずとも複数のスレッドから読まれても OK (書く手段を提供しないため)

# coding: utf-8

#
# 『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』 http://www.hyuki.com/dp/dp2.html
# 
# Immutable - 壊したくとも、壊せない
#

require 'thread'
require 'monitor'

class Person
  def initialize(name, address)
    @name = name
    @address = address
  end
  
  def getName()
    return @name
  end
  
  def getAddress()
    return @address
  end
  
  def to_s()
    return "[ Person: name = #{@name} address = #{@address} ]"
  end
end

class PrintPersonThread < Thread
  def initialize(person, name)
    @person = person
    @name = name
    
    block = Proc.new() {
      while true
        puts "Thread-#{@name} prints #{@person}"
      end
    }
    super(&block)
  end
end

def main(argv)
  alice = Person.new("Alice", "Alaska");
  th ||= []
  th << PrintPersonThread.new(alice, 0)
  th << PrintPersonThread.new(alice, 1)
  th << PrintPersonThread.new(alice, 2)
  th.each {|t| t.join() }
end

main(ARGV)
% ruby Immutable.rb
Thread-0 prints [ Person: name = Alice address = Alaska ]
Thread-0 prints [ Person: name = Alice address = Alaska ]
Thread-0 prints [ Person: name = Alice address = Alaska ]
Thread-0 prints [ Person: name = Alice address = Alaska ]
Thread-1 prints [ Person: name = Alice address = Alaska ]
Thread-1 prints [ Person: name = Alice address = Alaska ]
Thread-1 prints [ Person: name = Alice address = Alaska ]
Thread-1 prints [ Person: name = Alice address = Alaska ]
Thread-1 prints [ Person: name = Alice address = Alaska ]
Thread-1 prints [ Person: name = Alice address = Alaska ]
Thread-1 prints [ Person: name = Alice address = Alaska ]
Thread-1 prints [ Person: name = Alice address = Alaska ]
Thread-1 prints [ Person: name = Alice address = Alaska ]
Thread-2 prints [ Person: name = Alice address = Alaska ]
Thread-2 prints [ Person: name = Alice address = Alaska ]
Thread-2 prints [ Person: name = Alice address = Alaska ]
Thread-2 prints [ Person: name = Alice address = Alaska ]
Thread-2 prints [ Person: name = Alice address = Alaska ]
Thread-2 prints [ Person: name = Alice address = Alaska ]
Thread-2 prints [ Person: name = Alice address = Alaska ]
以下略

ライセンス

Copyright (C) 2002,2006 Hiroshi Yuki.
http://www.hyuki.com/dp/dp2.html
hyuki@hyuki.com

This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is not
required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

参考

『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』

4797331623


2014-02-14 :-)

_ 午前

0800 起床 || お仕事ですね

0900 移動

1000 みなとみらい

1010 CP+

IMG_3822

1100 おひる@ベローチェ 早めにとる

IMG_3834

_ 午後

1200 CP+

_

1800 撤退

2100 飯

_ [CP+]CP+2014

@パシフィコ横浜

行ってきた。

CP+ 技術アカデミーを受講してきたんだけど商品紹介ばかりであった。もう受講しなくていいなあ。

雪景色

IMG_3824

働くおじさん

IMG_3851

ホテルのラストダンジョン感がヤバい。

IMG_3856

パナソニック

撮り損ねた。写真なし。

4K カメラで動画を撮影したけど TFT で再生してもまったく嬉しくない。パナソニック「LUMIX GH4」登場、4K動画撮影できる初めてのミラーレス一眼 : ギズモード・ジャパン

オリンパス

撮り損ねた。写真なし。

イーグルズアイを見たかったけど確認できず。あったのかしら オリンパスからLEDドットサイト照準器つきカメラSTYLUS SP-100EE、光学50倍ズーム望遠撮影用 - Engadget Japanese

DJI

なんかラジコンが飛んでた。Phantom という名前らしい。設計したひとはゼビウスのファンに違いない スーパーゼビウス ガンプの謎 - Wikipedia

IMG_3829

IMG_3827

シグマ

シグマのこれ触ってきた。ああ、うん....?

IMG_3832

ハッセルブラッド

「ハッセルブラッドに行ってみるがいい」と Twitter で replay を貰ったので行ってみた。高級品らしい。外人ばかりでこわかった。これは欲しいな(形状だけ)s

IMG_3837

キヤノン

キヤノンのブースに行ったらちょうどトークショーが開始されるところだったので眺めていた。Power Shot G1 X Mark II でローアングルがいいですよ!とのこと。

IMG_3841

EOS M2 を触ってみたけど、ライブビューがすげえ重いんですが。AF もそんなに速くなってるように見えん。うーん

MREAL とやら( 現実と仮想を融合する -Mixed Realityシステム MREAL- ) AR と同じようなもんだろうと思うんだけどどうやって自分の位置を把握してるのかと思ったらてっぺんに付いてるのが磁気センサーらしく、すぐ脇に設置してあった棒状の物との位置関係で把握するんだそうだ。

IMG_3842

シネマなんとか

IMG_3843

シネマなんとか。超高そうなので怖くて触らなかった。CINEMA EOS SYSTEM|EOS-1D C

IMG_3845

CP+ 技術アカデミー

Nikon 1 AW1の開発

八木成樹(株式会社ニコン)

  • 商品企画
    • あらゆるシーンで使えるカメラを作る
      • 耐久性
      • 日常での携帯性
      • 高級感
      • とかいろいろ
LUMIX一眼動画の取組み

前川直也(パナソニック株式会社)

  • 経歴
    • 学生時代
      • 映像のスタジオでバイトしてた
    • パナソニックへ転職
      • 最初に映像機器に配属された
      • 次にデジタルカメラに配属された
      • ソフトウェア指揮ってる
      • いま GH4
  • Panasonic LUMIX GH4
    • ヴィーナスエンジン
    • 新規開発した
    • 大変だった
  1. 1 機種作って
  2. プラットホーム作って
  3. GH4 に展開した

プロトタイプを作ってノウハウを蓄えてライブラリ化して展開。ということかな

  • 動画撮影機器
    • あるカメラマン曰く
    • 一眼を作ってるところの動画カメラだから買う
    • 業務用の動画カメラは高価だし
    • 一眼なら同じ金額で 2 台買えるし
    • 一眼のノウハウ(ホワイトバランスとかシャッタースピードとか)が活かされている

そうなん?動画も結局は静止画の集まりなのだからその辺のノウハウは共通してそうなんだけど。

  • PAL/NTSC 切り替え
    • 切り替え時にカメラの電源を OFF→ON させるようにしている
    • ソフトウェアとしては電源を入り切りする必要はないのだが
    • 業務用のカメラは電源 OFF→ON させるようになっている
    • 映像業界の人達も PAL/NTSC 切り替え時に電源 OFF→ON することが習慣になっている
    • その習慣にならって GH4 も電源を OFF→ON させるようにしている

すげえ無駄な...

全天球画像撮影デバイス"RICOH THETA"の開発

竹中博一(株式会社リコー)

画像処理担当

  1. 2 眼で撮影し
  2. パターンマッチングで 2 画像を処理し
  3. 繋ぎ合わせる
  • 左目の画像と右目の画像を基準画像と比較画像としてパターンマッチング
  • 左目と右目で視点が異なる
  • 視差が起きる
  • 写す対象が異なるので対象までの距離が異なる

普通にパターンマッチングらしい

_ [艦これ]艦これ

なんか貰った。

模様替えするなど


2014-02-15 :-)

_ 午前

0900 起床 && 部屋掃除

1010 おひる。うどん

1030 アニメ消化

_ 午後

1200 買い物

1500 アニメ消化

IMG_3868

_

1700 ぐったり。部屋の那珂が温まらないのでオフトゥン.in

2100 飯。アジの開き

2200 おやつ。クラシックショコラ( ref. ちゃんと作れるスイーツ pp.26-27 ) 最近作ってなかった。

IMG_3878

_ [Java][Ruby][マルチスレッド][デザインパターン]Java言語で学ぶデザインパターン入門マルチスレッド編 Guarded Suspension - 用意できるまで、待っててね

リクエストが put されるまで get はブロックする。待機する。

スピンロックなどとも言う。

# coding: utf-8

#
# 『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』 http://www.hyuki.com/dp/dp2.html
# 
# Guarded Suspension - 用意できるまで、待っててね
#

require 'thread'
require 'monitor'

class Request
  def initialize(name)
    @name = name
  end
  
  def getName()
    return @name
  end
  
  def to_s()
    return "[ Request #{@name} ]"
  end
end

class RequestQueue
  def initialize()
    @lock = Monitor.new()
    @cond = @lock.new_cond
    @queue ||= []
  end
  
  def getRequest()
    @lock.synchronize {
      while @queue.empty? == true
        begin
          @cond.wait()
        rescue
        end
      end
      return @queue.pop()
    }
  end
  
  def putRequest(request)
    @lock.synchronize {
      @queue.push(request)
      @cond.broadcast()
    }
  end
end

class ServerThread < Thread
  def initialize(requestQueue, name, seed)
    @requestQueeu = requestQueue
    @random = Random.new(seed)
    
    block = Proc.new {
      0.upto(10) {|i|
        request = requestQueue.getRequest()
        puts "#{self} handles #{request}"
        begin
          sleep(random.rand(10))
        rescue
        end
      }
    }
    super(&block)
  end
end

class ClientThread < Thread
  def initialize(requestQueue, name, seed)
    @requestQueue = requestQueue
    @random = Random.new(seed)
    
    block = Proc.new {
      0.upto(10) {|i|
        request = Request.new("No. #{i}")
        puts "#{self} requests #{request}"
        @requestQueue.putRequest(request)
        begin
          sleep(random.rand(10))
        rescue
        end
      }
    }
    super(&block)
  end
end

def main(argv)
  th ||= []
  requestQueue = RequestQueue.new()
  th << ServerThread.new(requestQueue, "Bobby", 6535897)
  th << ClientThread.new(requestQueue, "Alice", 3141592)
  th.each {|t| t.join() }
end

main(ARGV)
ruby GuardedSuspension.rb
#<ClientThread:0x000000002fbde0> requests [ Request No. 0 ]
#<ClientThread:0x000000002fbde0> requests [ Request No. 1 ]
#<ServerThread:0x00000002abd608> handles [ Request No. 0 ]
#<ClientThread:0x000000002fbde0> requests [ Request No. 2 ]
#<ServerThread:0x00000002abd608> handles [ Request No. 1 ]
#<ClientThread:0x000000002fbde0> requests [ Request No. 3 ]
#<ServerThread:0x00000002abd608> handles [ Request No. 2 ]
#<ClientThread:0x000000002fbde0> requests [ Request No. 4 ]
#<ServerThread:0x00000002abd608> handles [ Request No. 3 ]
#<ClientThread:0x000000002fbde0> requests [ Request No. 5 ]
#<ServerThread:0x00000002abd608> handles [ Request No. 4 ]
#<ClientThread:0x000000002fbde0> requests [ Request No. 6 ]
#<ServerThread:0x00000002abd608> handles [ Request No. 5 ]
#<ClientThread:0x000000002fbde0> requests [ Request No. 7 ]
#<ServerThread:0x00000002abd608> handles [ Request No. 6 ]
#<ClientThread:0x000000002fbde0> requests [ Request No. 8 ]
#<ServerThread:0x00000002abd608> handles [ Request No. 7 ]
#<ClientThread:0x000000002fbde0> requests [ Request No. 9 ]
#<ServerThread:0x00000002abd608> handles [ Request No. 8 ]
#<ClientThread:0x000000002fbde0> requests [ Request No. 10 ]
#<ServerThread:0x00000002abd608> handles [ Request No. 9 ]
#<ServerThread:0x00000002abd608> handles [ Request No. 10 ]

ライセンス

Copyright (C) 2002,2006 Hiroshi Yuki.
http://www.hyuki.com/dp/dp2.html
hyuki@hyuki.com

This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is not
required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

参考

『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』

4797331623


2014-02-16 :-)

_ 午前

0930 起床

1020 おひる。カルボナーラ。昨日 生クリームを余らせたので生クリームを使った(普段は代わりに牛乳を使っている。生クリームなんぞそう買わない)

1100 アニメ消化

IMG_3880

_ 午後

1200 アニメ消化

1400 散歩

IMG_3887

_

1700 読書

2100 飯。ぶりの塩焼き

_ [NetBSD][jenkins][pkgsrc]Jenkins をインストールしてみた

% cd /usr/pkgsrc/devel/jenkins
% cmake install clean clean-depends

 :

===========================================================================
$NetBSD: MESSAGE,v 1.1.1.1 2011/12/08 14:09:25 ryoon Exp $

To use jenkins with apache tomcat, you will need to perform the following
steps. Of cource you can run jenkins with builtin winstone web server.

1. Install apache tomcat server, for example apache-tomcat7

        # cd www/apache-tomcat7
        # make install

2. Set jenkins location to apache tomcat
        $ sudo vi /usr/pkg/share/tomcat/conf/server.xml
        Add
        <Context path="/jenkins" docBase="/usr/pkg/share/jenkins"
                debug="0" reloadable="true">
        </Context>
        in <Host> tag

3. Set URI Encoding as UTF-8
        $ vi /usr/pkg/share/tomcat/conf/server.xml
        You should have
        URIEncoding="UTF-8"
        in <Connector/> tag. For example, you should have the following
        lines.
        <Connector port="8080" protocol="HTTP/1.1"
                connectionTimeout="20000"
                redirectPort="8443" URIEncoding="UTF-8"/>

4. Start apache tomcat and access http://localhost:8080/jenkins/
===========================================================================

ok

tomcat を使うらしいので上の手順どおりに作業する。

終わったら

rc ファイルをコピー。

% sudo cp  /usr/pkg/share/examples/rc.d/tomcat  /etc/rc.d

/etc/rc.conf に追加

tomcat=yes

起動

% sudo /etc/rc.d/tomcat start
Using CATALINA_BASE:   /usr/pkg/share/tomcat
Using CATALINA_HOME:   /usr/pkg/share/tomcat
Using CATALINA_TMPDIR: /usr/pkg/share/tomcat/temp
Using JRE_HOME:        /usr/pkg/java/openjdk7
Using CLASSPATH:       /usr/pkg/share/tomcat/bin/bootstrap.jar:/usr/pkg/share/tomcat/bin/tomcat-juli.jar
Using CATALINA_PID:    /var/run/tomcat/catalina.pid

http://localhost:8080/jenkins/ にアクセスしてみる。

ok

pf

当初は http://localhost:8080/jenkins/ にアクセスしてもつながらなかった。結局 pf で弾いていたからなんだけど

以下その作業ログ

タイムアウト

http://localhost:8080/jenkins/ にアクセスしてみる。

タイムアウトした。

ログを見る。

/var/log にログが見当たらない。

ログはどこだ。

/etc/rc.d/tomcat で以下のように起動している。

tomcat_start()
{
        cd $CATALINA_HOME/logs
        /usr/bin/su ${tomcat_user} -c "${command} start"
}

CATALINA_HOME は /usr/pkg/share/tomcat として定義されている。

移動してみる。

% cd /usr/pkg/share/tomcat/logs

いくつかファイルがある。

% ls
catalina.2014-02-16.log  host-manager.2014-02-16.log  localhost_access_log.2014-02-16.txt
catalina.out             localhost.2014-02-16.log     manager.2014-02-16.log

とりあえず片っ端から見る。

例外が起きてる?

% tail catalina.out
        at javax.jmdns.JmDNS.create(JmDNS.java:60)
        at hudson.DNSMultiCast$1.call(DNSMultiCast.java:32)
        at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
        at java.util.concurrent.FutureTask.run(FutureTask.java:166)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
        at java.lang.Thread.run(Thread.java:722)

2 16, 2014 12:03:57 午前 hudson.WebAppMain$2 run
情報: Jenkins is fully up and running

例外が起きているものの、top を見ると java が起動している。死んでるわけではないらしい。よく分からん。

同じホスト( mogu )から http://localhost:8080/jenkins/ へアクセスしてみる。

起動してた。

ということは jenkins (のウェブサーバー)の待ち受けアドレスをどうにかすればいいのか。

どこで設定してるんだ。

grep してみる。

% cd /usr/pkg/share/tomcat/conf
% sudo grep -r Listen *
server.xml:  <Listener className="org.apache.catalina.security.SecurityListener" />
server.xml:  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
server.xml:  <Listener className="org.apache.catalina.core.JasperListener" />
server.xml:  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
server.xml:  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
server.xml:  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

いやー、その Listener は違うっしょ。イベントの受け口としてのリスナでしょ。

分からん。

pkgsrc でインストールしたときのログをちゃんと見てみると...おや?

 To use jenkins with apache tomcat, you will need to perform the following
 steps. Of cource you can run jenkins with builtin winstone web server.

winstone web server is 何

公式に文書があるじゃないか。

Starting and Accessing Jenkins - Jenkins - Jenkins Wiki

The easiest way to execute Jenkins is through the built in Winstone servlet container.

「Jenkins は簡単に起動できる。そう、Winstone ならね。」

ああ、そういうこと。

FreeBSD についての文書もあったのでパクる。

FreeBSD - Jenkins - Jenkins Wiki

待ち受けアドレスとポートはデフォルトで 0.0.0.0 8080 らしいので指定しない。

% JAVA_HOME=/usr/pkg/java/openjdk7 /usr/pkg/java/openjdk7/bin/java -jar /usr/pkg/share/jenkins/jenkins.war --webroot=/usr/pkg/share/jenkins/war --prefix=/jenkins

やはり同じホストからしかアクセスできない。

ということは pf か!

とりあえず pf を停止

% sudo /etc/rc.d/pf stop

別のホストからアクセスしてみる。

ok

動作確認できたので /etc/pf.conf にポート 8080 を追加しておく。

tcp_services = "{ ssh, www, smtp, domain, munin, netbios-ssn, microsoft-ds, 6667, 8080 }"

しかし 8080 は redmine とかでも使っていたような記憶があるから 8080 から変えたほうがいいんだろうなあ。

_ [文書][ドキュメント][マニュアル]文書陳腐化問題

入門者向け文書

右も左も分からない開発者のこと。とする

チュートリアルとか get started 的なものが欲しい。

e.g.

中級者向け文書

右や左は分かるようになった開発者のこと。とする

何が居るだろうか。

  • リファレンス?
  • 内部構造?
  • wiki のような散文?
  • デバッグ方法?

e.g.

陳腐化

BSD BoF[ 20131221#p04 ] のときに「翻訳文書がメンテナンスされない」という話題があったけど結局 解は無かったし(無かったよね)、佐藤広生さん(FreeBSD の偉い人) は

「10年ほど観測して、自然発生的に日本語ドキュメントが書かれたりコミュニティが活発になるのを期待するのは無理だと分かった」

と言っていたし、対策として専任のライターをつける と言っていたし。

Ruby も「リファレンスマニュアル刷新計画」(るりまプロジェクト) として体制を作ってるし。

開発者たちが片手間に文書をメンテナンスするのは無理なのか。

_ 文書陳腐化問題 (2)

ランク付けするとか

  • 初級技
  • 中級技
  • 奥義
  • 秘技

ロマサガ(1)のパクリですが。


2014-02-17 :-(

_ 午前

0530 起床

0830 出勤 || デバッグしTARI

_ 午後

1300 デバッグしTARI

_

1700 残業アワー

1930 退勤

2030 部屋探すなど

2130 飯

_ ,

むしろ葛西紀明がまだ現役だったことに驚いた。レジェンド

_ [Java][Ruby][マルチスレッド][デザインパターン]Java言語で学ぶデザインパターン入門マルチスレッド編 Balking - 必要なかったら、やめちゃおう

仕事しようとして条件が満たされてなかったら保留。

  1. もういいかい?
  2. まだだよ ←ガード
  3. もういいかい?
  4. まだだよ ←ガード
  5. もういいかい?
  6. もういいよ
# coding: utf-8

#
# 『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』 http://www.hyuki.com/dp/dp2.html
# 
# Balking - 必要なかったら、やめちゃおう
#

require 'thread'
require 'monitor'

class BData
  def initialize(filename, content)
    @filename = filename
    @content = content
    @changed = true
    @lock = Monitor.new()
  end
  
  def change(newContent)
    @lock.synchronize {
      @content = newContent
      @changed = true
    }
  end
  
  def save()
    @lock.synchronize {
      if @changed == false
        return
      end
      doSave()
      @changed = false
    }
  end
  
  def doSave()
    puts "#{Thread.current} calls doSave, content = #{@content}"
    File.open(@filename, "wb") {|f|
      f.write(@content)
    }
  end
end

class ChangerThread < Thread
  def initialize(name, data)
    @data = data
    @random = Random.new()
    
    block = Proc.new {
      i = 0
      begin
        while true
          @data.change("No. #{i}")
          sleep(1)
          @data.save()
          i += 1
        end
      rescue => ex
        puts ex
      end
    }
    super(&block)
  end
  
end

class SaverThread < Thread
  def initialize(name, data)
    @data = data
    
    block = Proc.new {
      begin
        while true
          @data.save()
          sleep(2)
        end
      rescue => ex
        puts ex
      end
    }
    super(&block)
    
  end
end

def main(argv)
  th ||= []
  data = BData.new("data.txt", "(empty)")
  th << ChangerThread.new("ChangerThread", data)
  th << SaverThread.new("SaverThread", data)
  th.each {|t| t.join() }
end

main(ARGV)
>ruby Balking.rb
#<SaverThread:0x000000002fbdb8> calls doSave, content = No. 0
#<ChangerThread:0x00000002b7e218> calls doSave, content = No. 1
#<SaverThread:0x000000002fbdb8> calls doSave, content = No. 2
#<ChangerThread:0x00000002b7e218> calls doSave, content = No. 3
#<SaverThread:0x000000002fbdb8> calls doSave, content = No. 4
#<ChangerThread:0x00000002b7e218> calls doSave, content = No. 5
#<SaverThread:0x000000002fbdb8> calls doSave, content = No. 6
#<ChangerThread:0x00000002b7e218> calls doSave, content = No. 7
#<SaverThread:0x000000002fbdb8> calls doSave, content = No. 8
#<ChangerThread:0x00000002b7e218> calls doSave, content = No. 9
#<SaverThread:0x000000002fbdb8> calls doSave, content = No. 10
#<ChangerThread:0x00000002b7e218> calls doSave, content = No. 11
#<SaverThread:0x000000002fbdb8> calls doSave, content = No. 12

ライセンス

Copyright (C) 2002,2006 Hiroshi Yuki.
http://www.hyuki.com/dp/dp2.html
hyuki@hyuki.com

This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is not
required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

参考

『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』

4797331623

_ ドッグフードを食べる

Windows NT 開発時のデビッド・カトラーによるメソッドなわけだが

デビッド・カトラー コンピュータ偉人伝 ちえの和WEBページ

ドッグフードを食べる
WindowsNTの最初のバージョンは560万ステップにおよぶコードが書かれたという話だ。その想像を絶する開発の内輪話は参考文献で読んでほしい。 NTの開発には当初OS/2環境が使われていたが、NTのカーネルの部分ができてくると、 NTの開発にNTを使うようにしたらしい。こうするとイヤでもバグを直さざるをえないからだ。このことをドッグフードを食べるといったらしい。それと、毎日その日までのバージョンをビルドするということをカトラーはやった。こうしたことは我々にも非常に参考になる。

「ドッグフードを食べましょう」と云うからには開発コードはもちろんそうだし、自分たちが世に送り出した製品も自分で使っているのは当たり前 なわけですが、まったくそのようになっていないので食べます。といったことを上司に投げるなど。

_ ,

mixi も Twitter もやめた友人が Tumblr には住み着いている。Tumblr は最後の楽園である。

_ ,

tabesugi.net のひとが英語で日記を書くようになってから 2, 3 年経過した。あのひとのエアメールをもらうのが楽しみなので欠かさずにチェックしないといけない( MUST ) 会ったことないけど


2014-02-18 :-(

_ 午前

0530 起床

0710 食堂

0830 出勤 || デバッグしTARI

_ 午後

1300 デバッグしTARI

_

1700 残業アワー

2010 退勤

2200 飯

_ [Java][Ruby][マルチスレッド][デザインパターン]Java言語で学ぶデザインパターン入門マルチスレッド編 Producer-Consumer - わたしが作り、あなたが使う

生産者と消費者

供給と需要

# coding: utf-8

#
# 『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』 http://www.hyuki.com/dp/dp2.html
# 
# Producer-Consumer - わたしが作り、あなたが使う
#

require 'thread'
require 'monitor'

class Table
  def initialize(count)
    @buffer = Array.new(count)
    @head = 0
    @tail = 0
    @count = 0
    @lock = Monitor.new()
    @cond = @lock.new_cond()
  end
  
  def put(cake)
    @lock.synchronize {
      puts "#{Thread.current} puts #{cake}"
      while @count >= @buffer.length
        @cond.wait()
      end
      
      @buffer[@tail] = cake
      @tail = (@tail + 1) % @buffer.length
      @count += 1
      @cond.broadcast()
    }
  end
  
  def take()
    @lock.synchronize {
      while @count <= 0
        @cond.wait()
      end
      
      cake = @buffer[@head]
      @head = (@head + 1) % @buffer.length
      @count -= 1
      @cond.broadcast()
      puts "#{Thread.current} takes #{cake}"
      return cake
    }
  end
end

class EaterThread < Thread
  def initialize(name, table, seed)
    @table = table
    @random = Random.new(seed)
    
    block = Proc.new {
      begin
        cake = table.take()
        sleep(@random.rand(5))
      rescue => ex
        puts ex
      end
    }
    super(&block)
  end
end

class MakerThread < Thread
  def initialize(name, table, seed)
    @random = Random.new(seed)
    @table = table
    @lock = Monitor.new
    @@id = 0  # ケーキの通し番号(コックさん全員共通)
    
    block = Proc.new {
      begin
        sleep(@random.rand(5))
        cake = "[ Cake No. #{nextid()} by #{Thread.current} ]"
        table.put(cake)
      rescue => ex
        puts ex
      end
    }
    
    super(&block)
  end

  def nextid()
    @lock.synchronize {
      @@id += 1
      return @@id
    }
  end
end

def main(argv)
  th ||= []
  table = Table.new(3)
  th << MakerThread.new("MakerThread-1", table, 31415)
  th << MakerThread.new("MakerThread-2", table, 92653)
  th << MakerThread.new("MakerThread-3", table, 58979)
  th << EaterThread.new("EaterThread-1", table, 32384)
  th << EaterThread.new("EaterThread-2", table, 62643)
  th << EaterThread.new("EaterThread-3", table, 38327)
  th.each {|t| t.join() }
end

main(ARGV)
ruby Producer-Consumer.rb
#<MakerThread:0x0000000046bd38> puts [ Cake No. 1 by #<MakerThread:0x0000000046bd38> ]
#<EaterThread:0x0000000046b630> takes [ Cake No. 1 by #<MakerThread:0x0000000046bd38> ]
#<MakerThread:0x0000000046b978> puts [ Cake No. 2 by #<MakerThread:0x0000000046b978> ]
#<EaterThread:0x0000000046b248> takes [ Cake No. 2 by #<MakerThread:0x0000000046b978> ]
#<MakerThread:0x00000002c4c758> puts [ Cake No. 3 by #<MakerThread:0x00000002c4c758> ]
#<EaterThread:0x0000000046b4a0> takes [ Cake No. 3 by #<MakerThread:0x00000002c4c758> ]

ライセンス

Copyright (C) 2002,2006 Hiroshi Yuki.
http://www.hyuki.com/dp/dp2.html
hyuki@hyuki.com

This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is not
required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

参考

『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』

4797331623


2014-02-19 :-(

_ 午前

0530 起床

0710 食堂

0830 出勤 || コード読んだり

_ 午後

1300 コード読んだり

_

1700 退勤

1830 やらないことリスト

2000 飯

2100 祖母へ線香

_ 古めかしい世界感がある。「教会旋法」が使われている楽曲10選 - NAVER まとめ

7年くらい前に友人が「梶浦由記の曲聞いたら教会旋法使ってた」的なことを言っていた。ような気がする

cerbe のことですが

_ [Java][Ruby][マルチスレッド][デザインパターン]Java言語で学ぶデザインパターン入門マルチスレッド編 Read-Write Lock - みんなで読むのはいいけれど、読んでる間は書いちゃだめ

誰かが読んでる間は誰でも読める。けど書けない。

誰も読み書きしていない間に書ける。

Data という名前は Ruby の組み込みクラスかしら。怒られたので名前を変えた。

# coding: utf-8

#
# 『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』 http://www.hyuki.com/dp/dp2.html
# 
# Read-Write Lock - みんなで読むのはいいけれど、読んでる間は書いちゃだめ
#

require 'thread'
require 'monitor'

class ReadWriteLock
  def initialize()
    @lock = Monitor.new()
    @cond = @lock.new_cond()
    @readingReaders = 0  # (A) 実際に読んでいる最中のスレッドの数
    @waitingWriters = 0  # (B) 書くのを待っているスレッドの数
    @writingWriters = 0  # (C) 実際に書いている最中のスレッドの数
    @preferWriter = true  # 書くのを優先するならtrue
  end
  
  def readLock()
    @lock.synchronize {
      while ((@writingWriters > 0) or (@preferWriter and (@waitingWriters > 0)))
        @cond.wait()
      end
      @readingReaders += 1    # (A) 実際に読んでいるスレッドの数を1増やす
    }
  end
  
  def readUnlock()
    @lock.synchronize {
      @readingReaders -= 1    # (A) 実際に読んでいるスレッドの数を1減らす
      @preferWriter = true
      @cond.broadcast()
    }
  end
  def writeLock()
    @lock.synchronize {
      @waitingWriters += 1    # (B) 書くのを待っているスレッドの数を1増やす
      begin
        while ((@readingReaders > 0) or (@writingWriters > 0))
          @cond.wait()
        end
      rescue
      ensure
        @waitingWriters -= 1    # (B) 書くのを待っているスレッドの数を1減らす
      end
      @writingWriters += 1    # (C) 実際に書いているスレッドの数を1増やす
    }
  end
  def writeUnlock()
    @lock.synchronize {
      @writingWriters -= 1    #  (C) 実際に書いているスレッドの数を1減らす
      @preferWriter = false
      @cond.broadcast()
    }
  end
end

class BData
  def initialize(size)
    @lock = ReadWriteLock.new()
    @buffer = Array.new(size)
    @buffer.fill('*')
  end
  
  def read()
    @lock.readLock()
    begin
      return doRead()
    rescue
    ensure
      @lock.readUnlock()
    end
  end

  def write(c)
    @lock.writeLock();
    begin
      doWrite(c)
    rescue
    ensure
      @lock.writeUnlock()
    end
  end

  def doRead()
    newbuf = @buffer.clone()
    slowly()
    return newbuf
  end

  # @buffer を埋めるなら fill() すればいいんだけど
  # 1 文字ごとに slowly() させるのでループしておく
  def doWrite(c)
    0.upto(@buffer.length - 1) {|i|
      @buffer[i] = c
      slowly()
    }
  end
  
  def slowly()
    begin
      sleep(0.5)
    rescue => ex
      puts ex
    end
  end
end

class WriterThread < Thread
  def initialize(data, filler)
    @data = data
    @filler = filler
    @index = 0
    @random = Random.new()
    
    block = Proc.new {
      begin
        while true
          c = nextchar()
          @data.write(c)
          sleep(@random.rand(3))
        end
      rescue => ex
        puts ex
      end
    }
    super(&block)
  end
  
  def nextchar()
    c = @filler[@index]
    @index += 1
    if @index >= @filler.length
      @index = 0
    end
    return c
  end
end

# Thread.current だと分かりづらいので名前をつける
class ReaderThread < Thread
  def initialize(data, n)
    @data = data
    @name = "reader #{n}"
    
    block = Proc.new {
      begin
        while true
          readbuf = @data.read
          puts "#{@name} reads #{readbuf}"
        end
      rescue => ex
        puts ex
      end
    }
    super(&block)
  end
end

def main(argv)
  th ||= []
  data = BData.new(10)
  th << ReaderThread.new(data, 0)
  th << ReaderThread.new(data, 1)
  th << ReaderThread.new(data, 2)
  th << ReaderThread.new(data, 3)
  th << ReaderThread.new(data, 4)
  th << ReaderThread.new(data, 5)
  th << WriterThread.new(data, "ABCDEFGHIJKLMNOPQTSTUVWXYZ")
  th << WriterThread.new(data, "abcdefghijklmnopqrstuvwxyz")
  th.each {|t| t.join() }
end

main(ARGV)

スレッドごとの print は同期できないか

ruby Read-Write-Lock.rb
reader 2 reads ["*", "*", "*", "*", "*", "*", "*", "*", "*", "*"]
reader 5 reads ["*", "*", "*", "*", "*", "*", "*", "*", "*", "*"]reader 1 reads ["*", "*", "*", "*", "*", "*", "*", "*", "*", "*"]

reader 4 reads ["*", "*", "*", "*", "*", "*", "*", "*", "*", "*"]
reader 3 reads ["*", "*", "*", "*", "*", "*", "*", "*", "*", "*"]
reader 0 reads ["*", "*", "*", "*", "*", "*", "*", "*", "*", "*"]
reader 5 reads ["A", "A", "A", "A", "A", "A", "A", "A", "A", "A"]
reader 3 reads ["A", "A", "A", "A", "A", "A", "A", "A", "A", "A"]reader 1 reads ["A", "A", "A", "A", "A", "A", "A", "A", "A", "A"]

reader 4 reads ["A", "A", "A", "A", "A", "A", "A", "A", "A", "A"]
reader 0 reads ["A", "A", "A", "A", "A", "A", "A", "A", "A", "A"]
reader 2 reads ["A", "A", "A", "A", "A", "A", "A", "A", "A", "A"]
reader 5 reads ["a", "a", "a", "a", "a", "a", "a", "a", "a", "a"]
reader 2 reads ["a", "a", "a", "a", "a", "a", "a", "a", "a", "a"]
reader 3 reads ["a", "a", "a", "a", "a", "a", "a", "a", "a", "a"]
reader 0 reads ["a", "a", "a", "a", "a", "a", "a", "a", "a", "a"]
reader 4 reads ["a", "a", "a", "a", "a", "a", "a", "a", "a", "a"]
reader 1 reads ["a", "a", "a", "a", "a", "a", "a", "a", "a", "a"]
reader 2 reads ["B", "B", "B", "B", "B", "B", "B", "B", "B", "B"]
reader 5 reads ["B", "B", "B", "B", "B", "B", "B", "B", "B", "B"]
reader 1 reads ["B", "B", "B", "B", "B", "B", "B", "B", "B", "B"]
reader 4 reads ["B", "B", "B", "B", "B", "B", "B", "B", "B", "B"]reader 3 reads ["B", "B", "B", "B", "B", "B", "B", "B", "B", "B"]

reader 0 reads ["B", "B", "B", "B", "B", "B", "B", "B", "B", "B"]
reader 0 reads ["b", "b", "b", "b", "b", "b", "b", "b", "b", "b"]
reader 2 reads ["b", "b", "b", "b", "b", "b", "b", "b", "b", "b"]
reader 1 reads ["b", "b", "b", "b", "b", "b", "b", "b", "b", "b"]reader 5 reads ["b", "b", "b", "b", "b", "b", "b", "b", "b", "b"]

reader 4 reads ["b", "b", "b", "b", "b", "b", "b", "b", "b", "b"]
reader 3 reads ["b", "b", "b", "b", "b", "b", "b", "b", "b", "b"]
reader 2 reads ["C", "C", "C", "C", "C", "C", "C", "C", "C", "C"]
reader 5 reads ["C", "C", "C", "C", "C", "C", "C", "C", "C", "C"]
reader 1 reads ["C", "C", "C", "C", "C", "C", "C", "C", "C", "C"]reader 3 reads ["C", "C", "C", "C", "C", "C", "C", "C", "C", "C"]

reader 4 reads ["C", "C", "C", "C", "C", "C", "C", "C", "C", "C"]
reader 0 reads ["C", "C", "C", "C", "C", "C", "C", "C", "C", "C"]
reader 0 reads ["c", "c", "c", "c", "c", "c", "c", "c", "c", "c"]
reader 4 reads ["c", "c", "c", "c", "c", "c", "c", "c", "c", "c"]
reader 1 reads ["c", "c", "c", "c", "c", "c", "c", "c", "c", "c"]reader 5 reads ["c", "c", "c", "c", "c", "c", "c", "c", "c", "c"]

reader 3 reads ["c", "c", "c", "c", "c", "c", "c", "c", "c", "c"]
reader 2 reads ["c", "c", "c", "c", "c", "c", "c", "c", "c", "c"]
reader 4 reads ["D", "D", "D", "D", "D", "D", "D", "D", "D", "D"]
reader 3 reads ["D", "D", "D", "D", "D", "D", "D", "D", "D", "D"]reader 5 reads ["D", "D", "D", "D", "D", "D", "D", "D", "D", "D"]

reader 1 reads ["D", "D", "D", "D", "D", "D", "D", "D", "D", "D"]
reader 2 reads ["D", "D", "D", "D", "D", "D", "D", "D", "D", "D"]
reader 0 reads ["D", "D", "D", "D", "D", "D", "D", "D", "D", "D"]

ライセンス

Copyright (C) 2002,2006 Hiroshi Yuki.
http://www.hyuki.com/dp/dp2.html
hyuki@hyuki.com

This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is not
required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

参考

『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』

4797331623


2014-02-20 :-(

_ 午前

0530 起床

0710 食堂

0830 出勤 || コード読んだり

_ 午後

1300 コード読んだり

_

1700 残業アワー

2100 退勤

_ 訃報

父方の祖母が亡くなった

_ 買い物

iTunes Store

_ ,

irb(main):005:0> 5 & 6
=> 4
irb(main):006:0> 5 | 6
=> 7
irb(main):007:0> 10 & 13
=> 8
irb(main):008:0> 10 | 13
=> 15
irb(main):009:0> 30 | 40
=> 62

t.jpg


2014-02-21 :-)

_ 午前

0530 起床 || 本日は全休

0830 通院 && レントゲンをとるなど && とくに異常なし

1000 散髪

1100 おひる。カップラーメン

_ 午後

1200 アニメ消化

1500 散歩

梅はオワコン

IMG_3897

_

1700 飯。弁当

1800 読書

2000 ぐったり

IMG_3905

_ 私の熱い独身活動 ドクカツ! 始まります! フフッヒ

飯を作る気力がないのでインスタントにするなど怠惰なセイカツをしている。

_ ,

ツッコミ spam 増えたなあ。ksg

_ [Java][Ruby][マルチスレッド][デザインパターン]Java言語で学ぶデザインパターン入門マルチスレッド編 Thread-Per-Message - この仕事、やっといてね

メッセージごとにスレッドを起動して処理する。

(起動済スレッドへメッセージを投げるのは Worker-Thread パターン)

# coding: utf-8

#
# 『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』 http://www.hyuki.com/dp/dp2.html
# 
# Thread-Per-Message - この仕事、やっといてね
#

require 'thread'
require 'monitor'

class Host
  def initialize()
    @helper = Helper.new()
  end
  
  def request(count, c)
    puts "        request(#{count}, #{c}) BEGIN"
    t = Thread.new() {
      @helper.handle(count, c)
    }
    puts "        request(#{count}, #{c}) END"
    return t
  end
end

class Helper
  def handle(count, c)
    puts "        handle(#{count}, #{c}) BEGIN"
    0.upto(count) {|i|
      slowly()
      printf c
    }
    puts ""
    puts "        handle(#{count}, #{c}) END"
  end

  def slowly()
    begin
      sleep(2)
    rescue => ex
      puts ex
    end
  end
end

def main(argv)
  th ||= []
  puts "main BEGIN"
  host = Host.new();
  th << host.request(10, 'A')
  th << host.request(20, 'B')
  th << host.request(30, 'C')
  th.each {|t| t.join()}
  puts "main END"
end

main(ARGV)
>ruby Thread-Per-Message.rb
main BEGIN
        request(10, A) BEGIN
        request(10, A) END
        request(20, B) BEGIN
        request(20, B) END
        request(30, C) BEGIN
        request(30, C) END
        handle(10, A) BEGIN
        handle(20, B) BEGIN
        handle(30, C) BEGIN
ACBCABCABCABCBAACBBCACABCBACABCBA
        handle(10, A) END
BCCBBCCBCBCBBCBCBCB
        handle(20, B) END
CCCCCCCCCCC
        handle(30, C) END
main END

ライセンス

Copyright (C) 2002,2006 Hiroshi Yuki.
http://www.hyuki.com/dp/dp2.html
hyuki@hyuki.com

This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is not
required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

参考

『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』

4797331623


2014-02-22 :-)

_ 午前

0800 起床 && 部屋掃除

1000 アニメ消化

1100 買い物

_ 午後

1200 おひる

1300 なんかググったり

1400 買ったまま放置していた CD をエンコードしたり

1500 散歩

IMG_1338

_

1700 飯。弁当 || 弁当生活していたら肥えた。

1800 ぐったり

1900 はてなブックマークがどうのこうの

2100 ImageMagick がどうのこうの

IMG_1343

_ コートのファスナーが壊れた

2002 年の國府田マリ子 Mariko Kouda 2002 NEW YEAR LIVE で買ったはず。ファッションを気にしない場合(通勤とか通勤とか通勤とか)に使っている。10 年以上使ってるのか。

IMG_3908

IMG_3909


2014-02-23 :-)

_ 午前

0800 起床

1000 アニメ消化

_ 午後

1200 おひる

1300 アニメ消化

1400 はてなブックマークがどうのこうの

1500 散歩

IMG_3914

_

1700 ImageMagick がどうのこうの

2130 飯。ぶりの塩焼き

_ 祖母の葬儀

結局私は行かず。両親のみ行ってきた。(宮崎である)

_ [NetBSD][pkgsrc][pkg_add]バイナリパッケージをインストールする

Chapter 4. Using pkgsrc - 4.1.2. Installing binary packages

NetBSD 6.1.2 / i386 とする

配布元 http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/

たとえばここ:

http://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/6.1.2/All/

設定

PATH="/usr/pkg/sbin:$PATH"
PKG_PATH="ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/6.1.2/All/"
export PATH PKG_PATH

インストール

pkg_add gimp-2.8.10
pkg_add mng-2.0.2

_ [ImageMagick][CR2][JPEG]ImageMagick で Canon CR2 ファイルを JPEG へ変換する

環境

NetBSD 6.1.2 / i386 (core i5 の VMWare)

インストール

% cd /usr/pkgsrc/graphics/ImageMagick/
% make install clean clean-depends

Canon CR2 を JPEG へ変換する

ここに 29MB くらいの CR2 があるじゃろ

% /bin/ls -lM
total 57,696
-rwxr--r--  1 rin  users  29,516,818 Feb 22 19:26 IMG_1332.CR2

それを

こうじゃ

% time convert IMG_1332.CR2 IMG_1332.jpg
convert IMG_1332.CR2 IMG_1332.jpg  34.62s user 39.42s system 48% cpu 2:33.14 total

35秒くらい。Digital Photo Professional でもそのくらい時間かかったような気がするので、まあこんなものか。

まとめるとこうか。ファイル名の大文字と小文字区別は tr とか使えば出来るけどまあ。出力先を指定するよりもディレクトリを移動すると楽だからついサブシェル使ってしまうんだけどダサい。

#!/bin/sh

if [ -z $1 ]; then
  echo "convCR2toJPEG.sh <image directory>"
  exit
fi

image_dir=$1
convert_cmd=/usr/pkg/bin/convert

{
  cd ${image_dir}
  find . -type f -name "*.CR2" | while read f; do
    jpg=$(basename ${f} .CR2)".jpg"
    echo ${f} "=>" ${jpg}
    $convert_cmd ${f} ${jpg}
  done
}
% ./convCR2toJPEG.sh ./
./IMG_1332.CR2 => IMG_1332.jpg
./IMG_1334.CR2 => IMG_1334.jpg
./IMG_1333.CR2 => IMG_1333.jpg

ufraw

なおインストールした直後は以下のように怒られた。

% convert ./IMG_1332.CR2 ./IMG_1332.jpg
convert: delegate failed `"ufraw-batch" --silent --create-id=also --out-type=png --out-depth=16 "--output=%u.png" "%i"' @ error/delegate.c/InvokeDelegate/1065.
convert: unable to open image `/var/tmp/magick-175238px9Jm17523d.ppm': No such file or directory @ error/blob.c/OpenBlob/2643.
convert: no images defined `./IMG_1332.jpg' @ error/convert.c/ConvertImageCommand/3127.

前提を確認。

Canon の RAW ファイルについて読み込みはサポートしている。

% convert -list format | grep -i canon
      CR2  r--   Canon Digital Camera Raw Image Format
      CRW  r--   Canon Digital Camera Raw Image Format

ImageMagick をビルドしたときの設定はこう。-ljpeg とかあるよなあと。

% convert -list configure

Path: /usr/pkg/lib/ImageMagick-6.8.6//config-Q16/configure.xml

Name           Value
-------------------------------------------------------------------------------
CC             gcc
CFLAGS         -pthread -I/usr/pkg/include/OpenEXR -I/usr/pkg/include/freetype2 -I/usr/pkg/include -fopenmp -O2 -I/usr/include -I/usr/pkg/include -I/usr/pkg/include/freetype2 -Wall -pthread -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
CODER_PATH     /usr/pkg/lib/ImageMagick-6.8.6/modules-Q16/coders
CONFIGURE      --without-dps --without-fpx --without-gvc --without-jbig --without-lqr --without-modules --disable-assert --with-fontconfig --with-ltdl-include=/usr/pkg/include --with-ltdl-lib=/usr/pkg/lib --with-xml=yes --without-perl --sysconfdir=/usr/pkg/etc --without-x --without-jp2 --without-djvu --without-gslib --without-wmf --prefix=/usr/pkg --build=i486--netbsdelf --host=i486--netbsdelf --mandir=/usr/pkg/man
CONFIGURE_PATH /usr/pkg/etc/ImageMagick-6/
COPYRIGHT      Copyright (C) 1999-2013 ImageMagick Studio LLC
CPPFLAGS       -I/usr/pkg/include/ImageMagick-6
CXX            c++
CXXFLAGS       -O2 -I/usr/include -I/usr/pkg/include -I/usr/pkg/include/freetype2 -pthread
DEFS           -DHAVE_CONFIG_H
DELEGATES      bzlib fftw fontconfig freetype jng jpeg lcms openexr png ps tiff webp xml zlib
DISTCHECK_CONFIG_FLAGS 'CC=gcc' 'CFLAGS=-O2 -I/usr/include -I/usr/pkg/include -I/usr/pkg/include/freetype2' 'CPPFLAGS=-I/usr/include -I/usr/pkg/include -I/usr/pkg/include/freetype2' 'CXX=c++' 'LDFLAGS=-L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib' 'LIBS=' --disable-deprecated --with-quantum-depth=16 --with-umem=no --with-autotrace=no --with-dps=no --with-djvu=no --with-fpx=no --with-gslib=no --with-fontpath= --with-gvc=no --with-jp2=no --with-lqr=no --with-mupdf=no --with-rsvg=no --with-wmf=no --with-perl=no
DOCUMENTATION_PATH /usr/pkg/share/doc/ImageMagick-6
EXEC-PREFIX    /usr/pkg
EXECUTABLE_PATH /usr/pkg/bin
FEATURES       DPC OpenMP
FILTER_PATH    /usr/pkg/lib/ImageMagick-6.8.6/modules-Q16/filters
HOST           i486--netbsdelf
INCLUDE_PATH   /usr/pkg/include/ImageMagick-6
LDFLAGS        -L/usr/pkg/lib -L/usr/lib -Wl,-R/usr/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/pkg/lib
LIB_VERSION    0x686
LIB_VERSION_NUMBER 6,8,6,9
LIBRARY_PATH   /usr/pkg/lib/ImageMagick-6.8.6
LIBS           -lMagickCore -llcms2 -ltiff -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lfreetype -ljpeg -lpng16 -lfftw3 -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lfontconfig -lfreetype -lwebp -lbz2 -Wl,-R/usr/pkg/lib -L/usr/pkg/lib -lIlmImf -lImath -lHalf -lIex -lIexMath -lIlmThread -lxml2 -lz -lm -lgomp
NAME           ImageMagick
PCFLAGS        -fopenmp -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
PREFIX         /usr/pkg
QuantumDepth   16
RELEASE_DATE   2014-02-22
SHARE_PATH     /usr/pkg/share/ImageMagick-6
SHAREARCH_PATH /usr/pkg/lib/ImageMagick-6.8.6/config-Q16
SVN_REVISION   13089
TARGET_CPU     i486
TARGET_OS      netbsdelf
TARGET_VENDOR
VERSION        6.8.6
WEBSITE        http://www.imagemagick.org

Path: [built-in]

Name           Value
-------------------------------------------------------------------------------
FEATURES       OpenMP
NAME           ImageMagick
QuantumDepth   16

いろいろググると、ufraw をインストールしてから ImageMagick をリビルドしろというのを見つけた。

入れる。

% cd /usr/pkgsrc/graphics/gimp-ufraw
% make install clean clean-depends

ImageMagick をリビルド。make update でもいいかもしれず。

% cd /usr/pkgsrc/graphics/ImageMagick
% make deinstall
% make install clean clean-depends

結局これでイケた。

_ [Plagger][Automatic Ruby]汎用自動処理フレームワーク Automatic Ruby とは - 774::Blog

Plagger らしきもの。

手順どおり

README.ja

もちろん開発版を入れる。

% git clone git://github.com/automaticruby/automaticruby.git
% cd automaticruby
% bundle install --path vendor/gems
% bin/automatic scaffold
% bin/automatic -c ~/.automatic/config/example/feed2console.yml

さて、何に使おうか。

_ [艦これ]艦これ

五月雨ちゃんをレベル 99 にするためにここ 2, 3 週間ひたすら 4-3 で潜水艦を狩っているわけですが。

三式ソナーが 1 個しかなかったけど開発したので 2 個装備させてみた。エリート潜水艦は大破までしか出来なかったけど一撃で沈められるようになった。これで安定するかなー。

演習で先日 航空戦隊に重巡、軽巡で挑んだらボロ負けしたので出し惜しみしないで戦艦を編成することにした。装備は 41cm連装砲x2 三式弾 14号対空電探。46cm 欲しい。

楽勝だった。まあレベル高いしな。

本日のツッコミ(全2件) [ツッコミを入れる]

_ Fryght [欲しいものほど出ない、物欲センサーの性能は我々の予想をはるかに上回っております。]

_ みわ [46cm いらない!]


2014-02-24 :-(

_ 午前

0530 起床

0710 食堂

0830 出勤 || デバッグしTARI

_ 午後

1300 デバッグしTARI

_

1700 残業アワー

2045 退勤

2200 飯

_ [カメラ][レンズ][レンズ沼][シグマ]CP+シグマブース「レンズ沼にハマらない写真術」 - YouTube

  • 原則レンズを決める
    • 画角を身につける
    • 絶対画角感
    • 自分の中の基準となる
    • 例 ラの音を一日中聞かせれば絶対音感が身につく ほんとか
  • 原則レンズで10000枚撮る
    • そのレンズでは撮れないものが分かってくる
    • レンズの解像度以上の写真は撮れない
    • レンズを生かす
  • 応用レンズを選ぶ
    • さらに表現の幅を広げる

「写真は場数です」

量が質に転化する!

写真 1 万枚撮影する、というのは同じことを昔聞いたんだが誰から聞いたのだったか。

_ [カメラ][一眼レフ][ミラーレス]レフレックス

レンズから入った撮像を光学ファインダーへ反射させるための仕組みのこと。

一眼レフカメラの「レフ」である。

この「レフ」が無いのが「ミラーレス」である。

よってミラーレスは一眼「レフ」ではない。


2014-02-25 :-(

_ 午前

0530 起床

0710 食堂

0830 出勤 || デバッグしTARI

_ 午後

1300 デバッグしTARI

_

1730 退勤

1830 リポジトリ整理したり

2100 飯。鮭のムニエル

2200 リポジトリ整理したり

_ [Java][Ruby][マルチスレッド][デザインパターン]Java言語で学ぶデザインパターン入門マルチスレッド編 Worker Thread - 仕事が来るまで待ち、仕事が来たら働く

予め起動しておいたスレッドへ仕事を投げる。

apache web server とかでもお馴染み。

# coding: utf-8

#
# 『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』 http://www.hyuki.com/dp/dp2.html
# 
# Worker Thread - 仕事が来るまで待ち、仕事が来たら働く
#

require 'thread'
require 'monitor'

MAX_REQUEST = 100

class Channel
  def initialize(threads)
    @lock = Monitor.new()
    @cond = @lock.new_cond()
    @requestQueue = Array.new(MAX_REQUEST)
    @head = 0;    # 次にtakeRequestする場所
    @tail = 0;    # 次にputRequestする場所
    @count = 0;   # Requestの数
    @threadPool = Array.new(threads)
  end
  
  def startWorkers()
    # join() するとブロックするのでやってはいけない
    0.upto(@threadPool.length - 1) {|i|
      @threadPool[i] = WorkerThread.new("Worker-#{i}", self)
    }
  end
  
  def putRequest(request)
    @lock.synchronize {
      while (@count >= @requestQueue.length)
        begin
          @cond.wait()
        rescue => ex
          puts ex
        end
      end
      @requestQueue[@tail] = request
      @tail = (@tail + 1) % @requestQueue.length
      @count += 1
      @cond.broadcast()
    }
  end

  def takeRequest()
    @lock.synchronize {
      while (@count <= 0)
        begin
          @cond.wait();
        rescue => ex
          puts ex
        end
      end
      request = @requestQueue[@head]
      @head = (@head + 1) % @requestQueue.length;
      @count -= 1
      @cond.broadcast()
      return request
    }
  end
end

class Request
  def initialize(name, number)
    @name = name      # 依頼者
    @number = number  # リクエストの番号
  end
  
  def execute()
    puts "#{Thread.current} executes #{to_s}"
    begin
      sleep(0.1)
    rescue => ex
      puts ex
    end
  end
  
  def to_s()
    return "[ Request from #{@name} No. #{@number} ]"
  end
  
end

class ClientThread < Thread
  def initialize(name, channel)
    @channel = channel
    @name = name
    
    block = Proc.new {
      begin
        i = 0
        while true
          request = Request.new(@name, i);
          @channel.putRequest(request)
          sleep(0.1)
          i += 1
        end
      rescue => ex
        puts ex
      end
      
    }
    super(&block)
  end
end

class WorkerThread < Thread
  def initialize(name, channel)
    @channel = channel
    
    block = Proc.new {
      while true
        request = @channel.takeRequest()
        request.execute()
      end
    }
    super(&block)
  end
end

def main(argv)
  th ||= []
  channel = Channel.new(5);   # ワーカースレッドの個数
  channel.startWorkers()
  th << ClientThread.new("Alice", channel)
  th << ClientThread.new("Bobby", channel)
  th << ClientThread.new("Chris", channel)
  th.each {|t| t.join() }
end

main(ARGV)
>ruby WorkerThread.rb
#<WorkerThread:0x00000002bc7760> executes [ Request from Alice No. 0 ]
#<WorkerThread:0x0000000031bde8> executes [ Request from Bobby No. 0 ]
#<WorkerThread:0x0000000031bb18> executes [ Request from Chris No. 0 ]
#<WorkerThread:0x0000000031b690> executes [ Request from Chris No. 1 ]
#<WorkerThread:0x00000002bc7760> executes [ Request from Alice No. 1 ]
#<WorkerThread:0x0000000031bb18> executes [ Request from Bobby No. 1 ]
#<WorkerThread:0x0000000031bde8> executes [ Request from Alice No. 2 ]
#<WorkerThread:0x0000000031b690> executes [ Request from Chris No. 2 ]
#<WorkerThread:0x0000000031b8c0> executes [ Request from Bobby No. 2 ]
#<WorkerThread:0x0000000031bde8> executes [ Request from Chris No. 3 ]
#<WorkerThread:0x0000000031bb18> executes [ Request from Alice No. 3 ]
#<WorkerThread:0x0000000031b690> executes [ Request from Bobby No. 3 ]
#<WorkerThread:0x0000000031bb18> executes [ Request from Alice No. 4 ]
#<WorkerThread:0x00000002bc7760> executes [ Request from Chris No. 4 ]
#<WorkerThread:0x0000000031b8c0> executes [ Request from Bobby No. 4 ]
#<WorkerThread:0x0000000031b690> executes [ Request from Alice No. 5 ]
以下略

ライセンス

Copyright (C) 2002,2006 Hiroshi Yuki.
http://www.hyuki.com/dp/dp2.html
hyuki@hyuki.com

This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is not
required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

参考

『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』

4797331623


2014-02-26 :-(

_ 午前

0530 起床

0710 食堂

0830 出勤 || デバッグしTARI

_ 午後

1300 デバッグしTARI

_

1700 退勤

1730 仕事場のプール && 冬になってから行ってなかった && 片道 25m 泳ぐだけで息が切れるというか心臓がバクバクいうんだけど

1900 ウェブ巡回

2000 飯

2100 はてなブックマークがどうのこうの

_ [Java][Ruby][マルチスレッド][デザインパターン]Java言語で学ぶデザインパターン入門マルチスレッド編 Future - 引換券を、お先にどうぞ

先に発注だけおこないあとで成果物を受け取る。

# coding: utf-8

#
# 『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』 http://www.hyuki.com/dp/dp2.html
# 
# Future - 引換券を、お先にどうぞ
#

require 'thread'
require 'monitor'

class BData
  def getContent()
  end
end

class RealData < BData
  def initialize(count, c)
    @content = ""
    puts "        making RealData(#{count}, #{c}) BEGIN"
    buffer = Array.new(count)
    0.upto(count - 1) {|i|
      buffer[i] = c
      begin
        sleep(0.1)
      rescue => ex
        puts ex
      end
    }
    puts "        making RealData(#{count}, #{c}) END"
    @content = buffer.join()
  end
  
  def getContent()
    return @content
  end
end

class FutureData < BData
  def initialize()
    @lock = Monitor.new
    @cond = @lock.new_cond()
    @realdata = nil
    @ready = false
  end

  def setRealData(realdata)
    @lock.synchronize() {
      if @ready
        return  # balk
      end
      @realdata = realdata
      @ready = true
      @cond.broadcast()
    }
  end
  
  def getContent()
    @lock.synchronize() {
      while @ready == false
        begin
          @cond.wait()
        rescue => ex
          puts ex
        end
      end
      return @realdata.getContent()
    }
  end
end

class Host
  def initialize()
  end
  
  def request(count, c)
    puts "    request(#{count}, #{c}) BEGIN"

    # (1) FutureDataのインスタンスを作る
    future = FutureData.new()

    # (2) RealDataを作るための新しいスレッドを起動する
    t = Thread.new() {
      realdata = RealData.new(count, c)
      future.setRealData(realdata)
    }
    
    # join() するとここでブロックするのでやってはいけない
#    t.join()

    puts "    request(#{count}, #{c}) END"

    # (3) FutureDataのインスタンスを戻り値とする
    return future;
  end
end

def main(argv)
  puts "main BEGIN"
  host = Host.new()
  data1 = host.request(10, 'A')
  data2 = host.request(20, 'B')
  data3 = host.request(30, 'C')

  puts "main otherJob BEGIN"
  begin
    sleep(2)
  rescue => ex
    puts ex
  end
  puts "main otherJob END"

  puts "data1 = #{data1.getContent()}"
  puts "data2 = #{data2.getContent()}"
  puts "data3 = #{data3.getContent()}"
  puts "main END"
end

main(ARGV)
>ruby Future.rb
main BEGIN
    request(10, A) BEGIN
    request(10, A) END
    request(20, B) BEGIN
    request(20, B) END
    request(30, C) BEGIN
    request(30, C) END
main otherJob BEGIN
        making RealData(10, A) BEGIN
        making RealData(20, B) BEGIN
        making RealData(30, C) BEGIN
        making RealData(10, A) END
        making RealData(20, B) END
main otherJob END
data1 = AAAAAAAAAA
data2 = BBBBBBBBBBBBBBBBBBBB
        making RealData(30, C) END
data3 = CCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
main END

ライセンス

Copyright (C) 2002,2006 Hiroshi Yuki.
http://www.hyuki.com/dp/dp2.html
hyuki@hyuki.com

This software is provided 'as-is', without any express or implied warranty.
In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it freely,
subject to the following restrictions:

1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is not
required.

2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.

3. This notice may not be removed or altered from any source distribution.

参考

『増補改訂版Java言語で学ぶデザインパターン入門マルチスレッド編』

4797331623


2014-02-27 :-(

_ 午前

0530 起床

0710 食堂

0830 出勤 || デバッグしTARI

_ 午後

1300 デバッグしTARI

_

1700 残業アワー

2000 退勤

2130 飯。塩鮭

2230 Picasa がどうのこうの

_ 買い物

ゲーマーズとか amazon

4832244051

4800223326


2014-02-28 :-(

_ 午前

0530 起床

0710 食堂

0830 出勤 || デバッグしTARI

1100 外出

_ 午後

1230 セミナー@有楽町

1530 退勤

_

1700 flickr がどうのこうの

2100 飯

2200 ぐったり

2530 Σ( ̄□ ̄lll)