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 A { | |
val initVal: String = "aa" | |
def useInitVal { println(initVal) } | |
useInitVal | |
} | |
class B extends A { | |
override val initVal = "bb" | |
} |
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 OptionalEmbeddedField[V](override val mongoFieldName: String, val g: T => Option[V], val p: Option[(T,Option[V]) => Unit]) | |
extends MongoScalar[V] with EmbeddedContent[V] with FieldModifyOp[V] with Optional[V] { | |
self: MongoField[V] with ObjectIn[V, QueryType] => | |
override val rep = parent.Represented.byOption(g, p) | |
override def canEqual(other: Any): Boolean = other.isInstanceOf[OptionalEmbeddedField[_]] | |
} | |
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 reflect.{Manifest, ClassManifest} | |
import org.scalatest.matchers.{Matcher,MatchResult} | |
trait CustomMatchers { | |
/** | |
* Based on http://daily-scala.blogspot.com/2010/01/overcoming-type-erasure-in-matching-1.html | |
*/ | |
class ConformMatcher[A](implicit m: Manifest[A]) extends Matcher[AnyRef] { | |
override def apply(obj: AnyRef) = { | |
def deepConformance[B,C](desired: Manifest[B], actual: Manifest[C]): Boolean = { |
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
trait PostStart { actor: Actor => | |
def postStart: Unit | |
override def preStart { | |
super.preStart | |
actor.become { | |
case "PostStart" => try { postStart } finally { actor.unbecome } | |
} | |
actor.self ! "PostStart" | |
} |
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.osinka.i18n | |
import java.util.{Locale,ResourceBundle} | |
import collection.JavaConversions._ | |
import net.liftweb.common.Box._ | |
import net.liftweb.util.{BundleBuilder,PCDataXmlParser} | |
/** | |
* ResourceBundle.Control implementation for Liftweb resources | |
* |
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 scala.io._ | |
import collection.JavaConversions._ | |
import com.mongodb._ | |
import com.osinka.subset._ | |
import SmartValues._ | |
// we want to store it in MongoDB. ok.. | |
val mongo = new Mongo("192.168.0.164") | |
val db = mongo getDB "test" | |
val coll = db getCollection "timeline" |
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.osinka.subset.examples | |
/** | |
* Data model from this MongoDB doc page: | |
* http://www.mongodb.org/display/DOCS/Updating#Updating-The%24positionaloperator | |
*/ | |
// Use :paste mode | |
import com.mongodb._ | |
import com.osinka.subset._ |
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
<a href="http://www.osinka.ru/?utm_source=people&utm_medium=button&utm_content=osinka_banner_200x150_1&utm_campaign=110125" | |
title="Осинка.ру - все о моде, шитье и рукоделии"><img | |
src="http://www.osinka.ru/info/banners/osinka_banner_200x150_1.png" | |
width="200" | |
height="150" | |
border="0"></a> |
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 des = scala.concurrent.ExecutionContext.global | |
import scala.concurrent._ | |
import duration._ | |
def ct = Thread.currentThread.getName | |
val n = Runtime.getRuntime.availableProcessors | |
def hogThread(sec:Int) = future { |
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
'use strict'; | |
function* readLine(stream) { | |
const EOL = require('os').EOL; | |
const Fs = require('fs'); | |
const buf = new Buffer(1024); | |
stream.resume(); | |
stream.setEncoding('ascii'); |