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(type="hidden" name="address[id]" value="#{address.id}") | |
%fieldset | |
%ul | |
%li | |
%label(for="address[first_name]") First Name | |
%input(type="text" name="address[first_name]" value="#{address.first_name}" size="20") | |
%li | |
%label(for="address[last_name]") Last Name | |
%input(type="text" name="address[last_name]" value="#{address.last_name}" size="20") |
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
Threadflip.InfiniteScrollCollection = | |
infiniteScroll: (options) -> | |
success = options.success || -> | |
offset = options.offset || 400 | |
enabled = false | |
start = (params = {}) -> | |
unless enabled | |
# Bind to the scroll event. | |
$(window).scroll onScroll |
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
describe Purchase do | |
let(:have_1) { FactoryGirl.build_stubbed(:have, asking_price: 15) } | |
let(:have_2) { FactoryGirl.build_stubbed(:have, asking_price: 20) } | |
describe "#amount_for_haves" do | |
let(:amount_for_haves) { purchase.amount_for_haves([have_1, have_2], credit, promo) } | |
let(:credit) { 0 } | |
let(:expected_amount_for_haves) do | |
# Order haves by asking_price, high to low. | |
have_2_expected_amount_hash.merge(have_1_expected_amount_hash) |
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
def available_if_enough_info | |
if self.available? || self.display_only? | |
if self.can_be_available? | |
self.available! | |
else | |
self.display_only! | |
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
describe Foo do | |
let(:big_params) do | |
{ | |
foo: foo, | |
name: "name", | |
... | |
} | |
end | |
let(:foo) { nil } |
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 BaseView extends Backbone.View | |
template: "" | |
# Render hooks. | |
beforeFirstRender: -> | |
beforeRender: -> | |
afterRender: -> | |
afterFirstRender: -> | |
render: => |
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 InFlip | |
initialize: (options) -> | |
@set 'stripe_token', new Threadflip.StripeToken(options.stripeToken) | |
fetchStripeToken: -> | |
@get('stripe_token').fetch() |
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
def solution(strengths, weights, connections) | |
# simulate the order by going through the conections and building the graph | |
# at each step, evaluate the graph to detect breaks | |
# at each step, attach the weight, then travel up the graph and check for breaks O(n * log(n)) | |
# data structure: | |
# node(parent_node, strength, weight (incl. children), children) | |
# map(i: node) | |
# create root node |
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 LRUCache | |
MAX_SIZE = 3 | |
def initialize | |
@cache = {} | |
@max_size = MAX_SIZE | |
@lru_list = List.new | |
end | |
def get(key) |
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
var $ = require('jQuery'); | |
var _ = require('_'); | |
var React = require('react'); | |
var FinancingApplicationView = require('financing/views/FinancingApplicationView.react.jsx'); | |
var FinancingConstants = require('financing/FinancingConstants.js'); | |
var FinancingApplicationData = require('financing/models/FinancingApplicationData.js'); | |
var FinancingApplicant = require('financing/models/FinancingApplicant.js'); | |
var activeApplicant = new FinancingApplicant(); |