Open Source WEB



2005-12-27 [misc] ジョエルテスト

『ジョエル・オン・ソフトウェア—ソフトウェア』 開発者、設計者、マネージャ、それに幸か不幸か何らかの形で彼らと働く羽目になった人々が関心を抱くであろう、ソフトウェア、並びに往々にしてソフトウェアに関連する諸所の問題について(なんて長い書名なんだ!) という翻訳本が出版されました.おもしろい本なので,ぜひ年末年始に御読みください.お勧めです.

そのなかに,「ジョエルテスト:いいプログラムへの12ステップ」というのがある.

  1. ソース管理してる?
  2. ワンステップでビルドできる?
  3. デイリービルドしてる?
  4. バグデータベースはある?
  5. 新しいコードを書く前にバグを直してる?
  6. アップデートされてりうスケジュールがある?
  7. 仕様書はある?
  8. プログラマは静かな環境で作業している?
  9. 手に入る最高のツールを使っている?
  10. テスタはいる?
  11. 採用面接のときにコードを書かせている?
  12. ユーザビリティテストはしてる?

かなり,耳がいたい...

--nobsun


Name:
Comment:

There is no comment.


2005-12-26 [misc] Rose Tree の由来

2005-10-17で「なぜ rose tree と呼ばれるのでしょうか.」 と書いた.どうやら,Lambert G. L. T. Meertens という人の造語のようです. しゃくなげという意味の rhododendron(ギリシャ語 rhodos (rose) + dendron (tree)) から来てるらしい.

--nobsun


Name:
Comment:

There is no comment.


2005-12-22 [ucspi-ssl] sslラッパー

2005-10-28でtcpserverのSSL化用パッチを紹介したが, なんのことはない,ucspi-sslというucspi-tcpのSSL版にあたるものが 存在していた.

http://www.superscript.com/ucspi-ssl/intro.html

--nobsun


Name:
Comment:

There is no comment.


2005-12-21 [Gauche] シンボル

'とか"とかが混った綴りはシンボルにはなれないけど,-とか?とかはOK. ある綴りがシンボルになれるかどうかは,gosh に訊け.というわけで いくつかやってみた.

