Skip to content

Instantly share code, notes, and snippets.

View izmailoff's full-sized avatar
🎯
Focusing

Aleksey Izmailov izmailoff

🎯
Focusing
View GitHub Profile
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])
@davidallsopp
davidallsopp / Shrinking.scala
Last active January 30, 2024 13:25
Solutions to the ScalaCheck problem that shrinking failing values may generate invalid values, because the constraints of the generator are not respected. This is for using ScalaCheck from within ScalaTest.
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
@amferraz
amferraz / Main.java
Created May 8, 2014 12:09
A sample app of converting a file to html with Apache Tika
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;
@visenger
visenger / install_scala_sbt.sh
Last active January 31, 2023 19:10
Scala and sbt installation on ubuntu 12.04
#!/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
@leon
leon / compile.scala
Created March 29, 2012 06:33
Compile scala programatically
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")
})
@jrudolph
jrudolph / TowersOfHanoi.scala
Created February 19, 2009 13:51
Scala-Metaprogramming: Towers of Hanoi
/*
* 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