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
require 'rspec' | |
# The goal is to make the tests pass | |
# Get the cheapest price for each seller. | |
# Seller x the priority seller. | |
# returs a hash containing fruits, | |
# sub keys under fruits are prices | |
# and fruit "keys" | |
def fruits_prices(sellers) |
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
// <input ng-model="foobar"> | |
// $scope.foobar is an object with attribute 'baz' | |
$scope.foo = _.map($scope.barArray, function(bar) { | |
if(bar.baz === $scope.foobar.baz) { | |
return bar; | |
} | |
}); | |
// after uglifying, i cannot access $scope.foobar.baz in the _.map anymore |
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
# q can be unlimited length | |
# one var only | |
# each element is a single digit integer | |
class SingleVarQ | |
def initialize(start) | |
@q = start | |
end | |
def queue |
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 Child < ActiveRecord::Base | |
belongs_to :parent | |
def self.update_info | |
self.with_lock | |
if true | |
# succesful | |
true | |
else | |
# fail |
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
<% form_for @object do |f| %> | |
<%= f.label :foo %> | |
<%= f.text_field :foo %> | |
<% f.fields_for :bar do |ff| %> | |
<%= ff.radio_button :some_attr, 1 %> | |
<%= ff.label :some_attr %> | |
<%= ff.radio_button :some_attr, 2 %> | |
<%= ff.label :some_attr %> | |
<% end %> |