digg moved away from MySQL (to Cassandra)

http://about.digg.com/node/564

MySQL -> Cassandra

  • cassandra is a distributed database with a BigTable data model running on a Dynamo like infrastructure
  • it is column-oriented and allows for the storage of relatively structured data
  • fully decentralize model: every node is identical, no single point of failure, with fault tolerant
  • elastic: read/write throughput increase linearly
  • to read more: http://about.digg.com/blog/looking-future-cassandra

現状

  • ほぼ Cassandra
  • Cassandra-based indexing using full text, relational and graph indexing systems
  • eventual consistency にも慣れた(digg の特性では exact & strict な一貫性は必須ではないと判断していた)
  • implemented native atomic counters using Zookeeper

Cassandra そのまま投入ではなくて色々手を加えている。


今日のホットスポットは広義の UI - HTML5 を含む client side scripting から BMI まで - とバックエンドにあるように思える。
楽しげ。

Installing squawk - log parsing tool - on Snow Leopard (失敗)

SQL like なシンタックスを採用したログのパースツール

UserWarning: Unknown distribution option: 'install_requires'

が出て、どうもうまくいってないぽい。
断念した。


setup python

libs

  • install py26-parsing, py26-setuptools
  • run setup.py build

大惨敗の夜

友達のパーティーに行ってみると外国人のオフ会だった。
日本人補正が効かないと辛い辛い。話やキャラがつまらない相手は箸にも棒にも引っかからない。
ネタ振られても内容理解に自信が無いので聞き間違い?とか思ってしまう。
結局マジレスになったり、ネタを振った相手に自己回収させてしまい、そのうち相手にならなくなる。

今回は経験不足、何よりスキル不足を痛感した。
相手を楽しませられなかった、の一言に尽きる。大惨敗ですよ。

でも、海外経験ゼロだぜ! と言いながらどっかんどっかん笑わせてるカッコいいおっさんも居た。
為せば成るのだ。今はスキルと失敗回数が足りないだけ。

技術英語やバグレポ、サポートといった事務レベルの英語はいけるが、個人として興味を持ち向き合えるコミュニケーション英語にはまだまだ足りていない。
don't be shy! と失敗しまくれ、話すの好きか?話したいと思うか?(勿論 yes)の言葉が印象に残ってる。
楽しませるネタ、ストーリーを持て、こっちから話して興味を引くんだ、とも。
話せる機会を得たときに、より多くの経験を獲得する為の tips か。

その経験を積む前にスキルが足りていない。
今日から DVD の subtitle は英語で、BBC world radio や TED、スパナチュといった素材を会話の細部まで理解して楽しめるようになるまで頑張る。
カッコいい言い方、それっぽい喋り方が出来ると良いらしい、、、ドラマ+ English Journal か?

25年日本で生活しているじーちゃんとか、普通に汎アジア的な生き方をしている怪しいおっちゃんとか、マイノリティな雰囲気ある人達とは話していて楽しかった。
うん、HP の減りは早かったけど、何だかんだで楽しかったな。


翌日の日本酒探訪は 東京で最高の夜だった!と言って貰えて大勝利。
日本人補正有りならしっかり楽しませられる。

reading Rails 3 Release Note (8:Active Model to 7:Action Pack)

Rails に対して「ここはちょっとなー」と思っていた、表面はエレガントだが内部のコードはダーティという水鳥な部分が払拭されたように見える。
フルアーマーZZみたいだ!と思っていた重厚長大感もモジュール&粗結合で回答が出たような。
spec 見てるだけの今の段階ではかなりの好印象

