This file contains hidden or 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
| (map | |
| (fn [n] (cond (= (mod n 15) 0) "FizzBuzz" | |
| (= (mod n 3) 0) "Fizz" | |
| (= (mod n 5) 0) "Buzz" | |
| :else n)) | |
| (range 1 101)) |
This file contains hidden or 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
| class WordFilter | |
| def initialize(*ng_words) | |
| @ng_words = ng_words | |
| end | |
| def detect(message) | |
| message =~ /#{@ng_words.join('|')}/ | |
| end | |
| def censor(message) |
This file contains hidden or 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
| class WordFilter | |
| attr_reader :words | |
| attr_accessor :censor_message | |
| def initialize(*words) | |
| @words = words | |
| @censor_message = "censored" | |
| end | |
| def detect(message) |
This file contains hidden or 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
| Session.pre_send_message_timeline_status do |sender, e| | |
| result = e.text.scan( /http:\/\/movapic\.com\/pic\/\w+/) | |
| if result.size > 0 | |
| params = result.first.split('/') | |
| e.text = e.text + " http://image.movapic.com/pic/m_#{params.last}.jpeg" | |
| end | |
| end |
This file contains hidden or 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
| class CreateUsers < ActiveRecord::Migration | |
| def self.up | |
| create_table :users do |t| | |
| t.string :login, :null => false | |
| t.string :name, :null => false | |
| t.string :crypted_password | |
| t.string :salt | |
| t.timestamps | |
| end | |
| end |
This file contains hidden or 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
| Rails.configuration.middleware.use RailsWarden::Manager do |manager| | |
| manager.default_strategies :password | |
| manager.failure_app = SessionsController | |
| end | |
| class Warden::SessionSerializer | |
| def serialize(record) | |
| [record.class, record.id] | |
| end |
This file contains hidden or 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
| class User < ActiveRecord::Base | |
| has_many :receipts | |
| include Authentication | |
| include Authentication::ByPassword | |
| validates_presence_of :login | |
| validates_length_of :login, :within => 3..40 | |
| validates_uniqueness_of :login |
This file contains hidden or 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
| class SessionsController < ApplicationController | |
| def new | |
| end | |
| def create | |
| authenticate! | |
| redirect_to dashboard_path | |
| end | |
| def destroy |
This file contains hidden or 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
| source 'http://rubygems.org' | |
| gem 'rails', '3.0.0' | |
| gem 'sqlite3-ruby', :require => 'sqlite3' | |
| group :development, :test do | |
| gem 'rspec','>=2.0.0.beta.20' | |
| gem 'rspec-rails','>=2.0.0.beta.20' | |
| gem 'ZenTest' | |
| gem 'autotest' |
This file contains hidden or 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
| --format nested | |
| --color | |
| --drb |