Skip to content

Instantly share code, notes, and snippets.

View ovstetun's full-sized avatar

Trond Marius Øvstetun ovstetun

View GitHub Profile
@ovstetun
ovstetun / ResId.scala
Last active March 31, 2016 16:33
binding trait instance
trait ResId {
def toASCIIString: String
}
object ResId {
def apply(uri: String): ResId = new StringUri(uri)
def apply(uri: URI): ResId = new StringUri(uri.toString)
private def validated(uri: String): String = URI.create(uri).toString
case class StringUri(value: String) extends ResId {
override val toASCIIString: String = validated(value)
@ovstetun
ovstetun / Bruk.java
Last active September 21, 2016 12:45
exceptionwrapping
Runtime.getRuntime().addShutdownHook(new Thread(() -> consumer(server::close)));
File tempFile = propagate(() -> File.createTempFile("util-tests", ".tmp"));
@ovstetun
ovstetun / Main.scala
Last active December 22, 2015 14:18 — forked from xuwei-k/Main.scala
/**
* https://github.com/json4s/json4s/issues/39
*
* Validation Monad instance removed from Scalaz7.
* https://github.com/scalaz/scalaz/blob/v6.0.4/core/src/main/scala/scalaz/Validation.scala#L133-L147
*
* need explicitly convert to `scalaz.\/` (aka disjunction) if you want use the `Kleisli` composition
*/
object Main extends App {
package test;
@Controller
@RequestMapping("/person/{id}/overview")
public class MyController {
...
@ModelAttribute
public Person getPerson(@PathVariable final long id, final HttpServletRequest request) {
final Person soknad = personRepository.fetch(id);
return soknad;