Skip to content

Instantly share code, notes, and snippets.

package org.scalavienna.refactoringdojo.gameoflife
import org.scalatest.FunSuite
import org.scalatest.Matchers
import org.scalatest.exceptions.TestFailedException
import scala.Array.canBuildFrom
import scala.Array.fallbackCanBuildFrom
/**
* As a general rule, don't remove test-cases. You are free to add, though.
@sebnozzi
sebnozzi / Instructions.md
Last active August 29, 2015 14:10
Pair-Programming

We'll exchange important info over PGP.

I am using this browser-based tool:

http://ianpurton.com/online-pgp/

I generated new keys there. I recommend you do the same (don't use your normal keys on your machine).

object PositiveIntApp extends App {
// The class Option[T] allows us to eventually wrap around a value.
// Instances of Option[T] *could* have a value, or not.
//
// If they have a value, we are dealing with a Some[T], which is a
// subclass of Option[T].
//
// If the don't have a value, we are dealing with a None, which is
// a special singleton instance of Option.
package org.hyperscala.hello
import org.scalatest.WordSpec
import org.scalatest.Matchers
import org.scalatest.BeforeAndAfter
class HelloPageTest extends WordSpec with Matchers with BeforeAndAfter {
"HelloPage" when {
"when rendered" should {
@sebnozzi
sebnozzi / greeting_button.java
Last active August 29, 2015 14:01
Comparing Vaadin/Java and Scaladin
final Button greetButton = new Button("Greet");
greetButton.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
Notification.show("Hi there!");
}
});
@sebnozzi
sebnozzi / CardQuestions.scala
Created March 24, 2014 09:50
Checking on properties of a sequence of cards
object CardQuestions {
case class Card(number: Int, color: String)
val cards = Seq(
Card(5, "red"),
Card(7, "red"),
Card(3, "black"))
// Do the cards all have the same color?
case class GreetingEvent(msg: String)
class Greeter extends Publisher[GreetingEvent] {
def greet(msg:String) = {
println("Firing event")
publish(GreetingEvent(msg))
}
}
class GreetingSubscriber(name: String)
@sebnozzi
sebnozzi / PlayBrowserSpec.scala
Last active November 8, 2016 02:15
How to integrate ScalaTest (FlatSpec) with Play
import org.scalatest.BeforeAndAfterAll
import org.openqa.selenium.WebDriver
import org.openqa.selenium.htmlunit.HtmlUnitDriver
import org.scalatest.FlatSpec
import play.api.test.TestServer
import org.scalatest.Matchers
import play.api.test.Helpers
import org.scalatest.selenium.WebBrowser
import play.api.test.FakeApplication
@sebnozzi
sebnozzi / hangman-frames.scala
Created November 7, 2013 15:04
Frames for a progressing Hangman game. In case we need this for a Dojo.
import scala.collection.mutable.Buffer
val frames = Buffer[String]()
frames += """
> _______
> |/ |
> |
> |
> |
@sebnozzi
sebnozzi / TicTacToe.scala
Last active December 22, 2015 20:39
A TicTacToe implementation. Result of a TDD practice session (solo).
package com.sebnozzi.katas.tictactoe
object TicTacToe {
sealed class Player
case object O extends Player
case object X extends Player
case class Board(state: State = State()) {