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
I'm wondering what speed benefits using rails-api gives you over the normal rails stack. Conceptually it makes sense that removing unneeded pieces will help, but most of the default rails middleware is still in place, so I'm wondering if the boost is actually noticeable. | |
Removing those pieces does restrict your ability to use things like active_admin to manage your data, so I'd only go with the slimmer rails-api style project if the improvements are noticeable. |
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
git rm `git status | grep deleted | cut -f2 -d: | xargs` |
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
= form_for @list do |f| | |
no routes matches /lists | |
= form_for @list, url: (@list.new_record? ? lists.lists_path : lists.list_path(@list) do |f| |
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
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 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 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 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 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 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 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] |