wombat風Xcodeカラーテーマ

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

$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>

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)

OpenCVの型情報の定数まとめ

命名規則を覚えれば大体わかるけど、一応メモ。
ちゃんと対応してないかも。

IplImage CvMat 対応する他の構造体 チャンネルのバイト数 チャンネル数 一要素のバイト数 符号 種類
IPL_DEPTH_8U CV_8UC1 1 1 1 整数
CV_8UC2 1 2 2 整数
CV_8UC3 1 3 3 整数
CV_8UC4 1 4 4 整数
IPL_DEPTH_8S CV_8SC1 1 1 1 整数
CV_8SC2 1 2 2 整数
CV_8SC3 1 3 3 整数
CV_8SC4 1 4 4 整数
IPL_DEPTH_16U CV_16UC1 2 1 2 整数
CV_16UC2 2 2 4 整数
CV_16UC3 2 3 6 整数
CV_16UC4 2 4 8 整数
IPL_DEPTH_16S CV_16SC1 2 1 2 整数
CV_16SC2 2 2 4 整数
CV_16SC3 2 3 6 整数
CV_16SC4 2 4 8 整数
CV_32SC1 4 1 4 整数
CV_32SC2 CvPoint 4 2 8 整数
CV_32SC3 4 3 12 整数
CV_32SC4 4 4 16 整数
IPL_DEPTH_32F CV_32FC1 4 1 4 浮動小数点数
CV_32FC2 4 2 8 浮動小数点数
CV_32FC3 4 3 12 浮動小数点数
CV_32FC4 4 4 16 浮動小数点数
IPL_DEPTH_32F CV_32FC1 4 1 4 浮動小数点数
CV_32FC2 CvPoint2D32f 4 2 8 浮動小数点数
CV_32FC3 CvPoint3D32f 4 3 12 浮動小数点数
CV_32FC4 4 4 16 浮動小数点数
CV_64FC1 8 1 8 浮動小数点数
CV_64FC2 CvPoint2D64f 8 2 16 浮動小数点数
CV_64FC3 CvPoint3D64f 8 3 24 浮動小数点数
CV_64FC4 8 4 32 浮動小数点数
IPL_DEPTH_1U 1? 1 1? 真偽値

ところで右寄せとか左寄せとかははてな記法にはないんでしょーか。
あと太字とかイタリックとかって、エディタ使うかタグ打たないと駄目なの?
MarkdownとかreStructuredTextとか使えるようにならないかな。

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

Reddit経由:
http://lca2srv30.epfl.ch/sathe/data/emacs_learning_curves.png

emacsが凄いことになっていて笑った。時間を逆行できると考えるべきか、ある時点で複数の状態が取りうるということなのか・・・。
僕自身はvimerですが、viと比べて拡張性がある分、操作に慣れて急上昇した後も緩やかに上昇していっている感覚があります。