先々週は急遽祖母の米寿祝いをやることになり、帰省。山水閣でお食事会

ゴールデンウィークで見た時よりも弱ってた。足悪くすると一気に老けるね。
先付け。鮎の干物、ミョウガの寿司。造り(魚(忘れた)と牛肉)

チーズ入りの茶碗蒸し、絶品。イワナの塩焼き

しゃぶしゃぶ

ご飯

昼の食事会は運転手で飲めなかったので、帰りに月井酒店で大那の純吟のひやおろしと澤姫買ってホテルでぐびぐびやった。

27082010 Haskell
最大回避ヒープ。この章ではjoinの仕方を色々工夫する。他にラウンドロビンヒープとかねじれヒープなどがある。
data Ord a => Tree a = Null | Fork Int a (Tree a) (Tree a) deriving (Show)
isEmpty :: Ord a => Tree a -> Bool
isEmpty Null = True
isEmpty (Fork n x a b) = False
minElem :: Ord a => Tree a -> a
minElem (Fork n x a b) = x
deleteMin :: Ord a => Tree a -> Tree a
deleteMin (Fork n x a b) = merge a b
insert :: Ord a => a -> Tree a -> Tree a
insert x a = merge (Fork 1 x Null Null) a
merge :: Ord a => Tree a -> Tree a -> Tree a
merge a Null = a
merge Null b = b
merge a b
| minElem a <= minElem b = join a b
| otherwise = join b a
join (Fork n x a b) c = Fork (n + size c) x aa (merge bb cc)
where (aa,bb,cc) = orderBySize a b c
orderBySize a b c
| size a == biggest = (a,b,c)
| size b == biggest = (b,a,c)
| size c == biggest = (c,a,b)
where
biggest = size a `max` size b `max` size c
size Null = 0
size (Fork n x a b) = n
いきなり最初の章から面白い。
*Main> insert 5 $ insert 4 $ insert 3 $ insert 2 $ insert 1 Null Fork 5 1 (Fork 2 3 (Fork 1 4 Null Null) Null) (Fork 2 2 (Fork 1 5 Null Null) Null)
26082010 music
予約したもの
26082010 life
スマートグリッドってのは今の電力網に毛が生えたようなもんかなと思ってたけど、全然違った。今後電力は再生可能エネルギーの割合が増えていって、プロシューマーという生産者と消費者が一緒になったような状態(ネットでいえばP2Pみたいにサーバー的なものがない感じか)での電力を有効に機能させる仕組みみたいなものなのね。となるとIPv6が前提か。
文章が硬くて読みにくかったけど、一通り読めた(普通の内容だったら飽きるけど)
電力をうまく貯めるために、バッファとしての電気自動車の電池は有効。本書では太陽光発電ばかりが取り上げられていたが、屋根とか庭に風車があるとかもいいんじゃないか。
あと知りたいのはスマートグリッドとコンパクトシティ構想は補完すんのか?とかそういうあたり。
これも読めばいいのかな。
26082010 Haskell
プログラミングHaskell 9章の練習問題やってないとかいいつつなぜか関数プログラミングの楽しみが手元にあるのであった。
26082010 Haskell
rst2pdf で reStructuredText から PDF を生成するで日本語pdfが生成できるようになってもSphinxでは
[ERROR] pdfbuilder.py:120 BuildEnvironment instance has no attribute 'modules'
....
if self.config.pdf_use_modindex and self.env.modules:
AttributeError: BuildEnvironment instance has no attribute 'modules'
FAILED
とかいうエラーが出る(Sphinx1.02,1.03 + rst2pdf-0.15)
この場合にはrst2pdfの新しい版をsvnでインストール(0.16.dev-r2311をいれた)
あとはSphinxで日本語PDFを生成するの通りにやればうまくいく
中身は全然進んでないのに、出力だけは色々できるようになった ;-)
夏の風物詩

24082010 Flask Processing.js
staticディレクトリにprocessing.jsを置いて
from flask import Flask
app = Flask(__name__)
@app.route("/")
def processing():
response = """
<html>
<head>
<title>Processing Sample</title>
<style type="text/css">
body {margin:0; padding:0;}
</style>
<script type="text/javascript" src="static/processing-0.9.7.js"></script>
<script type="text/javascript">
window.onload = function() {
var canvas = document.getElementsByTagName('canvas')[0];
var codeElm = document.getElementById('processing-code');
var code = codeElm.textContent || codeElm.innerText;
Processing(canvas, code);
};
</script>
<script id="processing-code" type="application/processing">
void setup()
{
size(window.innerWidth, window.innerHeight);
background(102);
smooth();
}
void draw() {
if (mousePressed == true) {
variableEllipse(mouseX, mouseY, pmouseX, pmouseY);
}
}
void variableEllipse(int x, int y, int px, int py)
{
float speed = abs(x-px) + abs(y-py);
stroke(speed);
fill(random(0,255),random(0,255),random(0,255))
ellipse(x, y, speed, speed);
}
</script>
</head>
<body>
<div>
<canvas width="400" height="400"></canvas>
</div>
</body>
"""
return response
if __name__ == "__main__":
app.run()

参考
Built with Processing[Ver. 1.x対応版] -デザイン/アートのためのプログラミング入門24082010 processing VD
processingを使ってデータの視覚化をするための基礎的な本。なのでprocessingでアート的なことをやる本とはちょっと違うかも。
スキャッタープロットとかネットワークを題材に「より効率的にデータを表現する」ということを考えていく。僕は、データとヒトの目という中途半端なデバイスをうまくつなげるミドルウェアのようなものはどういうものが良いのかということを考えていくための教科書的なものと位置づけて読んでる。
7章はズームして掘っていけるようなTreeMapを実装する。TreeMapならMatplotlibでももちろんできるけど、インタラクテイブ性をもたすならProcessingがいいかも。 あとこの本はコードの断片の説明というかたちが多いので別途サンプルコードをダウンロードしながら読む必要がある。 僕はjavaとprocessingがまだ拙いので、単に写経していくだけでは動かず、悩むことが多かったため、なかなか読み進められていないが、良書の予感はする(びしびしと)。