寄付の募り方
http://tin
手軽なマネタイズ方法としてつけることも検討してみよう
http://tin
手軽なマネタイズ方法としてつけることも検討してみよう
下記URLから入手できます。
http://svn
URLを渡すとTinyURLに変換してリンクを作ります。
1 module ApplicationHelper 2 include TinyurlHel per 3 end
1 <%= link_to_tinyurl "http://www .yahoo.co. jp" %>
1 script/generate plugin tinyurl_he lper
1 require 'net/http' 2 3 module TinyurlHelper 4 def link_to_ti nyurl(url, html_optio ns = nil) 5 uri = 'http://tin yurl.com/a pi-create. php?url=' + url 6 uri = URI.parse(uri) 7 tiny_url = Net::HTTP.get_respon se(uri).body 8 options = {:title => url, :alt => url} 9 options = html_optio ns.nil? ? options : options.merge(html_optio ns) 10 link_to tiny_url, tiny_url, options 11 end 12 end
テストを書く(アプリテスト、プラグイン単体テスト両方通るように書くと吉)
1 - 2 require 'test/unit' 3 require File.expand_path(File.dirname(__FILE__) + "/../lib/ti nyurl_help er") 4 5 class TinyurlHel perTest < Test::Unit ::TestCase 6 include TinyurlHel per 7 8 #dummy link_to 9 def link_to(name, options = {}, html_optio ns = nil) 10 [name, html_optio ns[:title]] 11 end 12 13 def test_link_ to_tinyurl 14 url = 'http://www .yahoo.co. jp/' 15 tiny_url, title = link_to_ti nyurl(url) 16 assert_equ al 'http://tin yurl.com/9 10', tiny_url 17 assert_equ al url, title 18 end 19 20 def test_link_ to_tinyurl _with_titl e 21 url = 'http://www .yahoo.co. jp/' 22 tiny_url, title = link_to_ti nyurl(url, {:title => 'title'}) 23 assert_equ al 'http://tin yurl.com/9 10', tiny_url 24 assert_equ al 'title', title 25 end 26 end
README, MIT-LICENS
公開用リポジトリにコミット
1 ActionView::Base.send :include, TinyurlHel per
今年の目標に、railsのプラグインを作るというのがあるのですが、時間ができたらと言わずに「さっさと/ささっと作れ」という助言をもらったのでささっとやってみました。まずはどいういうものかという初歩的なところから。
ここに多く集められています。
http://agi
プラグインはRailsの機能拡張するものなのですが、下記のように分類できます。
今日、Skypeチャットルームで話されてたんだけど、「digg is really one-day fly spike」(Diggは一日だけの急上昇飛行)なんだそう。もしかしてはてぶそうなのかもですね。今まではなんとなくブックマークサービスとしてだけ見ていましたが、ユーザーの使い方がDiggぽいといえばDiggぽい。だのにブックマークサービスだから、議論とかがしにくい。
ユニークな見方をもらいました。
http://h.h
携帯のエッセンスだけを残したのがModu。
ジャケットを変えるだけで、MP3プレイヤー・普通の携帯電話・GPSナビゲーションシステム等いろんな役目を果たしてくれるなんてステキ!
http://www
.modumobil e.com/
http://www.technolog yreview.co m/Infotech /20276/
とりあえず、modulemobi
そうそうイスラエルのstarupなんです。イスラエルってデバイス系のstarup多い気がします。
http://www
詳細は原文で確認してくださいね。news.ycomb
http://www
Amazon DevPay is a simple-to-
use billing and account management service that makes it easy for developers to get paid for applicatio ns they build on Amazon Web Services.
Sellers of Amazon DevPay applicatio
ns must be able to do business in the United States. Funds earned through the sale of Amazon DevPay applicatio ns can only be withdrawn to U.S. bank accounts.
rttool 1.0.2.0のgem installに失敗して困ったので記事にしてみます。
RTtoolはシンプルな作表ツール。
http://www
1 gem install rttool 2 ERROR: While executing gem ... (Errno::ENOENT) 3 No such file or directory - /usr/local /bin/rt/rd rt2
下記で解決。tar.gzファイルを落としてインストールすればOKです。
http://www
1 wget http://www.rubyist.n et/~rubiki tch/archiv e/rttool-1 .0.2.tar.g z 2 tar xzvf rttool-1.0 .2.tar.gz 3 cd rttool-1.0 .2 4 ruby setup.rb config 5 ruby setup.rb setup 6 ruby setup.rb install
あすなろとのダブルポストです。
仕事で使ってみたところ、とても簡単にそしてかっこいいグラフが表示できたので紹介します。配置ディレクトリがRoR前提になっていますが、適宜自分の環境に合うように変更してください。
enjoy! ;)
GNU General Public Licenseで公開されています。
http://tee
GoogleFina
http://fin
ダウンロードして適当なところに解凍します。
http://tee
解凍したディレクトリ直下のopen-flash
1 <% stats[:posts] = [23,44,35,46,78,7] %> 2 3 <%= javascript_include_t ag 'swfobject' %> 4 <div id="chart"></div> 5 <script type="text/javas cript"> 6 var so = new SWFObject("/open-flas h-chart.sw f", "ofc", "180", "100", "9", "#FFFFFF"); 7 so.addVariabl e("variables","true"); 8 so.addVariabl e("y_label_st yle", 'none'); 9 so.addVariabl e("x_label_st yle", "10,#799191,0,2"); //2は2メモリごとにラベル表示の意。 10 so.addVariabl e("x_axis_ste ps","1"); //メモリ軸 11 so.addVariabl e("y_ticks","5,10,2"); 12 so.addVariabl e("y_min","<%= stats[:posts].min %>"); //最小値 13 so.addVariabl e("y_max","<%= stats[:posts].max %>"); //最大値 14 so.addVariabl e("x_labels","Mon,Tue,Wed,Thurs,Fri,Sat,Sun"); //x軸ラベル 15 so.addVariabl e("values", "<%= stats[:posts].join(',') %>"); //値 16 so.addVariabl e("line_hollo w", "3,#799191,This week,10,5"); //グラフの種類 17 so.addVariabl e("bg_colour", "#F0F0F0"); 18 so.addVariabl e("x_axis_col our", "#FFFFFF"); 19 so.addVariabl e("x_grid_col our", "#FFFFFF"); 20 so.addVariabl e("y_axis_col our", "#FFFFFF"); 21 so.addVariabl e("y_grid_col our", "#FFFFFF"); 22 so.addVariabl e("tool_tip","#x_label#:#val#"); 23 24 so.addParam("allowScrip tAccess", "sameDomain "); 25 so.write("chart"); 26 </script>
(追記) 経緯:attr_read
例えば、Blogテーブルにarticles_c
1 class Article < ActiveRecord::Base 2 belongs_to :blog, :counter_ca che => true
Rails2.0からカウンターキャッシュカラム(ex Blog#articles_c
1 #NG for Rails2.0 2 blog.update_attribute :articles_c ount, total
1 def self.up 2 add_column:blogs, :articles_c ount, :integer, :default => 0 3 4 Blog.find(:all).each do |blog| 5 Blog.update_cou nters(blog.id, :articles_c ount => blog.articles.count) 6 end
あすなろとダブルポストです。+最後の感想ちょこっと変更しました。
Ctonroller
after_cont
oroller_ac tion
before_contoroller_a ction
ex. after_blog
→ BlogContro
ぐぐってヒントを見つける。
[Rails][cache] Sweeper
http://d.h
なんとなくはわかるけど、やっぱりよくわからないのでソースを見ることにする。
Rails Referenceで検索する。右上にファイルの場所があるので確認。
vendor/rai
http://api
ソースを読む:cache_swe
1 def cache_sweeper(*sweepers) 2 return unless perform_ca ching 3 configurat ion = sweepers.extract_op tions! 4 sweepers.each do |sweeper| 5 ActiveReco rd::Base.observers << sweeper if defined?(ActiveReco rd) and defined?(ActiveReco rd::Base) 6 sweeper_in stance = Object.const_get(Inflector.classify(sweeper)).instance 7 if sweeper_in stance.is_a?(Sweeper) 8 around_fil ter(sweeper_in stance, :only => configurat ion[:only]) 9 else 10 after_filt er(sweeper_in stance, :only => configurat ion[:only]) 11 end 12 end 13 end
ソースを読む:after処理のエントリポイント
1 def after(controller) 2 callback(:after) 3 # Clean up, so that the controller can be collected after this request 4 self.controller = nil 5 end
ソースを読む:after_cont
1 def callback(timing) 2 controller_callback_ method_nam e = "#{ timing}_#{controller .controller _name.underscore }" 3 action_cal lback_meth od_name = "#{controller _callback_ method_nam e}_#{controller .action_nam e}" 4 send!(controller _callback_ method_nam e) if respond_to ?(controller _callback_ method_nam e, true) 5 send!(action_cal lback_meth od_name) if respond_to ?(action_cal lback_meth od_name, true) 6 end
最後の、"send!(action...:
愛が足りないながんばろ。