-
legacy wild controller route ':controller(/:action(/:id))(.:format)' は使わない派
-
利用するURLを明示しておきたい
-
named_route使えないとリンクの記述が冗長になるのでは
-
namespaceなど少し複雑なことをやろうとすると何かしらルーティングを書くことになり、統一感がなくなる
-
確認画面
- confirmアクションの追加
- 各アクションがすっきりする
- 新規と編集で挙動が変わる場合 (edit_confirmアクション?)
- confirmアクションの追加
-
パラメータ(mode=confirm)またはモデルの確認用プロパティ(http://bit.ly/mRQ8I5)
- "How do I get started with Unicorn and Heroku?"
- "How can I made a remote HTTP webhook?"
- "How can I make a simple web service?" ,
- "How can I get started with a free ruby hosting evironment?"
I want to take a moment to answer a few of these questions in a small package I have
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ja: | |
errors: | |
messages: | |
expired: "の期限が切れましたので、新しくリクエストしてください" | |
# expired: "has expired, please request a new one" | |
not_found: "は見つかりませんでした" | |
# not_found: "not found" | |
already_confirmed: "は既に登録済みですのでログインしてください" | |
# already_confirmed: "was already confirmed, please try signing in" | |
not_locked: "は凍結されていません" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './interface' | |
puts to_strings(->(limit) { | |
->(lst) { | |
->(f) { | |
->(f) { | |
->(g) { | |
->(n) { | |
f.(g.(g)).(n) | |
} | |
}.(->(g) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'twitter' | |
require 'pivotal-tracker' | |
Twitter.configure do |c| | |
c.consumer_key = "your consumer key" | |
c.consumer_secret = "your consumer secret key" | |
c.oauth_token = "oauth token" | |
c.oauth_token_secret = "oauth token secret" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Adds support for http digest authentication in Rails 3 | |
# Inspired by: http://lightyearsoftware.com/2009/04/testing-http-digest-authentication-in-rails/ | |
# Place this code in test/test_helper.rb | |
# In your test, call authenticate_with_http_digest prior to calling get, post, put or delete | |
# Tested with Rails 3.0.7 | |
class ActionController::TestCase | |
require 'digest/md5' | |
def authenticate_with_http_digest(user = API_USERNAME, password = API_PASSWORD, realm = API_REALM) |
dRubyはこれまでに多くの大規模システムの基盤として利用されてきました。dRubyはいつものRubyプログラミングに非常に近い感覚で分散オブジェクトを実現します。これにより、複雑な分散システムであってもアイデアをすぐに実現することができます。 dRubyが提供するのは汎用のRMIです。スケッチの段階でdRubyを用い、有用性を確認したのちに用途に特化したミドルウェアに置き換えるといったように成長していったシステムも多いようです。 以下に実世界でのdRubyの使用例を示します。
Hatena Screen Shot (http://www.hatena.ne.jp/)
Hatena は日本を代表するインターネットカンパニーで、ブログ、ソーシャルブックマークサービスなどを提供しています。2006年当時(現在はサービス終了) Hatena Screen Shotという、登録されたURLのスクリーンショットをサムネイルとして表示するサービスがありました。このサービスのアーキテクチャーのユニークな点にWebフロントエンドはLinux上に構築されているが、スクリーンショットの撮影はWindowsのIEコンポーネントを用いて実現されていることにある。これはWindows環境の方がスクリーンショットを撮影できる環境が整っていたためであるが、クロスプラットフォーム間のシステムを協調させるdRubyを使った良い例といえよう。またスクリーンショットマシーンは並列処理が行われていたため、スケーラビリティも確保されていた。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# モデルがこれだけで作れたら素敵じゃないか | |
# entry.coffee | |
Database = require('libs/database') | |
class Entry extends Database | |
initialize:()-> | |
@property 'title', 'text' | |
@property 'body', 'text' | |
super | |
module.exports = new Entry('entries') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TwitterBootstrapHelper | |
# Usage: | |
# | |
# icon(:'exclamation-sign') | |
# | |
def icon(name) | |
content_tag :i, '', :class => "icon-#{name}" | |
end | |
# Usage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'thin' | |
class Metaserver < Sinatra::Base | |
set server: 'thin' | |
set connections: [] | |
get '/stream', provides: 'text/event-stream' do | |
stream :keep_open do |out| | |
settings.connections << out |