開発効率を上げる&バグを減らすアプローチとして、抽象化はとても大事だと思う訳ですよ。
複数の手続きに名前を付けてカプセル化し、テストを付けて再利用する、、普段のアプリケーション開発なんてその繰り返しなんじゃないかと。
Rails にはそのための機能が揃っていて嬉しい。

  • AM の validation はとても良いように思える。
  • AR 含め、Rails2 系の API が使えるのは 3.2 まで
    • will not deplicated until 3.1 and not removed until Rails 3.2
    • compatibility layer でサポートって面白い。
  • AR で State Machine サポート
    • REST 厨だけど業務に於いて State Machine 欲しい場面は多々有る。デフォで State Machine が入ってくるのはデカい。

note の写経になるとあまり意味が無い事に気付いた。
mind-map 代わりにと思ったが、note が既に mind-map 状態なのでサブセットを作るだけだったり。
次は補足だけ記そう、、、、


source

Active Model
# custom validator
class TitleValidator < ActiveModel::EachValidator
  Titles = ['Mr.', 'Mrs.', "Dr."]
  def validate_each(record, attr, value)
    record.errors[attr] << 'must be a valid title' unless Titles.include?(value)
  end
end

# validate with plain object
class Person
  include ActiveModel::Validations
  attr_accessor :title
  validates :title, :presence => true, :title => true
end

# validate with AR
class Person < ActiveRecord::Base
  validates :title, :presence => true, :title => true
end

Active Record

Enhancements

  • :destroyed?
  • :inverse_of allowing you to pull instance of an already loaded association without hitting db

Patches and Deprications

  • pgsql support for the XML data type col
  • a lot
  • named_scope is now just "scope"
    • scope :since, lambda {|time| where("created_at > ?", time)}
  • save(false) is now save(:validate => false)
  • i18n err msg is now :en.errors.template
  • model.errors.on is now model.errors[]
  • validate_presence_of is now :presence => true
  • colored logging is now Rails::Subscriber.colorize_logging or config.colorize_logging

Active Resource

extracted to Active Model

see doc http://guides.rails.info/3_0_release_notes.html#active-resource

Active Support

  • Safe Buffers are implemented in ActiveSupport::SafeBuffer
    • what's that ? like a object-escaper or cache of escaped input values or so ?
  • added Array.uniq_by, uniq_by!
  • added ActiveSupport::Notifications middleware
    • what's that ?
  • escape_html_entities_in_json now defaults to false
  • string.mb_chars
  • added SAX-based parser for XmlMini, using LibXML and Nokogiri
  • added Object.presence returns object if it's #present? otherwise returns nil
  • use .exclude? instead of if ! x.include?
  • support deep-merging in HashWithIndifferentAccess

object tap (ruby 1.9)

  • helper for call chaining
  • passes its object into the given block, and gets block's return
"hoge".tap do |o|
  o.capitalize
end
# gets Hoge ?
# I haven't run it yet.

Action Mailer

  • inherits Abstract Controller, and wraps the Mail gem in a Rails DSL
  • all mailers are now in app/mailers by default

reading Rails 3 Release Note (1:Upgrading to 7:Action Pack)

routing 重要。
色々萌える。escaping by default はやっとか!って感じだけど。


sources

more infos

Intro
  • RESTful declaration router
  • AR chainable query lang built on top of relational algebra
  • unobtrusive js driver for jQ and more coming
  • Bundler
Upgrading to Rails 3
Creating Rails 3 app
Architectural Change
Internationalization
Railties
  • each app now has its own namespace
  • anything under Rails.root/app is now added to the load path
    • you can make app/observers/user_observer.rb
  • Rails.config, Rails wide configuration option
  • generators
    • allow you to override the templates by placing a copy at RAILS_ROOT/lib/templates
  • rake
    • rake routes CONTROLLER=x show the routes for one controller
  • deprecated
Action Pack

Action Controller

Action View

  • escaping by default
    • no longer need to call h(string)
    • use raw(string) to unescape
  • helpers now output HTML 5 by default
  • form label helper now pulls values from i18n
    • select label on should now be :en.helpers.select
  • no longer need to place '-' sign on ERb
  • added as new
    • grouped_collection_select helper
    • content_for? allowing you to check before rendering
