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 demo | |
object ScalaDsl { | |
/* | |
* Defining a simplistic model for the web app DSL | |
*/ | |
case class HttpRequest(path: String, headers: Map[String, String], body: Option[String]) |
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 org.scalatest._ | |
import prop._ | |
import org.scalacheck.Arbitrary._ | |
import org.scalacheck.Gen | |
/** | |
* Solutions to the ScalaCheck problem that shrinking failing values may generate | |
* invalid values, because the constraints of the generator are not respected. | |
* | |
* See also http://stackoverflow.com/questions/20037900/scalacheck-wont-properly-report-the-failing-case |
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 jusbrasil.test_tika; | |
import java.io.ByteArrayInputStream; | |
import java.io.ByteArrayOutputStream; | |
import java.io.File; | |
import java.io.IOException; | |
import javax.xml.transform.OutputKeys; | |
import javax.xml.transform.TransformerConfigurationException; | |
import javax.xml.transform.sax.SAXTransformerFactory; |
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
#!/bin/sh | |
# one way (older scala version will be installed) | |
# sudo apt-get install scala | |
#2nd way | |
sudo apt-get remove scala-library scala | |
wget http://www.scala-lang.org/files/archive/scala-2.11.4.deb | |
sudo dpkg -i scala-2.11.4.deb | |
sudo apt-get update |
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 scala.tools.nsc.{Interpreter,Settings} | |
var i = new Interpreter(new Settings(str => println(str))) | |
var res = Array[Any](null) | |
i.beQuietDuring({ | |
i.bind("result", "Array[Any]", res) | |
i.interpret("class Fred {def foo = 3}") | |
i.interpret("result(0) = new Fred") | |
}) |
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
/* | |
* This is the Towers of Hanoi example from the prolog tutorial [1] | |
* converted into Scala, using implicits to unfold the algorithm at | |
* compile-time. | |
* | |
* [1] http://www.csupomona.edu/~jrfisher/www/prolog_tutorial/2_3.html | |
*/ | |
object TowersOfHanoi { | |
import scala.reflect.Manifest |
NewerOlder