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 pl.project13.scala.unsigned | |
import com.google.common.primitives.UnsignedInteger | |
import org.scalatest.FlatSpec | |
import org.scalatest.matchers.ShouldMatchers | |
import java.math.BigInteger | |
class UnsignedInt(val intValue: Int) extends AnyVal { | |
import UnsignedInteger._ |
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 pl.project13.scala.workshop.rogue.model | |
import net.liftweb.mongodb.record.{MongoMetaRecord, MongoRecord} | |
import net.liftweb.mongodb.record.field.{MongoListField, IntPk} | |
import net.liftweb.record.field._ | |
import pl.project13.scala.workshop.mongo.MongoConfig.MainMongoIdentifier | |
class Person extends MongoRecord[Person] with IntPk[Person] { | |
override val meta = Person |
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
ktoso@moon /Users/ktoso | |
$ scalac vals_by_types.scala | |
warning: there were 2 deprecation warnings; re-run with -deprecation for details | |
one warning found | |
ktoso@moon /Users/ktoso | |
$ scala Main | |
The combined names are: UserFinder and UserStatusReader |
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
import language.experimental.macros // enable the macros language feature | |
import reflect.macros._ | |
object Alias { | |
def aliasFor[P1, P2, T](delegate: (P1, P2) => T): T = macro alias_impl[T] | |
// ... | |
} |
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
import scalaz._ | |
val failOrBusiness: Validation[Error, Business] = for { | |
business <- doBusiness() | |
_ <- validateBusiness(business) // we can inspect the business here, it's like "case Right(business) =>" | |
} yield business | |
// instead of Either, use monadic Validation |
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 tv.yap.common.util | |
import scala.collection.mutable | |
/** | |
* Enables you to create unique collections of any type, such as Lists, Maps etc, | |
* by simply proving a "key" predicate, so you can filter arbitrary complex objects for your | |
* own definition of uniqueness. | |
*/ | |
trait UniquifyVerb { |
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
java.lang.StackOverflowError | |
at scala.tools.nsc.symtab.Types$SingletonType.baseClasses(Types.scala:1040) | |
at scala.tools.nsc.symtab.Types$Type.findMember(Types.scala:885) | |
at scala.tools.nsc.symtab.Types$Type.member(Types.scala:502) | |
at scala.tools.nsc.typechecker.Typers$Typer.typedIdent$1(Typers.scala:3720) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:4176) | |
at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:4271) | |
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedApply$1$1.apply(Typers.scala:3353) | |
at scala.tools.nsc.typechecker.Typers$Typer$$anonfun$typedApply$1$1.apply(Typers.scala:3353) | |
at scala.tools.nsc.typechecker.Typers$Typer.silent(Typers.scala:624) |
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
import pl.project13.test.lambda.exampleimpl.Adder; | |
import pl.project13.test.lambda.spec.set.ClassSpecSet; | |
import static org.fest.assertions.Assertions.assertThat; | |
import static pl.project13.test.lambda.SpecDSL.describe; | |
public class ClassSpecTest { | |
// this `SpecSet` provides a new instance of the tested class for each `should` | |
ClassSpecSet<Adder> it = describe(Adder.class); |
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
// or even more plain: | |
testCases.foreach((case) -> { | |
// given | |
Object given = case.given; | |
Object expected = case.expected; | |
it.should("return [%s] when applied to [%s]", given, expected, system -> { | |
// when | |
Object got = system.doThing(given); | |
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 tv.yap.common.zip | |
import collection.mutable | |
import java.util.zip.{ZipEntry, ZipFile} | |
import java.io._ | |
import tv.yap.logging.Logging | |
import collection.JavaConversions._ | |
import tv.yap.common.util.{TimedVerb, StreamOperations} | |
import org.apache.commons.io.{IOUtils, FilenameUtils} | |
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream |