Skip to content

Instantly share code, notes, and snippets.

@Epictetus
Epictetus / memo.md
Created July 22, 2012 22:50 — forked from deeeki/memo.md
RailsにおけるRESTfulなURL設計勉強会
  • legacy wild controller route ':controller(/:action(/:id))(.:format)' は使わない派

  • 利用するURLを明示しておきたい

  • named_route使えないとリンクの記述が冗長になるのでは

  • namespaceなど少し複雑なことをやろうとすると何かしらルーティングを書くことになり、統一感がなくなる

  • 確認画面

    • confirmアクションの追加
      • 各アクションがすっきりする
      • 新規と編集で挙動が変わる場合 (edit_confirmアクション?)
  • パラメータ(mode=confirm)またはモデルの確認用プロパティ(http://bit.ly/mRQ8I5)

@Epictetus
Epictetus / Blog.creole
Created July 21, 2012 07:02 — forked from robotarmy/Blog.creole
Building Small Web Services with a Heroku and Unicorn Sinatra Template Project

Using Sinatra Unicorn and Heroku (CEDAR stack) Together!

I have been asked

  • "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

@Epictetus
Epictetus / devise.ja.yml
Created July 13, 2012 12:13 — forked from orzccc/devise.ja.yml
Japanese locale file for "Devise" (2.1.2) http://github.com/plataformatec/devise/wiki/I18n
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: "は凍結されていません"
@Epictetus
Epictetus / cfb2.rb
Created July 12, 2012 17:47 — forked from jimweirich/cfb2.rb
Inspired by "Programming with Nothing" http://experthuman.com/programming-with-nothing. See comment below for some details.
require './interface'
puts to_strings(->(limit) {
->(lst) {
->(f) {
->(f) {
->(g) {
->(n) {
f.(g.(g)).(n)
}
}.(->(g) {
@Epictetus
Epictetus / icebox.rb
Created July 8, 2012 01:20 — forked from hanachin/icebox.rb
add stories to PivotalTracker from Twitter hash
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
@Epictetus
Epictetus / test_http_digest_rails3_patch.rb
Created July 6, 2012 12:28 — forked from denisahearn/test_http_digest_rails3_patch.rb
Testing HTTP Digest Authentication in Rails 3
# 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)
@Epictetus
Epictetus / real_world_druby.md
Created July 5, 2012 01:57 — forked from makoto/real_world_druby.md
実世界でのdRubyの使用例

実世界でのdRubyの使用例

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を使った良い例といえよう。またスクリーンショットマシーンは並列処理が行われていたため、スケーラビリティも確保されていた。

@Epictetus
Epictetus / gist:3045637
Created July 4, 2012 06:00 — forked from yagitoshiro/gist:3039968
Titanium Mobile用のSQLiteを扱うクラス・第二形態
# モデルがこれだけで作れたら素敵じゃないか
# entry.coffee
Database = require('libs/database')
class Entry extends Database
initialize:()->
@property 'title', 'text'
@property 'body', 'text'
super
module.exports = new Entry('entries')
module TwitterBootstrapHelper
# Usage:
#
# icon(:'exclamation-sign')
#
def icon(name)
content_tag :i, '', :class => "icon-#{name}"
end
# Usage:
@Epictetus
Epictetus / metaserver.rb
Created June 29, 2012 19:55 — forked from fractaloop/metaserver.rb
Rails 3.1 Sinatra streaming question...
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