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
for{ | |
u <- UserStore.getFull(requesterRef) | |
// .map{usr=> if(false) notAuthorizedC("x") else usr} | |
.map{usr=>UserRefs.ById(usr.id)} | |
// _ <- if (u.status == Statuses.Active) success | |
// else notAuthorizedC("Unable to retrieve the permissions for post: [%s] and requester: [%s]".format(postRef, requesterRef)) | |
r <- postRef match { | |
case ref:PostRefs.ById => | |
getPermitedOperationsForPostsById(Set(ref), u) | |
.map[ReaderCtx, Set[Operation]]{r=> r(ref)} |
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 versioning | |
// version 1 defined 2 actions here | |
trait V1 { | |
val SetOptOut = EmailPreferenceActions.SetOptOut | |
val GetSailthruEmail = EmailPreferenceActions.GetSailthruEmail | |
} | |
object V1Api extends V1 | |
// version 2 need to replace SetOptOut with SetOptOutImproved |
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
" | |
name, com.patch.kickass.actions.EmailPreferenceActions$SetOptOut | |
parameters: UserRef | |
param values: 1 | |
" | |
" | |
output: | |
action name, param types, return type, case class, implementation(needed to invoke the action) | |
" |
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
def test = { | |
lazy val x = { | |
println(s"lazy compute called") | |
Thread.sleep(1000*30) | |
1 | |
} | |
x | |
} | |
def mRun = { | |
import scala.concurrent.ExecutionContext.Implicits.global |
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 Battle { | |
import scala.util.Try | |
type cellType = String | |
type Result = Try[Set[Boat]] | |
val D = "D" | |
val W = " " | |
trait Boat { | |
def start: Point |
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 Transactions { | |
class Transactor(session: Session) extends BaseActor { | |
/** | |
* To be defined in child actors | |
*/ | |
override def handleMessage: Receive = ??? | |
def commit: Future[Unit] = ??? | |
def rollback:Future[Unit] = ??? | |
def execute[T](f: Session => T): Future[T] = ??? |
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.concurrent._ | |
import scala.concurrent.duration._ | |
object TimedFuture { | |
def apply[T](body: ⇒ T)(timeout: Duration = 10.seconds)(implicit executor: ExecutionContext): Future[T] = { | |
val start = System.currentTimeMillis() | |
Future { | |
val now = System.currentTimeMillis() | |
if (now - start > timeout.toMillis) throw new Exception(s"timed out after $timeout") | |
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
def fib(n: Int): (Int, Int) = if (n==1) (1,1) else { | |
val (m1,m2) = fib(n-1) | |
(m2, m1+m2) | |
} |