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 akka.util.ByteString | |
| import ByteOrder.{BIG_ENDIAN, LITTLE_ENDIAN} | |
| def putLongPart(order: ByteOrder) = ByteString.newBuilder.putLongPart(123, 4)(order).result() | |
| require(putLongPart(BIG_ENDIAN) != putLongPart(LITTLE_ENDIAN)) |
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 cqrs | |
| import scala.reflect.ClassTag | |
| object api { | |
| type Identifier = String | |
| def newIdentifier: Identifier = java.util.UUID.randomUUID().toString | |
| type Revision = Long | |
| val initialRevision: Revision = 0L |
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
| { | |
| "type": "object", | |
| "$schema": "http://json-schema.org/draft-03/schema", | |
| "id": "#", | |
| "title":"Child", | |
| "properties": { | |
| "name": { | |
| "type": "string", | |
| "id": "name", | |
| "required": true |
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 EndlessIterator[T](iterable: Iterable[T]) extends Iterator[T] { | |
| assert(iterable.nonEmpty, "iterable is empty") | |
| private var _iterator = iterable.iterator | |
| private def iterator = | |
| if (_iterator.hasNext) _iterator | |
| else { | |
| _iterator = iterable.iterator | |
| _iterator |
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
| /** | |
| * @author Yaroslav Klymko | |
| */ | |
| object Primes { | |
| val naturals = { | |
| def loop(n: Long): Stream[Long] = n #:: loop(n + 1) | |
| loop(1) | |
| } | |
| val primes: Stream[Long] = { |
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 blog { | |
| object events { | |
| sealed trait PostEvent | |
| case class PostCreated(title: String) extends PostEvent | |
| case class PostRenamed(id: Long, name: String) extends PostEvent | |
| class EventStream() { |
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 ConnectorTypes extends Table[(String, ConnectorType.Value)]("connector_type") { | |
| implicit val ConnectorTypeMapper = new EnumMappedTypeMapper(ConnectorType) | |
| def chargerId = column[String]("charger_id") | |
| def connectorType = column[ConnectorType.Value]("connector_type") | |
| def * = chargerId ~ connectorType | |
| def ux = index("ux_connector_type", chargerId ~ connectorType, unique = true) | |
| def fkCharger = foreignKey("fk_connector_types_charger", chargerId, Charger)(_.id) |
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
| val func = (req: HttpServletRequest) => { | |
| // ASYNC SCOPE | |
| // heavy scope, actually this is a place async is needed for | |
| // async request might expire | |
| (res: HttpServletResponse) => { | |
| // RESPONSE SCOPE | |
| // lite scope for putting collected data to response, called if not expired | |
| (result: Boolean) => { | |
| // CALLBACK SCOPE | |
| // called to notify whether response sent successfully |
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
| public class JavaClass { | |
| public String toString() { | |
| return "" | |
| } | |
| public boolean getBool() { | |
| return false | |
| } | |
| } |
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 com.thenewmotion.chargenetwork.server.services.proto | |
| import akka.actor._ | |
| import akka.actor.Actor._ | |
| import akka.routing._ | |
| import akka.event.EventHandler | |
| /** | |
| * @author Yaroslav Klymko | |
| */ |