• 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

caches_pageとの違い

caches_actionはcaches_pageと似ていますが、依然としてすべてのリクエストがAction Packを通って処理されるようになっています。これは認証や他の制限をつけたいときに便利です。

"/lists"と"/lists.xml"は別々にキャッシュされる

また、http://blog.s21g.com/listsとhttp://blog.s21g.com/lists.xmlは異なるリクエストとして処理され、別々にキャッシュされます。つまり、:action => "lists"のキャッシュが無効になったからといって、:actioin => "list", :format => ":xml"も無効になるわけではありません。

キャッシュの無効化

expire_actionでキャッシュを無効化できます。Sweepwerを使って処理、タイミングを書く。caches.rbのサンプルを抜き出します。

   1  class ListSweeper < ActionController::Caching::Sweeper
   2      observe List, Item
   3  
   4      def after_save(record)
   5         list = record.is_a?(List) ? record : record.list
   6         expire_page(:controller => "lists", :action => %w( show public feed ), :id => list.id)
   7         expire_action(:controller => "lists", :action => "all")
   8          list.shares.each { |share| expire_page(:controller => "lists", :action => "show", :id => share.url_key) }
   9        end
  10     end
  11   
  12  class ListsController < ApplicationController
  13      caches_action :index, :show, :public, :feed
  14      cache_sweeper :list_sweeper, :only => [ :edit, :destroy, :share ]
  15  end

Refs

vendor/rails/actionpack/lib/action_controller/caching.rb
http://scottstuff.net/presentations/rails-caching/ かなり詳しい
http://www.ibm.com/developerworks/web/library/wa-rails1/
http://www.hostingrails.com/forums/rails_coding_thread/386

posted by Png satoko on Sat 28 Jun 2008 at 01:19

昨日、今日と二日続けてrepoが壊れたので解決策を探ってみました。コミットはこまめにしておくのが吉だと思います。

   1  $ git status
   2  error: bad signature
   3  fatal: index file corrupt

git-fsck --fullというコマンドも試してみたのですが、やっぱりだめ。というわけで、ダメもとで下記をやってみたらすんなり復旧できた。yay!

After trying many things, I deleted .git/index and ran git-reset which regenerated the file.
http://www.nishioka.com/blog/2008/01/source-control-with-git-and-cygwin.html

つまり下記でok!

   1  $ rm .git/index 
   2  $ git reset

Refs

http://www8.atwiki.jp/git_jp/pub/Documentation.ja/user-manual.html#recovering-from-repository-corruption

おまけ

誰かがバグを修正してコミットしてくれて、自分の手元のrepoが古くなったとき、rebaseすれば最新のをfetchしてきてくれます。

   1  $ git svn rebase

posted by Png satoko on Thu 26 Jun 2008 at 11:20

via http://groups.google.com/group/twitter-development-talk/browse_thread/thread/6f24e47cca5b68f6

We've successfully moved to the OpenFire Jabber server, and now have far more visibility into our XMPP services overall.

だから20req/hr制限なのかしら。
それにしても、早くtrackを復活させて欲しいです。
http://twitter.com/account/rate_limit_status.xml

OpenFireとは

Javaで書かれているそうです。twitterが以前使っていたejabberdはErlang。そしてあんまり情報がない...

Openfire (formerly Wildfire) is a real time collaboration (RTC) server dual-licensed under the Open Source GPL and commercially. It uses the only widely adopted open protocol for instant messaging, XMPP (also called Jabber). Openfire is incredibly easy to setup and administer, but offers rock-solid security and performance.
http://www.igniterealtime.org/projects/openfire/index.jsp

twitterが以前使っていたJabberServer:ejabberd

http://www.jabber.org/servers/ejabberd
http://www.atmarkit.co.jp/news/200704/27/erlang.html

Refs

http://www.jabber.org/servers
http://www.jabber.org/servers/openfire

posted by Png satoko on Wed 25 Jun 2008 at 15:39

http://drnicwilliams.com/2008/06/18/what-is-gitjour-gemjour-starjour/

USではRailsCampという合宿みたいな、田舎で数日籠ってhackして遊んだりなんかするというのが流行しているようですが、田舎ではインターネットがないことも多く、それで共同作業したりなんかするのに困ったという経験からいろいろツールが出てきたみたいです。

インストールの手順(必要なgemとか)はDrNicのサイトにありますので、そちらを参照してくださいね。

始まりはBonjour(Macの通信プロトコル)のオープンソース化

http://en.wikipedia.org/wiki/Bonjour_(software)

gitjour

Chad Fowlerさんたちが作ったこのツール、ローカルでgitリポジトリを共有するツールです。
http://github.com/chad/gitjour

pastejour

今度はJohn Barnetteさんが作ったpastejour。これはInternet(pastie)がなくても、コードのsnnipetを送れる仕組み。
http://github.com/jbarnette/pastejour

gemjour

さらにEvan Phoenixさんが、gemのサーバ機能を提供。誰かのローカルにあるgemを取ってこれるようになります。
http://github.com/evanphx/gemjour/tree/master

appjour:Macオンリー

Lachie Cox作。appをみんなで共有できます。
http://github.com/lachie/appjour

dejour:Macオンリー

Aaron Patterson作。Growl(Macの通知バルーン?)の仕組みを使った、ローカルネットワークでtwitterみたいな感じ?のようです。
http://github.com/aaronp/dejour/tree/master

stajour:Macオンリー

Lachie Cox作。上の通知を一覧にして表示できるアプリ。
http://github.com/lachie/starjour

最後のほうはMacオンリー。残念です... あとあと、USのギークたちはみんなでGuitar Hero3やったりするみたいですね...

posted by Png satoko on Thu 19 Jun 2008 at 13:31

