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
| 1 module Resolvers | |
| 2 autoload :MobileFallbackResolver, 'resolvers/mobile_fallback_resolver' | |
| 3 | |
| 4 #ActiveSupport.on_load(:action_controller) do | |
| 5 #append_view_path(MobileFallbackResolver.new('app/views')) | |
| 6 #end | |
| 7 | |
| 8 # class Railtie < ::Rails::Railtie | |
| 9 # initializer 'resolvers.mobile_fallback_resolver' do |app| | |
| 10 # ActiveSupport.on_load(:action_controller) do |
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
| constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? } | |
| constraints constraint do | |
| mount Sidekiq::Web => '/sidekiq' | |
| 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
| module Sidekiq | |
| module Extensions | |
| class Proxy | |
| def method_missing(name, *args) | |
| @target.send(name, *args).deliver | |
| end | |
| end | |
| 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 Synapse | |
| constructor: (@sourceNeuron, @destNeuron) -> | |
| @prevWeight = @weight = (Math.random() * 2.0) - 1.0 | |
| class Neuron | |
| learningRate: 1.0 | |
| momentum: 0.3 | |
| constructor: -> | |
| @synapsesIn = [] |
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
| remaining: function() { | |
| return this.filterProperty('isDone', false).get('length'); | |
| }.property('@each.isDone'), |
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
| (defn divisible-by-3-or-5? [num] (or (== (mod num 3) 0)(== (mod num 5) 0))) | |
| #'user/divisible-by-3-or-5? | |
| user=> (take-while divisible-by-3-or-5? [7 9 13 5 8 3 1]) | |
| () | |
| user=> (take-while odd? [7 9 13 5 8 3 1]) | |
| (7 9 13 5) |
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
| ree-1.8.7-2011.03 :001 > messages = [] | |
| => [] | |
| ree-1.8.7-2011.03 :002 > messages << {:a => 1, :b => 2} | |
| => [{:b=>2, :a=>1}] | |
| ree-1.8.7-2011.03 :003 > messages << {:a => 3, :b => 4} | |
| => [{:b=>2, :a=>1}, {:b=>4, :a=>3}] | |
| ree-1.8.7-2011.03 :004 > messages.map do |m| | |
| ree-1.8.7-2011.03 :005 > m[:a] = 5 | |
| ree-1.8.7-2011.03 :006?> end | |
| => [5, 5] |
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
| Loading development environment (Rails 3.1.0) | |
| ree-1.8.7-2011.03 :001 > I18n.locale | |
| => :"en-US" | |
| ree-1.8.7-2011.03 :002 > exit | |
| ~/project > git checkout master | |
| Previous HEAD position was x314a19... bundle in activeadmin | |
| Switched to branch 'master' | |
| Loading development environment (Rails 3.1.0) |
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 Subscription | |
| belongs_to :user | |
| belongs_to :magazine | |
| validates :user_id, :uniqueness => {:scope => :magazine_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 Foo < ActiveRecord::Base | |
| include Models::Scopes::Order | |
| default_scope recently_updated # didn't realize you could do this | |
| end |