Hatena::ブログ(Diary)

// TODO: better name このページをアンテナに追加 RSSフィード

2009-02-26

Nitro

Safari4の新JSエンジンNitroの正体がよくわからなかったんですが、

http://www.nabble.com/Differences-between-Nitro-and-Squirrelfish.-td22211646.html

みたいな記事が。

SFXマーケティング上の名前みたい。ややこしい。

2009-02-02

wombat風Xcodeカラーテーマ

最近ずっとVimのカラースキームはwombat(http://dengmao.wordpress.com/2007/01/22/vim-color-scheme-wombat/)を微調整したものを使っていたのですが、Xcodeでも同様のカラーテーマを使いたくなってきたので作ってみました。自分のカスタマイズ版と同じくイタリック指定を解除してあったりします。

f:id:arche_t:20090203003203p:image

$HOME/ライブラリ/Application Support/Xcode/Color Themes/

拡張子xccolorthemeのテキストファイルを作成して以下をコピペすれば使えると思います。

(ファイル添付できないのって不便…)

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Colors</key>
	<dict>
		<key>Background</key>
		<string>0.141 0.141 0.141</string>
		<key>InsertionPoint</key>
		<string>0.396 0.396 0.396</string>
		<key>Selection</key>
		<string>0.267 0.267 0.267</string>
		<key>xcode.syntax.attribute</key>
		<string>0.906 0.965 0.855</string>
		<key>xcode.syntax.character</key>
		<string>0.584 0.894 0.329</string>
		<key>xcode.syntax.comment</key>
		<string>0.600 0.588 0.545</string>
		<key>xcode.syntax.comment.doc</key>
		<string>0.600 0.588 0.545</string>
		<key>xcode.syntax.comment.doc.keyword</key>
		<string>0.600 0.588 0.545</string>
		<key>xcode.syntax.identifier.class</key>
		<string>0.792 0.902 0.510</string>
		<key>xcode.syntax.identifier.class.system</key>
		<string>0.792 0.902 0.510</string>
		<key>xcode.syntax.identifier.constant</key>
		<string>0.898 0.471 0.427</string>
		<key>xcode.syntax.identifier.constant.system</key>
		<string>0.898 0.471 0.427</string>
		<key>xcode.syntax.identifier.function</key>
		<string>0.792 0.902 0.510</string>
		<key>xcode.syntax.identifier.function.system</key>
		<string>0.792 0.902 0.510</string>
		<key>xcode.syntax.identifier.macro</key>
		<string>0.898 0.471 0.427</string>
		<key>xcode.syntax.identifier.macro.system</key>
		<string>0.898 0.471 0.427</string>
		<key>xcode.syntax.identifier.type</key>
		<string>0.792 0.902 0.510</string>
		<key>xcode.syntax.identifier.type.system</key>
		<string>0.792 0.902 0.510</string>
		<key>xcode.syntax.identifier.variable</key>
		<string>0.792 0.902 0.510</string>
		<key>xcode.syntax.identifier.variable.system</key>
		<string>0.792 0.902 0.510</string>
		<key>xcode.syntax.keyword</key>
		<string>0.541 0.776 0.949</string>
		<key>xcode.syntax.mark</key>
		<string>1.000 0.500 0.000</string>
		<key>xcode.syntax.number</key>
		<string>0.898 0.471 0.427</string>
		<key>xcode.syntax.plain</key>
		<string>1.000 1.000 1.000</string>
		<key>xcode.syntax.preprocessor</key>
		<string>0.894 0.471 0.427</string>
		<key>xcode.syntax.string</key>
		<string>0.584 0.894 0.329</string>
		<key>xcode.syntax.url</key>
		<string>0.906 0.965 0.855</string>
		<key>xcode.syntax.url.mail</key>
		<string>0.100 0.100 1.000</string>
	</dict>
	<key>Fonts</key>
	<dict>
		<key>xcode.syntax.attribute</key>
		<string>Monaco - 11.0</string>
		<key>xcode.syntax.character</key>
		<string>Monaco - 11.0</string>
		<key>xcode.syntax.comment</key>
		<string>Monaco - 11.0</string>
		<key>xcode.syntax.comment.doc</key>
		<string>Monaco - 11.0</string>
		<key>xcode.syntax.comment.doc.keyword</key>
		<string>Monaco - 11.0</string>
		<key>xcode.syntax.keyword</key>
		<string>Monaco - 11.0</string>
		<key>xcode.syntax.number</key>
		<string>Monaco - 11.0</string>
		<key>xcode.syntax.plain</key>
		<string>Monaco - 11.0</string>
		<key>xcode.syntax.preprocessor</key>
		<string>Monaco - 11.0</string>
		<key>xcode.syntax.string</key>
		<string>Monaco - 11.0</string>
		<key>xcode.syntax.url</key>
		<string>Monaco - 11.0</string>
	</dict>
</dict>
</plist>

2009-01-30

GCCでIntel Syntaxなアセンブリコードを出力

gcc -S -masm=intel <input-file>

objdumpとかも対応してるのかな?

調べてみる。

追記

objdump -M intel -S <input-file>

でできるっぽい。これは便利。

2009-01-21

SICP4章のMetacircular Evaluatorを写経する

なんとなく思い立ったのでbracket("[", "]")を使って書き直してみるテスト

にわかSchemerとしては大分見やすくなった気がします。

[]の後は必ず改行するという自分ルールを適用した結果、かなりPython風味に(個人的に)。

Dr.Schemeで動きました。

;;;; Metacircular evaluator

(define true #t)
(define false #f)

;; Eval
(define [my-eval exp env]
  (cond ([self-evaluating? exp] 
         exp)
        ([variable? exp] 
         (lookup-variable-value exp env))
        ([quoted? exp] 
         (text-of-quotation exp))
        ([assignment? exp] 
         (eval-assignment exp env))
        ([definition? exp] 
         (eval-definition exp env))
        ([if? exp] 
         (eval-if exp env))
        ([lambda? exp] 
         (make-procedure (lambda-parameters exp)
                         (lambda-body exp)
                         env))
        ([begin? exp]
         (eval-sequence (begin-actions exp) env))
        ([cond? exp] 
         (my-eval (cond->if exp) env))
        ([application? exp]
         (my-apply (my-eval (operator exp) env)
                (list-of-values (operands exp) env)))
        (else
          (error "Unknown expression type -- EVAL" exp))))

;; Apply
(define [my-apply procedure arguments]
  (cond ([primitive-procedure? procedure]
         (apply-primitive-procedure procedure arguments))
        ([compound-procedure? procedure]
         (eval-sequence
           (procedure-body procedure)
           (extend-environment
             (procedure-parameters procedure)
             arguments
             (procedure-environment procedure))))
        (else
          (error
            "Unkown procedure type -- APPLY" procedure))))

;; Procedure arguments
(define [list-of-values exps env]
  (if [no-operands? exps]
    '()
    (cons (my-eval (first-operand exps) env)
          (list-of-values (rest-operands exps) env))))

;; Conditionals
(define [eval-if exp env]
  (if [true? (my-eval (if-predicate exp) env)]
    (my-eval (if-consequent exp) env)
    (my-eval (if-alternative exp) env)))

;; Sequences
(define [eval-sequence exps env]
  (cond ([last-exp? exps]
         (my-eval (first-exp exps) env))
        (else
         (my-eval (first-exp exps) env)
         (eval-sequence (rest-exps exps) env))))

;; Assignments 
(define [eval-assignment exp env]
  (set-variable-value! (assignment-variable exp)
                       (my-eval (assignment-value exp) env)
                       env)
  'ok)

;; Definitions
(define [eval-definition exp env]
  (define-variable! (definition-variable exp)
                    (my-eval (definition-value exp) env)
                    env)
  'ok)

;; Expressions
(define [self-evaluating? exp]
        (cond ([number? exp] 
                true)
              ([string? exp] 
                true)
              (else 
                false)))

(define [variable? exp] 
  (symbol? exp))

(define [quoted? exp]
  (tagged-list? exp 'quote))

(define [text-of-quotation exp]
  (cadr exp))

(define [tagged-list? exp tag]
  (if [pair? exp]
    (eq? (car exp) tag)
    false))

;; Assignments
(define [assignment? exp]
  (tagged-list? exp 'set!))
(define [assignment-variable exp]
  (cadr exp))
(define [assignment-value exp]
  (caddr exp))

;; Definitions
(define [definition? exp]
  (tagged-list? exp 'define))
(define [definition-variable exp]
  (if [symbol? (cadr exp)]
    (cadr exp)
    (caadr exp)))
(define [definition-value exp]
  (if [symbol? (cadr exp)]
    (caddr exp)
    (make-lambda (cdadr exp)    ; Formal parameters
                 (cddr exp))))  ; body

;; Lambda
(define [lambda? exp]
  (tagged-list? exp 'lambda))
(define [lambda-parameters exp]
  (cadr exp))
(define [lambda-body exp] 
  (cddr exp))
(define [make-lambda parameters body]
  (cons 'lambda (cons parameters body)))

;; If
(define [if? exp]
  (tagged-list? exp 'if))
(define [if-predicate exp]
  (cadr exp))
(define [if-consequent exp]
  (caddr exp))
(define [if-alternative exp]
  (if [not (null? (cdddr exp))]
    (caddr exp)
    'false))
(define [make-if predicate consequent alternative]
  (list 'if predicate consequent alternative))

;; Sequences
(define [begin? exp] 
  (tagged-list? exp 'begin))
(define [begin-actions exp] 
  (cdr exp))
(define [last-exp? seq]
  (null? (cdr seq)))
(define [first-exp seq]
  (car seq))
(define [rest-exps seq] 
  (cdr seq))

(define [sequence->exp seq]
  (cond ([null? seq] 
         seq)
        ([last-exp? seq] 
         (first-exp seq))
        (else 
          (make-begin seq))))
(define [make-begin seq] 
  (cons 'begin seq))

(define [application? exp] 
  (pair? exp))
(define [operator exp]
  (car exp))
(define [operands exp] 
  (cdr exp))
(define [no-operands? ops]
  (null? ops))
(define [first-operand ops]
  (car ops))
(define [rest-operands ops]
  (cdr ops))

;; Conditionals
(define [cond? exp] 
  (tagged-list? exp 'cond))
(define [cond-clauses exp] 
  (cdr exp))
(define [cond-else-clause? clause]
  (eq? (cond-predicate clause) 'else))
(define [cond-predicate clause] 
  (car clause))
(define [cond-actions clause] 
  (cdr clause))
(define [cond->if exp]
  (expand-clauses (cond-clauses exp)))
(define [expand-clauses clauses]
  (if [null? clauses]
    'false
    (let ([first (car clauses)]
          [rest (cdr clauses)])
      (if [cond-else-clause? first]
        (if [null? rest]
          (sequence->exp (cond-actions first))
          (error "ELSE clause isn't last -- COND->IF"
                 clauses))
        (make-if (cond-predicate first)
                 (sequence->exp (cond-actions first))
                 (expand-clauses rest))))))

;; Testing of predicates
(define [true? x]
  (not (eq? x false)))
(define [false? x]
  (eq? x false))

(define [make-procedure parameters body env]
  (list 'procedure parameters body env))
(define [compound-procedure? p]
  (tagged-list? p 'procedure))
(define [procedure-parameters p] 
  (cadr p))
(define [procedure-body p] 
  (caddr p))
(define [procedure-environment p] 
  (cadddr p))

(define [enclosing-environment env]
  (cdr env))
(define [first-frame env] 
  (car env))
(define the-empty-environment '())

(define [make-frame variables values]
  (cons variables values))
(define [frame-variables frame]
  (car frame))
(define [frame-values frame]
  (cdr frame))
(define [add-binding-to-frame! var val frame]
  (set-car! frame (cons var (car frame)))
  (set-cdr! frame (cons val (cdr frame))))

(define [extend-environment vars vals base-env]
  (if [= (length vars) (length vals)]
    (cons (make-frame vars vals) base-env)
    (if [< (length vars) (length vals)]
      (error "Too many arguments supplied" vars vals)
      (error "Too few arguments supplied" vars vals))))

(define [lookup-variable-value var env]
  (define [env-loop env]
    (define [scan vars vals]
      (cond ([null? vars]
             (env-loop (enclosing-environment env)))
            ([eq? var (car vars)]
             (car vals))
            (else 
              (scan (cdr vars) (cdr vals)))))
    (if [eq? env the-empty-environment]
      (error "Unbound variable" var)
      (let ([frame (first-frame env)])
        (scan (frame-variables frame)
              (frame-values frame)))))
  (env-loop env))

(define [set-variable-value! var val env]
  (define [env-loop env]
    (define [scan vars vals]
      (cond ([null? vars]
             (env-loop (enclosing-environment env)))
            ([eq? var (car vars)]
             (set-car! vals val))
            (else
              (scan (cdr vars) (cdr vals)))))
    (if [eq? env the-empty-environment]
      (error "Unboud variable -- SET!" var)
      (let ([frame (first-frame env)])
        (scan (frame-variables frame)
              (frame-values frame)))))
  (env-loop env))

(define [define-variable! var val env]
  (let ([frame (first-frame env)])
    (define [scan vars vals]
      (cond ([null? vars]
             (add-binding-to-frame! var val frame))
            ([eq? var (car vars)]
             (set-car! vals val))
            (else
              (scan (cdr vars) (cdr vals)))))
    (scan (frame-variables frame)
          (frame-values frame))))
(define primitive-procedures
  (list (list 'car car)
        (list 'cdr cdr)
        (list 'cons cons)
        (list 'null? null?)
        (list '+ +)
        (list '- -)
        (list '* *)
        (list '/ /)
        ))
(define [primitive-procedure-names]
  (map car primitive-procedures))
(define [primitive-procedure-objects]
  (map (lambda [proc] (list 'primitive (cadr proc)))
       primitive-procedures))
(define [setup-environment]
  (let ([initial-env
          (extend-environment (primitive-procedure-names)
                              (primitive-procedure-objects)
                              the-empty-environment)])
    (define-variable! 'true true initial-env)
    (define-variable! 'false false initial-env)
    initial-env))

(define the-global-environment (setup-environment))

(define [primitive-procedure? proc]
  (tagged-list? proc 'primitive))
(define [primitive-implementation proc] 
  (cadr proc))

(define [apply-primitive-procedure proc args]
  (apply (primitive-implementation proc) args))

(define input-prompt ";;; M-Eval input:")
(define output-prompt ";;; M-Eval value:")
(define [driver-loop]
  (prompt-for-input input-prompt)
  (let ([input (read)])
    (let ([output (my-eval input the-global-environment)])
      (announce-output output-prompt)
      (user-print output)))
  (driver-loop))
(define [prompt-for-input string]
  (newline) 
  (newline)
  (display string)
  (newline))
(define [announce-output string]
  (newline)
  (display string)
  (newline))

(define (user-print object)
  (if [compound-procedure? object]
    (display (list 'compond-procedure
                   (procedure-parameters object)
                   (procedure-body object)
                   '<procedure-env>))
    (display object)))

;; Main
(define the-global-environment (setup-environment))
(driver-loop)

2009-01-20

iPod Touchからの投稿テスト。

はてなログインして普通に日記が書けてしまっている。これは本当に便利かもしれない。テキスト入力も慣れるとかなり快適になりそう。

OpenCVの型情報の定数まとめ

命名規則を覚えれば大体わかるけど、一応メモ。

ちゃんと対応してないかも。

IplImageCvMat対応する他の構造体チャンネルのバイト数チャンネル数一要素のバイト数符号種類
IPL_DEPTH_8U CV_8UC1 111整数
CV_8UC2 122整数
CV_8UC3 133整数
CV_8UC4 144整数
IPL_DEPTH_8S CV_8SC1 111整数
CV_8SC2 122整数
CV_8SC3 133整数
CV_8SC4 144整数
IPL_DEPTH_16UCV_16UC1 212整数
CV_16UC2 224整数
CV_16UC3 236整数
CV_16UC4 248整数
IPL_DEPTH_16SCV_16SC1 212整数
CV_16SC2 224整数
CV_16SC3 236整数
CV_16SC4 248整数
CV_32SC1 414整数
CV_32SC2CvPoint428整数
CV_32SC3 4312整数
CV_32SC4 4416整数
IPL_DEPTH_32FCV_32FC1 414 浮動小数点数
CV_32FC2 428 浮動小数点数
CV_32FC3 4312 浮動小数点数
CV_32FC4 4416 浮動小数点数
IPL_DEPTH_32FCV_32FC1 414 浮動小数点数
CV_32FC2CvPoint2D32f428 浮動小数点数
CV_32FC3CvPoint3D32f4312 浮動小数点数
CV_32FC4 4416 浮動小数点数
CV_64FC1 818 浮動小数点数
CV_64FC2CvPoint2D64f8216 浮動小数点数
CV_64FC3CvPoint3D64f8324 浮動小数点数
CV_64FC4 8432 浮動小数点数
IPL_DEPTH_1U 1?11? 真偽値

ところで右寄せとか左寄せとかははてな記法にはないんでしょーか。

あと太字とかイタリックとかって、エディタ使うかタグ打たないと駄目なの?

MarkdownとかreStructuredTextとか使えるようにならないかな。

テキストエディタの学習曲線

Reddit経由:

http://lca2srv30.epfl.ch/sathe/data/emacs_learning_curves.png

emacsが凄いことになっていて笑った。時間を逆行できると考えるべきか、ある時点で複数の状態が取りうるということなのか・・・。

僕自身はvimerですが、viと比べて拡張性がある分、操作に慣れて急上昇した後も緩やかに上昇していっている感覚があります。