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
#!/usr/bin/env ruby | |
# Load in the PrimalAccess class | |
require './PrimalAccess.rb' | |
require 'rubygems' | |
# We require this particular gem | |
# | |
# To install it: | |
# gem install json |
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
#!/usr/bin/env ruby | |
# We need to use some ruby gems | |
require 'rubygems' | |
# We require the httparty gem | |
# | |
# To install it: | |
# gem install httparty | |
# |
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
% node -v | |
v0.6.12 | |
% node | |
> [1,2,3,11,22].sort() | |
[ 1, | |
11, | |
2, | |
22, | |
3 ] | |
> console.log("That's just awesome") |
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
#!/bin/bash | |
command="$1" | |
shift | |
fileSpec="$@" | |
sentinel=/tmp/t.$$ | |
touch -t197001010000 $sentinel | |
while : | |
do |
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
// Spawn your futures | |
val fs = (1 to 100).map { i => | |
Future { Thread.sleep(i); i } | |
} | |
// Wrap all of the work up into a single | |
// Future | |
val f = Future.sequence(fs) | |
// Wait on it forever - i.e. until it's done |
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.actor.{Actor, ActorRef} | |
class Master(surrogate: ActorRef) extends Actor { | |
import Terminator._ | |
// Askf for the kids | |
override def preStart() { | |
surrogate ! GetChildren(self) | |
} |
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
// Downloading could take a while :) | |
implicit val askTimeout = Timeout(5 minutes) | |
// Some list of URLs we want to download | |
val urls = List(url1, ulr2, url3, ..., urlN) | |
// The Master | |
val m = system.actorOf(Props[Master], "master") | |
// Assume Workers are now present |
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 WorkerSpec extends TestKit(ActorSystem("WorkerSpec")) | |
with ImplicitSender | |
with WordSpec | |
with BeforeAndAfterAll | |
with MustMatchers { | |
override def afterAll() { | |
system.shutdown() | |
} |
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 TestWorker(masterLocation: ActorPath) extends Worker(masterLocation) { | |
// We'll use the current dispatcher for the execution context. | |
// You can use whatever you want. | |
implicit val ec = context.dispatcher | |
def doWork(workSender: ActorRef, msg: Any): Unit = { | |
Future { | |
workSender ! msg | |
WorkComplete("done") | |
} pipeTo self |
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
abstract class Worker(masterLocation: ActorPath) | |
extends Actor with ActorLogging { | |
import MasterWorkerProtocol._ | |
// We need to know where the master is | |
val master = context.actorFor(masterLocation) | |
// This is how our derivations will interact with us. It | |
// allows dervations to complete work asynchronously | |
case class WorkComplete(result: Any) |