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
object cliffHanger extends App{ | |
val man = List(" 0\n","-","-","-\n"," |\n"," /","\\\n") | |
def drawState(tries:Int,word:String,letters:List[Char]) = { | |
println("\n\n\n") | |
println(man.dropRight(tries).mkString) | |
word.toList.foreach(c => if (letters.exists(c == _)) print(c) else print("_")) | |
println() | |
} |
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
Show hidden characters
{ | |
"cmd": ["sbt-no-color compile"], | |
"file_regex": "^\\[error\\] ([.a-zA-Z0-9/-]+[.]scala):([0-9]+):", | |
"selector": "source.scala", | |
"working_dir": "${project_path:${folder}}", | |
"shell": "true" | |
} |
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
case class Config(name: String="none") | |
def methodNeedingAConfig(implicit config: Config = Config()) = config.name | |
// by default there is no config | |
methodNeedingAConfig === "none" | |
// just add one in the current scope | |
implicit val myConfig = Config("some") |
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
apply plugin: 'groovy' | |
apply plugin: 'jetty' | |
apply plugin: 'eclipse' | |
apply from: 'http://resolver/gradle-scripts/repo-settings/internal-maven.gradle' | |
dependencies { | |
groovy 'org.codehaus.groovy:groovy:1.7.10' | |
compile 'org.springframework:spring-webmvc:3.0.5.RELEASE' |
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 Calc extends PackratParsers { | |
type Elem = Char | |
val vars = mutable.Map[Char,Int]() | |
def parse(input:CharSequence) = doIt(new PackratReader(new CharSequenceReader(input))) | |
val spaces: Parser[Seq[Char]] = elem("Whitespace", _.isWhitespace)* | |
val digit: Parser[Char] = elem("Digit", _.isDigit) | |
val letter: Parser[Char] = elem("Letter", _.isLetter) |
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
package com.banksimple.util | |
private[util] final class Effectful[T](val origin: T) { | |
/** | |
* A special case of doto, andAlso is useful for | |
* quick logging or output tasks. Similar in use | |
* to doto, but only takes one function. | |
* */ | |
def andAlso(x: T => Unit): T = { x(origin) ; origin } |
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
import scalaz._ | |
import Scalaz._ | |
import scalaz.concurrent._ | |
/** | |
* Result type of concurrent functions that may fail. | |
*/ | |
case class PromiseEither[A, B](value: Promise[Either[A, B]]) extends NewType[Promise[Either[A, B]]] | |
/** |
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
package sample | |
import akka.actor._ | |
import akka.http._ | |
class SampleService extends Actor with Endpoint | |
{ | |
self.dispatcher = Endpoint.Dispatcher; |
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 MiniSTM[T <: AnyRef](initialValue: T) { | |
private val value = new AtomicReference[T](initialValue) | |
def apply(fun: T => T) { | |
@tailrec def update(expect: T): Unit = | |
if ( !value.compareAndSet(expect, fun(expect)) ) update(value.get) | |
update(value.get) | |
} | |
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
import java.util.concurrent.atomic.AtomicInteger | |
import akka.actor._ | |
import akka.actor.Actor._ | |
import akka.dispatch.Future | |
case class Reduce(val size: Int) | |
case class MappingDetail[T](val item: T, val reducer: ActorRef) | |
class MapperActor[T, U](val mapping: (T) => U) extends Actor { |