rails tipsコンテストの流れで出会った記事。
http://scoop.cheerfactory.co.uk/2008/04/25/5-rails-tips/

上記で紹介されていた「Use of to_param for cheap seo」というのを実践してみました。これはAmazonで以前から実施されているSEOなのですが、ARのクラスでto_paramメソッドを用意すればいいだけだったのでやってみました。(コントローラではparam[:id]でIDを取得できるようです)

上記サイトで上がっていた例

   1  class ArticleActiveRecord::Base
   2    def to_param
   3      "#{id}-#{headline.gsub(/[^a-z0-9]+/i, '-')}".downcase
   4    end
   5  end
コードの詳細は下記をどうぞ。

一方、dummyパラメータを送ってもid=5の記事が見れてしまうという問題もあります:下記のどのURLを要求しても同じarticleが表示される。
http://myaceapp.com/articles/5
http://myaceapp.com/articles/5-railscasts-rocks
http://myaceapp.com/articles/5-ANYTHINGHEREATALL

s21gブログでのコード

   1  class ArticleActiveRecord::Base
   2    def to_param
   3      "#{id}-#{CGI.escape(title)}".downcase
   4    end
   5  end
(注) titleが長い場合もあるので短く切ってからのほうが良いかも
(注) タイトルに数字が入っている場合うまくparams[:id]が取れないこともあるみたいです

気づいたSEOやってるサービス

結論:cheapなのでやめました

一昨日昼くらいから、昨日の昼くらいまで使っていたのですが、結局cheap SEOはとりやめました。理由としては、

  • RSS中のURLがすべて新しくなるため、読者の人に良くない(瀧内さん指摘)
  • 運営し始めてある程度時間経過しているので、URLが変わるページが多く、逆にSEO的にやさしくない → 異なるURLに対して同じ内容のページが二つ存在するとスパムとみなされることがある
  • URLが長くなるのはSEOにはやさしいが、人間にはやさしくない

というわけで、サービス運営初期時でもcheap SEOは効果的ですが、すでに運営を開始して時間が経っているサービスには良くないですという結論です。
RSSを購読下さっている読者の皆様、ご迷惑をおかけしました...

posted by Png satoko on Thu 19 Jun 2008 at 06:01
posted by Png satoko on Tue 10 Jun 2008 at 06:12

今までtraceでデバッグしてきましたが、一度は使ってみようと思い使ってみました。便利ではありませんが、処理の流れを確かめたいというときはよいと思います。

デバッグの準備:デバッグ用AIRの準備

1つ目のコマンドプロンプト開き、デバッグ用flashを生成します。

   1  C:\test_app>amxmlc -debug=true app.mxml

デバッグの準備:fdbコマンドラインデバッガ

2つ目のコマンドプロンプト開きます

   1  C:\flex_sdk_3\bin>fdb
   2  (fdb) run
   3  Player が接続するのを待っています

デバッガーの開始

1つ目のプロンプトで、AIRアプリを実行します

   1  C:\test_app>adl app.xml

2つ目のプロンプトでAIRアプリが接続した旨が表示されます

   1  (fdb) run
   2  Player が接続するのを待っています
   3  Player が接続されました。セッションを開始しています。
   4  [SWF] app.swf - 1,177,344 バイト (解凍後)

ブレークポイントを設定する

ファイル:app.mxmlの62行目に追加する場合

   1  (fdb) b app.mxml:62 
   2  (fdb) continue
   3  SWF ファイルまたはフレームから追加の ActionScript コードがロードされました。
   4  現在ロードされているすべてのファイルを表示するには、「info files」と入力してくだ
   5  さい。
   6  ブレークポイント 7 が app.mxml:62 の onAppComplete() に解決されました

ブレークポイントの確認

   1  (fdb) info breakpoints
   2  Num Type           Disp Enb Address    What
   3  7   breakpoint     keep y   0x00000000 の場所にある onAppComplete() 内 app.mxml:62

ブレークポイントの削除

continueを発行してブレークポイントが設定できなかった場合など、下記のように削除します

   1  (fdb) delete 2
   2  (fdb) delte 3 6
   3  (fdb) continue

スタックトレースの表示

ブレークポイントで停止した際に下記のコマンドでスタックトレースが表示されます

   1  (fdb) bt
   2  #0   this = [Object 35225761, class='memoApp'].app/onAppComplete(e=[Object 3
   3  7504001, class='mx.events::AIREvent']) 場所 :  app.mxml:62
   4  #1   EventDispatcher/dispatchEventFunction() 場所 :  app.mxml:0
   5  #2   this = [Object 35225761, class='memoApp'].EventDispatcher/dispatchEvent(_ar
   6  g1=[Object 37504001, class='mx.events::AIREvent']) 場所 :  app.mxml:0
   7  #3   this = [Object 35225761, class='memoApp'].UIComponent/dispatchEvent(event=[
   8  Object 37504001, class='mx.events::AIREvent']) 場所 :  UIComponent.as:9051
   9  #4   this = [Object 35225761, class='memoApp'].WindowedApplication/enterFrameHan
  10  dler(e=[Object 37504289, class='flash.events::Event']) 場所 :  WindowedApplicati
  11  on.as:2522

Refs

http://livedocs.adobe.com/flex/3_jp/html/help.html?content=CommandLineTools_4.html
http://livedocs.adobe.com/flex/3_jp/html/help.html?content=debugging_03.html#240390
http://livedocs.adobe.com/flex/3_jp/html/help.html?content=debugging_02.html#240284
http://www.adamrocker.com/blog/151/actionscript30_flex_debugger_fdb.html

posted by Png satoko on Mon 2 Jun 2008 at 11:50