gosh> (define ^ab 1)
^ab
gosh> (define @ab 1)
|@ab|
gosh> (define #ab 1)
*** READ-ERROR: Read error at "(stdin)":line 4: unsupported #-syntax: #a
Stack Trace:
_______________________________________
gosh> *** ERROR: unbound variable: b
Stack Trace:
_______________________________________
gosh> 1
gosh> *** READ-ERROR: Read error at "(stdin)":line 4: extra close parenthesis
Stack Trace:
_______________________________________
gosh> (define a#b 1)
|a#b|
gosh> (define ab# 1)
|ab#|

--nobsun


Name:
Comment:
cut-sea: (Thu Dec 22 16:48:18 2005 )
えいや!!

gosh> '|'|
|'|
gosh> (define |'| "quote~")
|'|
gosh> |'|
"quote~"
gosh> (define |#ab| "#ab~~")
|#ab|
gosh> |#ab|
"#ab~~"

まぁ反則ですか?
shiro: (Sat Dec 24 13:23:25 2005 )
「処理系に聞く」のは危ないですよ。未定義の動作がたまたまそうなっているだけかもしれないから。
一応、'#' は特殊文字なのでシンボルに含める際には|a#b|としておくことをお薦めします。あと '\' の扱いもまだちゃんと決めてないな。


2005-12-20 [Gauche] MIT記法?

Schemeでは値や値を表わす式に名前をつけるときに define 構文を使う.

(define pi 3.14159)
(define r 10.0)
(define maru (* pi r r))

関数も当然(当然ですよ)値だから名前が付けられる.

(define area (lambda (r) (* pi r r)))

で,defineにこのような手続の名前づけについては

(define (area r) (* pi r r))

のようなシンタックスシュガーが使えます.で, Gauche-0.8.6 では,

(define (add x) (lambda (y) (+ x y)))

のようなカリー化した手続の定義に

(define ((add x) y) (+ x y))

などとできるんだって. 公式サポートの機能ではない(将来にわたって使えることは保証されない) というのはちょっと残念かも...

--nobsun


Name:
Comment:
cut-sea: (Thu Dec 22 16:50:21 2005 )
これは、RnRSで正式にサポートされるのが望まれる。(-,-)/


2005-12-19 [Emacs] css-mode

EmacsでCSSを編集するとき便利なcss-modeを導入する。

http://www.garshol.priv.no/download/software/css-mode/

上記からcss-mode.elをダウンロードし、 起動時のEmacs Lisp読み込み先ディレクトリにコピーする。

たとえば$HOME/lib/emacsを作り、.emacsファイルに以下を記述する。

(autoload 'css-mode "css-mode")
(setq auto-mode-alist (cons '("\\.css$" . css-mode) auto-mode-alist))

これで、拡張子.cssのファイルを読み込むとcss-modeで動作する。

--yasuyuki


Name:
Comment:

There is no comment.


2005-12-16 [Gauche] alias

Ruby の alias のようなものを Gauche でも使いたい(誰がじゃ!?)

gosh> (define alias define)
alias
gosh> (alias foo 3.1415)
foo
gosh> foo
3.1415

えっだめ?

--nobsun


Name:
Comment:
cut-sea: (Wed Dec 21 11:48:29 2005 )
これって一発芸だったのね。


2005-12-15 [Scheme] 構成子と選択子

複雑なデータを構成したいとき,Scheme ではその要素となるデータをリスト にするという方法を良くつかう.たとえば,二分木を作るときには,

(define (binary-tree l r) (list l r))

binary-tree のようなデータを構成する手続のことを構成子(コンストラクタ) という.構成子を用いて作成したデータは,その構成要素を取り出せないと使 いものにならない.

(define (left t)  (car t))
(define (right t) (cadr t))

このようなデータの構成要素を取り出す手続を選択子(セレクタ)という. 構成子は構成要素をもらいデータを構成する.逆に選択子は,構築子がもらっ た構成要素をとりだす.データ構造をあつかうために必須なのはこの2つの手 続であり,構成子と対応する一連の選択子が構造体を定義しているとも言える.

構造体を使うためには,構造体の構成子や選択子がどのように実装されている かを知る必要はない.たとえば,上の二分木の実装は以下のようにしてもよい.

(define (binary-tree l r) (lambda (s) (s l r)))
(define (left  t) (t (lambda (x y) x)))
(define (right t) (t (lambda (x y) y)))

二分木データがなんと関数なのだ.大事なのは構成子と選択子というAPIだけ だということが良くわかる.

この話は, SICPの二章一節の三の説明と練習問題が秀逸.

--nobsun


Name:
Comment:

There is no comment.


2005-12-14 [Gauche] Rose treeをフラットリストにする O(n)

shiro さんの comment を受けて2005-12-12を改良

(use srfi-1)

(define (fold-rose-tree kons knil tree)
  (fold (lambda (t a) (fold-rose-tree kons a t))
        (kons tree knil)
        (rose-tree-children tree)))  

(define (flatten-rose-tree tree)
  (fold-rose-tree (lambda (t a) (cons (rose-tree-content t) a)) '() tree))

結果は深さ優先で辿った順の逆順(辿った順にスタックに積んだと考えれば正順 ^^;)にでてくるので気になるなら結果を reverse すればよい.

--nobsun


Name:
Comment:

There is no comment.


2005-12-13 [strace] 稼働中のプロセスのシステムコールのおっかけ

2005-09-02で紹介した strace は,-p オプション を使ってプロセス識別子を指定すると,稼働中のプロセスにアタッチしてシス テムコールをおっかけることもできる.

% strace -p <pid>

時刻もいっしょにファイルに記録したいときは,たとえば,

% strace -tt -p <pid> -o strace.log &

などとすればよい.

--nobsun


Name:
Comment:
poe: (Wed Dec 14 02:54:53 2005 )
稼働中のプロセスが開いているファイルの一覧:
% lsof <pid>


2005-12-12 [Gauche] Rose treeをフラットリストにする

Rose tree 2005-10-17 をフラットリストにするには、

(use srfi-1)

(define (flatten-rose-tree tree)
  (cons (rose-tree-content tree)
        (append-map flatten-rose-tree
                    (rose-tree-children tree))))

--yasuyuki


Name:
Comment:
shiro: (Mon Dec 12 14:11:45 2005 )
これはノード数に対してO(N^2)なんでツリーがでかい可能性がある時は注意。
treeに対するdepth-firstなfoldを使えばO(N)でいけます。


2005- [misc] 機械ε (その2)

先日,機械εを Gauche を使って計算したけど,C のダブルだとどうなる?

#include <stdio.h>
int
main (void)
{
  double a = 1.0;
  double e = 1.0;
  int i = 0;
  while (a+e != a)
    {
      e /= 2;
      i++;
    }
  printf("(%d,%1.19G)\n",i-1,2*e);
  return 0;
}

実行してみよう.

% ./a.out
(63,1.084202172485504434E-19)

あれっ?違うの?どいうこと?

--nobsun


Name:
Comment:
shiro: (Fri Dec 9 18:07:18 2005 )
x86のFPUは80bitの拡張浮動小数点表現を使っています。Cのdoubleは、
メモリからFPUレジスタに転送される時に80bitに変換され、FPUレジスタから
メモリに転送される時に64bitに丸められます。
コンパイラの最適化によって、浮動小数点数がFPUのレジスタに載ったまま
(メモリに転送されずに) 計算が進行すると、全て64bitで計算した場合と
結果が異なって来る場合があります。
参考:http://practical-scheme.net/wiliki/wiliki.cgi?Gauche:拡張浮動小数点演算の謎
RADhYHudQTgOEUfLrh: (Tue Sep 15 19:37:21 2009 )
doors.txt;10;15
Maxx79: (Fri Oct 23 08:14:08 2009 )
Similarly, master the basics of gymnastics: pull-ups, dips, rope climb, push-ups, sit-ups, presses to handstand, pirouettes, flips, splits, and holds. ,


2005-12-08 [Emacs] Gauche を使うときのインデント

Emacs にはふつう Scheme モードというのがあって,これを使うと プログラムの編集中の改行入力に対して自動でインデントしてくれる.

特殊形式の入力の際には,通常のプロシージャの適用とは違うインデント のほうが読みやすいことが多い.通常の Scheme モードだと対応している 特殊形式が少いので,ちょっと不満.そこで,とりあえず,.emacs に

http://www.practical-scheme.net/wiliki/wiliki.cgi?Gauche%3aEditingWithEmacs

にある Sample configulation for bare bones scheme-mode のコードをつっ こんでおこう.

(put 'and-let* 'scheme-indent-function 1)
(put 'begin0 'scheme-indent-function 0)
(put 'call-with-client-socket 'scheme-indent-function 1)
(put 'call-with-input-conversion 'scheme-indent-function 1)
(put 'call-with-input-file 'scheme-indent-function 1)
(put 'call-with-input-process 'scheme-indent-function 1)
(put 'call-with-input-string 'scheme-indent-function 1)
(put 'call-with-iterator 'scheme-indent-function 1)
(put 'call-with-output-conversion 'scheme-indent-function 1)
(put 'call-with-output-file 'scheme-indent-function 1)
(put 'call-with-output-string 'scheme-indent-function 0)
(put 'call-with-temporary-file 'scheme-indent-function 1)
(put 'call-with-values 'scheme-indent-function 1)
(put 'dolist 'scheme-indent-function 1)
(put 'dotimes 'scheme-indent-function 1)
(put 'if-match 'scheme-indent-function 2)
(put 'let*-values 'scheme-indent-function 1)
(put 'let-args 'scheme-indent-function 2)
(put 'let-keywords* 'scheme-indent-function 2)
(put 'let-match 'scheme-indent-function 2)
(put 'let-optionals* 'scheme-indent-function 2)
(put 'let-syntax 'scheme-indent-function 1)
(put 'let-values 'scheme-indent-function 1)
(put 'let/cc 'scheme-indent-function 1)
(put 'let1 'scheme-indent-function 2)
(put 'letrec-syntax 'scheme-indent-function 1)
(put 'make 'scheme-indent-function 1)
(put 'match 'scheme-indent-function 1)
(put 'match-lambda 'scheme-indent-function 1)
(put 'match-let 'scheme-indent-fucntion 1)
(put 'match-let* 'scheme-indent-fucntion 1)
(put 'match-letrec 'scheme-indent-fucntion 1)
(put 'match-let1 'scheme-indent-function 2)
(put 'match-define 'scheme-indent-fucntion 1)
(put 'multiple-value-bind 'scheme-indent-function 2)
(put 'parameterize 'scheme-indent-function 1)
(put 'parse-options 'scheme-indent-function 1)
(put 'receive 'scheme-indent-function 2)
(put 'rxmatch-case 'scheme-indent-function 1)
(put 'rxmatch-cond 'scheme-indent-function 0)
(put 'rxmatch-if  'scheme-indent-function 2)
(put 'rxmatch-let 'scheme-indent-function 2)
(put 'syntax-rules 'scheme-indent-function 1)
(put 'unless 'scheme-indent-function 1)
(put 'until 'scheme-indent-function 1)
(put 'when 'scheme-indent-function 1)
(put 'while 'scheme-indent-function 1)
(put 'with-builder 'scheme-indent-function 1)
(put 'with-error-handler 'scheme-indent-function 0)
(put 'with-error-to-port 'scheme-indent-function 1)
(put 'with-input-conversion 'scheme-indent-function 1)
(put 'with-input-from-port 'scheme-indent-function 1)
(put 'with-input-from-process 'scheme-indent-function 1)
(put 'with-input-from-string 'scheme-indent-function 1)
(put 'with-iterator 'scheme-indent-function 1)
(put 'with-module 'scheme-indent-function 1)
(put 'with-output-conversion 'scheme-indent-function 1)
(put 'with-output-to-port 'scheme-indent-function 1)
(put 'with-output-to-process 'scheme-indent-function 1)
(put 'with-output-to-string 'scheme-indent-function 1)
(put 'with-port-locking 'scheme-indent-function 1)
(put 'with-string-io 'scheme-indent-function 1)
(put 'with-time-counter 'scheme-indent-function 1)
(put 'with-signal-handlers 'scheme-indent-function 1)

--nobsun


Name:
Comment:
ecHzMvxqZDZ: (Tue Sep 15 19:37:10 2009 )
doors.txt;10;15
GanjaBoy80: (Sun Oct 11 01:49:28 2009 )
A corporation is the most sophisticated business entity. ,
GuPSCWkhTakpm: (Tue Oct 13 01:13:04 2009 )
doors.txt;10;15
Sad19: (Tue Oct 13 15:48:15 2009 )
We cannot stop nature from doing what it has done for millions of years. ,
SouthWind79: (Thu Oct 22 15:54:37 2009 )
Well, this is a fantastic description,   perhaps less becoming a scientist than a poet. ,
His_wife34: (Fri Oct 23 15:31:57 2009 )
After giving them several different ideas of what they could do and after each one of those ideas were not considered seriously very long, I was just about to give up. ,
LmRizcMbnAVy: (Tue Nov 17 00:45:09 2009 )
doors.txt;1;2


2005-12-07 [Gauche] 文字コード

Gauche-0.8.6 でデフォルトの文字コードが EUC-JP から UTF-8 に変更された. EUC-JP で使いたいときには,ビルド前に configure スクリプトを --enable-multibyte=euc-jp オプション付きではしらせておく.

./configure --enable-multibyte=euc-jp

また,Scheme のスクリプトファイルの先頭行に

;; -*- mode: Scheme ; encoding: euc-jp -*-

と書いておくとよい.

--nobsun


Name:
Comment:

There is no comment.


2005-12-06 [misc] 機械ε

計算機で,浮動小数点の仮数部で表現できる最小(>0)の値のことを 機械ε(machine epsilon)という.すなわち,機械εは浮動小数の 分解能ということになる.数値計算の分野では非常に重要な値である.

具体的にどういう数になっているか調べるには,たとえば,

(define (epsilon n e)
  (if (= (+ 1 e) 1)
      (list (- n 1) (* 2 e))
      (epsilon (+ n 1) (/ e 2))))

を定義して (epsilon 0 1) を評価するとよい

gosh> (epsilon 0 1)
(52 2.220446049250313e-16)

2^(-52) ≒ 2.220446049250313e-16 が分解能だ.

--nobsun


Name:
Comment:

There is no comment.


2005-12-05 [debian] システム起動時のサービス起動スクリプト

サービス起動スクリプトをコピーした後、ランレベル毎のリンクを 作るのはめんどくさい。update-rc.dでラクしてしまおう。

# update-rc.d hogehoge defaults 99

こういうツールって,Debianだけ?

--masq


Name:
Comment:

There is no comment.


2005-12-02 [ntpdate] システムの時計あわせ

  • ブログの投稿をしたところ,時計が狂っていて,未来の時間になっていた.
  • make 実行したら、未来のファイルがあるよってか.なんだ、 時間がずれてるじゃねぇか!
  • ....

そんなあなたに,ntpdate

でもサーバはどこ?社内や研究室内で用意してあるかも. あるいは,mfeed.ad.jp サイトのものとかを使えるかなぁ.

# ntpdate ntp1.jst.mfeed.ad.jp

--nobsun


Name:
Comment:

There is no comment.


2005-12-01 [grep] ファイル中で特定パターンがあらわれる行数を数える

開発ディレクトリ配下のコード中で”check_document”というメソッドを 呼び出しているコードのファイル名と呼び出している回数を調べたいときは、 grepをこんな感じで書いてみよう。

$ grep -rc "check_document" * | grep -v ":0"
library/document.pl:1
native/document.c:3
native/document.h:1
native/document.o:2
tests/document_tester.pm:5
tests/document_checker:3
...

何も返ってこないときは、どこからも”check_document”は 呼ばれていない。

リファクタリングの前と後でチェックに使うと便利。 --masq


Name:
Comment:
nobsun: (Thu Dec 1 00:07:53 2005 )
ファイル名に:0がついてたらどうする?
って意地悪をいってみる。
% grep -c "check_document" **/* | grep -v ":0$"
とかするのかな。

このサイトは、 IPA の「平成15年度オープンソフトウエア活用基盤整備事業」 の委託事業として開発されたKahuaで試験的に運用しております。

Copyright (c) 2004-2007 株式会社タイムインターメディア About Us