This file contains 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 my.gists.test; | |
import java.nio.ByteBuffer; | |
import java.nio.ByteOrder; | |
import junit.framework.Assert; | |
import org.junit.Test; | |
import com.mongodb.BasicDBObject; |
This file contains 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
function FindProxyForURL(url, host) { | |
var lhost = host.toLowerCase(); | |
var ip = myIpAddressEx(); | |
// exclude localhost and some specific range on company network (123.45.*) | |
if ((lhost == "localhost") | |
|| (shExpMatch(lhost, "localhost.*")) | |
|| (lhost == "127.0.0.1") | |
|| shExpMatch(lhost, "123.45.*")) { | |
return "DIRECT"; | |
} |
This file contains 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 unit.akka | |
import org.scalatest.matchers.ShouldMatchers | |
import org.scalatest.{WordSpec, BeforeAndAfterAll} | |
import akka.actor.Actor._ | |
import akka.util.duration._ | |
import akka.util.TestKit | |
import java.util.concurrent.TimeUnit | |
import akka.actor.{ActorRef, Actor} | |
import util.Random |
This file contains 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 unit.akka | |
import org.junit.Test | |
import akka.remote.netty.NettyRemoteSupport | |
import akka.actor.Actor | |
import akka.event.slf4j.Logging | |
import org.scalatest.junit.{ShouldMatchersForJUnit, JUnitSuite} | |
import org.scalatest.BeforeAndAfterAll | |
import akka.actor.Actor._ | |
import java.nio.channels.ClosedChannelException |
This file contains 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.actor.Actor | |
trait ReplyAfterProcessing extends Actor { | |
abstract override def receive = { | |
super.receive andThen { | |
case msg => self.reply_?(msg) | |
} | |
} | |
} |
This file contains 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 SomeSpec extends WordSpec { | |
"A oneway actor" should { | |
"Tell me when it's finished "in { | |
val testActor = Actor.actorOf(new SomeActor() with ReplyAfterProcessing) | |
var reply = testActor !! (message, 1000) | |
if(reply.isEmpty) fail("some message") | |
} | |
} | |
} |
This file contains 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 Node { actor:Actor => | |
def send(actorRef:ActorRef, m:Any) { actorRef.tell(m) } | |
def reply(m:Any) { sender ! m } | |
def forward(actorRef:ActorRef, m:Any) { actorRef.forward(m) } | |
def actorOf(props:Props):ActorRef = actor.context.actorOf(props) | |
def actorFor(actorPath:ActorPath):ActorRef = actor.context.actorFor(actorPath) | |
} |
This file contains 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 WebNode[Data,Request] extends Actor with Node { | |
// pathways coming into the node | |
protected val in = mutable.Set[ActorRef]() | |
// pathways going out of the node | |
protected val out = mutable.Set[ActorRef]() | |
// used to only handle a request once that travels | |
// through the web | |
protected var lastId:Option[UUID] = None |
This file contains 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 wrappedReceive:Receive = { | |
case m:Any if ! m.isInstanceOf[(Request,Spider)] => | |
recordInput(sender) | |
before(m) | |
super.receive(m) | |
after(m) | |
} |
This file contains 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 handleRequest:Receive = { | |
case (req:Request, spider @ Spider(ref,WebTrail(collected, uuid))) if !lastId.exists(_ == uuid) => | |
lastId = Some(uuid) | |
collect(req).map { data => | |
sendSpiders(ref, data, (req,spider), collected) | |
} | |
} |
OlderNewer