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 print-subtree [subtree prefix] | |
(if (empty? subtree) | |
"" | |
(apply str prefix (first subtree) "\n" | |
(map #(print-subtree %1 (str "\t" prefix)) (rest subtree))))) | |
(defn print-tree [tree] | |
(print-subtree tree "")) | |
(deftest print-empty-tree |
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
require 'rubygems' | |
require 'awesome_print' | |
load 'repodepot.rb' | |
class CodeEvent | |
def full_method_name | |
class_name + "#" + method_name | |
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
describe "Explored minefield", -> | |
expectHints = (mines) -> | |
expect(new exports.Minefield(mines:mines,explored:true).hints()) | |
it "shows rows and columns", -> | |
expectHints(["...","..."]).toEqual ["000", "000"] | |
it "shows minefield shape", -> | |
expectHints(["..","..",".."]).toEqual ["00","00","00"] |
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 exports.Minefield | |
constructor: (@cells)-> | |
hints: -> | |
((@hint(row,col) for col in @cols()).join("") for row in @rows()) | |
rows: -> [[email protected]] | |
cols: -> [0...@cells[0].length] | |
hint: (row,col) -> |
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
v Separate Solar system and bouncing ball logic | |
v Delete IS_BOUNCING_BALL flagg | |
v Move main method of Space to subclasses | |
v Create subclasses of "Space" | |
v Remove IS_BOUNCING_BALLS if-test in main | |
v Extract main method logic to non-static method | |
v Make IS_BOUNCING_BALLS into an argument | |
v Convert if statements into polymorphism | |
v Convert IS_BOUNCING_BALLS into non-static field in Space | |
v Move IS_BOUNCING_BALLS to Space |
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 ShoppingCart | |
constructor: (@items)-> | |
@counts = (count for item,count of @items).sort().reverse() | |
totalPrice: -> @subTotal() - @discount() | |
subTotal: -> | |
result = 0 | |
result += count*8 for item,count of @items | |
result | |
discount: -> | |
@discountForSetOfSize(2, 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
public class Demo { | |
private static Object baseUrl; | |
public static void main(String[] args) { | |
Namespace SOAP_NS = new Namespace("http://soap.com", "SOAP"); | |
Namespace MSG_NS = new Namespace("http://msg.com", "msg"); | |
TagName envelopeTag = SOAP_NS.tag("Envelope"); | |
Element envelope = envelopeTag.create( |
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
public class CurrencyPublisherTest { | |
private SubscriptionRepository subscriptionRepository = mock(SubscriptionRepository.class); | |
private EmailService emailService = mock(EmailService.class); | |
private CurrencyPublisher publisher = new CurrencyPublisher(); | |
private CurrencyService currencyService = mock(CurrencyService.class); | |
private GeolocationService geolocationService = mock(GeolocationService.class); | |
@Test | |
public void shouldPublishCurrency() throws Exception { |
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
package no.something.ftas.solvers; | |
import no.something.ftas.QuestionSolver; | |
public class AdditionSolver extends QuestionSolver { | |
public AdditionSolver() { | |
super("Addition"); | |
} |
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
package com.johannesbrodwall.infrastructure; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import java.io.File; | |
import java.io.FileInputStream; | |
import java.io.IOException; | |
import java.util.Properties; |
OlderNewer