Skip to content

Instantly share code, notes, and snippets.

View t3hnar's full-sized avatar
🎯
Focusing

Yaroslav Klymko t3hnar

🎯
Focusing
View GitHub Profile
package scala
/**
* @author Yaroslav Klymko
*/
object StringOption {
def apply(s: String): Option[String] = s match {
case null | "" => None
case _ => Some(s)
}
@t3hnar
t3hnar / BasicAuthentication.scala
Created October 24, 2011 13:13
BasicAuthentication in Akka
trait BasicAuthentication extends Loggable{
self: Actor =>
protected def authorize(rec: Receive): Receive = if (Props.testMode) rec
else new Receive {
def apply(v: Any) {
v match {
case method: RequestMethod => method.request.getHeader("Authorization") match {
case BasicAuth(login, password) if (authorized_?(login, password)) =>
@t3hnar
t3hnar / pom.xml
Created October 7, 2011 10:01
run.mode=test in maven
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.8</version>
<configuration>
<systemProperties>
<property>
<name>run.mode</name>
@t3hnar
t3hnar / Entity.scala
Created October 5, 2011 12:32
Squeryl Entity
package org.squeryl
import annotations.Transient
import java.lang.reflect.Field
/**
* @author Yaroslav Klymko
*/
trait HasValues {
protected def values: List[Any]