全体として太一が感覚的に実践している事を論理的に説明しようと試みている為、
説明の粒度が適切でなかったり一貫性が無いように見える部分があるかもしれない。
普段やっているけども書ききれていない事も多分きっとある。
- コードを嗜む
- コードを学ぶ
- 武器を手に入れる
| wait-free/lock-free/obstruction-freeの定義について | |
| ▲全てに共通する概念 | |
| スレッドが他のスレッドの進行を禁止する事がないので、どれかのスレッドが | |
| ロックを確保したままプリエンプションなどで全体の処理が停止する事態が発生しな | |
| い。 | |
| これは必ずしもロックベースのアルゴリズムより高速であることを意味し | |
| ない(現にロックの方が早い場合もある | |
| wait-freeが一番強い条件で、それを弱める度に |
| // g100pon #32 文字コード判定 | |
| import com.ibm.icu.text.CharsetDetector | |
| @Grab(group='com.ibm.icu', module='icu4j', version='4.0.1') | |
| def detector = new CharsetDetector() | |
| //ファイルは先に用意してあります... | |
| //ISO-2022-JP | |
| def bytes1 = new File('/works/test/iso2022-jp.txt').getBytes() | |
| def name1 = detector.setText(bytes1).detect().getName() |
| # Objective-C Syntax Highliht for Atlassian Fisheye and Crucible | |
| # Based on Atlassian's C syntax highlight | |
| # Author: Felipe Cypriano <fmcypriano@gmail.com> | |
| # Copyright 2010 Felipe Cypriano | |
| # | |
| # Licensed under the Apache License, Version 2.0 (the "License"); | |
| # you may not use this file except in compliance with the License. | |
| # You may obtain a copy of the License at | |
| # |
| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
| # |
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns
Compress 1K bytes with Zippy ............. 3,000 ns = 3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns = 20 µs
SSD random read ........................ 150,000 ns = 150 µs
Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs
| (use '[clojure.core.match :only [match]]) | |
| (defn evaluate [env [sym x y]] | |
| (match [sym] | |
| ['Number] x | |
| ['Add] (+ (evaluate env x) (evaluate env y)) | |
| ['Multiply] (* (evaluate env x) (evaluate env y)) | |
| ['Variable] (env x))) | |
| (def environment {"a" 3, "b" 4, "c" 5}) |
| import Control.Applicative ((<$>)) | |
| import Control.Monad (liftM2) | |
| import Data.Char (chr, ord) | |
| import Data.List (group) | |
| import System.Environment (getArgs) | |
| import Text.Parsec | |
| import Text.Parsec.String | |
| data Inst = Inc | Dec | R | L | In | Out | |
| deriving Show |