digg moved away from MySQL (to Cassandra)
http://about.digg.com/node/564
- 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
- install python26 and python_select via MacPorts
- type python -l (locate ?)
- python_select python26
- type which python for check
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
- all ORM plugin need to implement Active Model interface
# 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
- see the doc: http://guides.rails.info/3_0_release_notes.html#active-record
- http://m.onkey.org/2010/1/22/active-record-query-interface
- http://hasmanyquestions.wordpress.com/2010/01/17/let-your-sql-growl-in-rails-3/
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.
reading Rails 3 Release Note (1:Upgrading to 7:Action Pack)
routing 重要。
色々萌える。escaping by default はやっとか!って感じだけど。
sources
- en: http://guides.rails.info/3_0_release_notes.html
- ja: http://blog.bluemoderns.com/articles/2010/02/07/ruby-on-rails-3-1
more infos
- http://guides.rails.info/ updating one by one to reflect the changes in Rails 3
- guides.rails.info: edge
- guides.rubyonrails.org: stable version
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
- Application Object
- for supporting running multiple app in the same process
- has specific config
- defined in config/application.rb
- managing gems
- use bundler and Gemfile
- config.gem has gone
- rails_upgrade offers generating Gemfile based on config.gem
- use plugin for update: http://github.com/rails/rails_upgrade
Architectural Change
- six major changes
- 1. Railties
- 2. core components are decoupled
- rails core components are now using the same API that you can use for developing plugins
- any components, including core, are replaceable (like DataMapper or Sequel)
- more info: http://yehudakatz.com/2009/07/19/rails-3-the-great-decoupling/
- 3. Active Model abstraction
- untied AR from ActionPack
- all ORM need to implement Active Model interface to work with Action Pack
- more: http://yehudakatz.com/2010/01/10/activemodel-make-any-ruby-object-feel-like-activerecord/
- 4. Controller abstraction
- Abstruction Controller, a base super class
- http://yehudakatz.com/2009/06/11/rails-edge-architecture/
- 5. Arel Integration
- 6. Mail Extraction
Internationalization
- i18n behavior can be added to any object
- like a ActiveModel::Translation, ActiveModel::Validations
- errors.messages feedback, and the form
- more: http://blog.plataformatec.com.br/2010/02/rails-3-i18n-changes/
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
- application_controller.rb
- now has protect_from_forgery on by default
- cookie / session
- some settings moved to initializers/*.rb
- cookie_verifier_secret
- session_store
- some settings moved to initializers/*.rb
- cookies.secure allowing you to set encrypted in cookie with cookie.secure[:key] => value
- cookies.permanent, cookie.permanent[:key] => value
- can pass :notice => flash_msg, :alert => flash_msg to the format object call inside a respond_to block. flash[] still works
- more
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
- provides a new & cleaner implementation for routing
- Rails router is now rack_mount with DSL on top
- constraints method allowing you to guard routes with constraints
- root method as a short cut for match '/', :to=>path
- map still works but will be removed at 3.1
- more
# 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のはなし
- 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)
等価と等値って言葉に馴染みが無いなぁ、、、今日覚えたよ!
これは良いテスト。
Fizz Buzz は有名過ぎるか。
ループを使わずに.. はどういう意図なのだろう。
再帰かな?
JS だと for, while はほぼ使わず普通に $.each や再帰の方が好きだ。
それとも手続き的に展開、、こっちはホワイトボードでも見たくない><
ともうひとつ、スキルに加えて「自発的にその能力を発揮出来るか」、どれだけ proactive であるかという値も極めて重要だと思う。