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
| using System; | |
| using Machine.Specifications; | |
| using Given = Machine.Specifications.Establish; | |
| using When = Machine.Specifications.Because; | |
| using Then = Machine.Specifications.It; | |
| namespace TryMSpec { | |
| public class TicketCalculator{ | |
| private decimal _ticket_price = 11m; | |
| public void StartPurchase(int runtime, DayOfWeek day, bool isParquet, bool is3D) {} |
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
| // TotalCalculator.js | |
| function TotalCalculator() { | |
| } | |
| TotalCalculator.prototype.calculate = function(quantity, price) { | |
| var _quantity = parseInt(quantity); | |
| if (isNaN(_quantity)) | |
| return 'N/A'; | |
| var _price = parseInt(price.replace('$', '')); |
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
| /* | |
| function Calculator() { | |
| this.add = function(input) { | |
| var result = 0; | |
| for(i = 0; i<input.length; ++i) { | |
| result += input[i]; | |
| } | |
| return result; | |
| } |
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 ApplicationHelper | |
| def error_publisher(model) | |
| # Thanks Joe! | |
| return unless model.errors.any? | |
| item_errors = '' | |
| model.errors.full_messages.each do |e| | |
| item_errors += "<li>#{e}</li>" | |
| 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 TracksController < ApplicationController | |
| def index | |
| signed_in_user | |
| end | |
| def new | |
| @track = Track.new | |
| end | |
| def create |
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 CarElement | |
| def accept(visitor) | |
| raise NotImpelementedError.new | |
| end | |
| end | |
| module Visitable | |
| def accept(visitor) | |
| visitor.visit(self) | |
| 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 ActiveRecord; class Base; end; end | |
| # The AR Models Rails give you | |
| class User < ActiveRecord::Base | |
| # These fields are defined dynamically by ActiveRecord | |
| attr_accessor :id, :full_name | |
| end | |
| class Discussion < ActiveRecord::Base | |
| # These fields are defined dynamically by ActiveRecord |
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 StringCalculator | |
| calculate: (input) -> | |
| @validateArgument(input) | |
| result = 0 | |
| result += parseInt(splitValue) for splitValue in @splitValues(input) | |
| result | |
| validateArgument: (input) -> |
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 'ostruct' | |
| module SortWithOther | |
| def <=>(other) | |
| if self.send(sort_field).downcase == "Other".downcase | |
| 1 | |
| elsif other.send(sort_field).downcase == "Other".downcase | |
| -1 | |
| else | |
| self.send(sort_field) <=> other.send(sort_field) |
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 App.ScoreBoard | |
| permutations = | |
| [['A_1', 'B_1', 'C_1'], | |
| ['A_2', 'B_2', 'C_2'], | |
| ['A_3', 'B_3', 'C_3'], | |
| ['A_1', 'A_2', 'A_3'], | |
| ['B_1', 'B_2', 'B_3'], | |
| ['C_1', 'C_2', 'C_3'], |
OlderNewer