Skip to content

Instantly share code, notes, and snippets.

View eugener's full-sized avatar

Eugene Ryzhikov eugener

View GitHub Profile
@eugener
eugener / OptionCheatsheet.scala
Created December 3, 2012 03:00 — forked from devnulled/OptionCheatsheet.scala
Scala Option Cheatsheet
// flatMap
// This code is equivalent to:
// option.flatMap(foo(_))
option match {
case None => None
case Some(x) => foo(x)
}
// flatten
// This code is equivalent to:
@eugener
eugener / Spring AOP Configuration to use Spring annotations in Scala
Last active August 28, 2018 00:31
Spring AOP Configuration to use Spring annotations in Scala
<!--
Following switches Spring proxy targeting to classes vs interfaces as default
and allows for using Spring annotations (scanning etc) in Scala
-->
<aop:config proxy-target-class="true"/>
@eugener
eugener / gist:623213
Created October 13, 2010 01:00
Equivalent of C# using keyword. Automatically closes any resource which has a close method. Capable of returning a value
object Controls {
type CloseableResource = { def close() }
/**
* Equivalent of C# using keyword. Automatically closes any resource which has a close method.
* Capable of returning a value
* @param T resource which has a close() method
* @param M result
*/