Action Pack / Action Dispatch
# former
ActionController::Routing::Routes.draw do |map|
  map.resources :posts
end

# now
AppName::Application.routes do
  resources :posts
end

# and scope
#  below gives you the edit action with /es/projeto/1/cambiar
scope 'es' do
  resources :projects, :path_names => { :edit => ''cambiar' }, :as => 'projeto' 
end

# you can pass optional segments
#  each parenthesize segment is optional
'/:controller(/:action(/:id))(.:format)

# routes can be expressed via block
controller :home {
  match '/:action'
}

dive into rails3

node.js か Scala/Lift でいくでー!とか色々違うものに移ろうと思っていたのだけどやっぱり rails3 は押さえる事にした。
やっぱいいんですよ。「アプリの数だけレールがあっていいよね」は大変ささる。Rails1 から Rails3 に並べたときの時代に寄り添うような Railsness の変化には萌える。

更に、ホットスポット - 優秀な頭脳が集結しコミットを重ねている場所と付き合って得るものも大きい。
Input / Output どちらも大事なのだけど、まず必要なのは Input だ。
数年経ってもアプリケーションサーバホットスポットだと思える Rails は立派ですよ。

今回も Code on Demand & Client Side Scripting の流れとバックエンドで使う技術の選択が増した事で、アプリケーションサーバはとにかく RAD で、次に軽くて早くて小さいのがいいなぁと思っていたら最近の Rails もそんな感じになってた。
これは軽い驚き。

調べる (TODO)

  • 関係代数, ARel
    • named scope どうなったん?

read Rails3 のはなし

ほぼ写経になってしまった。スライド見た方が早いような。

freedom、rails for each apps って事は nice な規約がステキな道具達をゆるっと繋ぐ、道具箱的な存在になるんですかね。

  • Rails3のはなし
    • 疎結合、脱フルスタック
    • モジュール間インタフェース、Duck Typing 的
    • 選択: HAML, jQ, Sinatra, DM, Rack
    • Railsness の変化
      • Rails 1. 一人で作った一本のレール
      • Rails 2. みんなで敷いた一本のレール
      • Rails 3. アプリの数だけレールがあっていいよね
      • レールとは、Rails らしさのミーム, DHH が教えてくれたもの
      • DRY, CoC, フルスタック, MVC, AR, モデル中心, REST, TDD, generator, DSL, meta programming, Ajax, environments, plugins, scaffolding, + ActiveSupport (7.days.ago)
  • ActionPack
    • abstract_controller
    • action_dispatch
    • new router
  • ActiveRecord
    • ActiveModel
    • ARel
  • RailTies
    • yet another application.r
    • new initializer
    • new generator

面接問題

使えそうなのでメモ
http://japan.zdnet.com/sp/feature/07tenthings/story/0,3800082984,20409456,00.htm

  • 等価と等値の違い, == と ===
  • 値渡しと参照渡しの違い
  • ポリモーフィズム
  • 悲観的ロックと楽観的ロック

突然聞かれて答えられるのって、参照渡し、ポリモーフィズムくらいかも。不合格だ X)
等価と等値って言葉に馴染みが無いなぁ、、、今日覚えたよ!

  • ホワイトボードプログラミング
    • 数値 X のフィボナッチ数
    • 数値 X が素数であるか
    • ループを使わずに配列の順序を逆にする
    • Fizz Buzz

これは良いテスト。
Fizz Buzz は有名過ぎるか。
ループを使わずに.. はどういう意図なのだろう。
再帰かな?
JS だと for, while はほぼ使わず普通に $.each や再帰の方が好きだ。

それとも手続き的に展開、、こっちはホワイトボードでも見たくない><


ともうひとつ、スキルに加えて「自発的にその能力を発揮出来るか」、どれだけ proactive であるかという値も極めて重要だと思う。