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 eu.fakod.neo4jscala.{TypedTraverser, SingletonEmbeddedGraphDatabaseServiceProvider, Neo4jWrapper} | |
| import sys.ShutdownHookThread | |
| trait ProgramBase { | |
| val name: String | |
| } | |
| case class Series(name: String) extends ProgramBase | |
| case class Episode(name: String) extends ProgramBase |
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
| java -ea \ | |
| $SBT_OPTS \ | |
| $JAVA_OPTS \ | |
| -Djava.net.preferIPv4Stack=true \ | |
| -XX:+AggressiveOpts \ | |
| -XX:+UseParNewGC \ | |
| -XX:+UseConcMarkSweepGC \ | |
| -XX:+CMSParallelRemarkEnabled \ | |
| -XX:+CMSClassUnloadingEnabled \ | |
| -XX:ReservedCodeCacheSize=128m \ |
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
| /** | |
| * Semantic Versioning Script for Jenkins | |
| * | |
| * For this to work commit messages must contain one of the characters [!, +, =] | |
| * | |
| * ! is a breaking change and will increment the major version number. | |
| * e.g. 1.1.256 will become 2.0.0 | |
| * | |
| * + is a backward compatible new feature and will increment the minor version number. | |
| * e.g. 1.2.24 will become 1.3.0 |
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 scalaz._ | |
| import Scalaz._ | |
| // Option#getOrElse is ugly | |
| val two = None | 2 | |
| // if else & bool match are ugly | |
| val three = true.fold(t = 3, f = 0) | |
| // nested method calls can become ugly & hard to read |
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 cats.Functor | |
| trait ImplicitInstances { | |
| implicit val OptionInstance: Functor[Option] = new Functor[Option] { | |
| override def map[A, B](fa: Option[A])(f: (A) => B): Option[B] = fa.map(f) | |
| } | |
| } | |
| final class FuncAbs[M[_]] { | |
| def double(s: M[String])(implicit functor : Functor[M]) = functor.map(s)(str => str + str) |
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
| object test extends App { | |
| object Bar extends Dynamic { | |
| def applyDynamic(name: String)(args: Any*) = { | |
| ??? | |
| } | |
| } | |
| val b = Bar.foo("any") |
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 sun.misc.Unsafe | |
| object Foo { | |
| val len: String => Int = {s => s.length} | |
| def bar(s: String) = s.length | |
| } | |
| Foo.len("foo") // 3 | |
| val unsafe = { |
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
| -- an openresty/nginx authenticator that checks bearer tokens with | |
| -- an ID service for use with `access_by_lua_file` nginx directive | |
| local http = require "resty.http" | |
| local hc = http:new() | |
| function abandon_request(status_code, response_body) | |
| ngx.header["WWW-Authenticate"] = "Bearer" | |
| ngx.status = status_code | |
| ngx.say(response_body) |
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
| class InMemoryTTLCache[T <: AnyRef](settings: TTLCacheSettings, zeroFun: String => T) extends Cache[T] { | |
| val underlying = CacheBuilder.newBuilder() | |
| .initialCapacity(30) | |
| .expireAfterWrite(settings.maxAgeInSeconds, TimeUnit.SECONDS) | |
| .build[String, T](new CacheLoader[String, T] { | |
| override def load(key: String): T = zeroFun(key) | |
| }) | |
| override def get(cacheKey: String): Option[T] = Option(underlying.get(cacheKey)) | |
| override def set(cacheKey: String, value: T): Unit = underlying.put(cacheKey, value) | |
| override def delete(cacheKeys: Seq[String]): Unit = cacheKeys.foreach(underlying.invalidate) |
NewerOlder