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 scalaz.example | |
object Reader extends App { | |
/** | |
* Manual propagation of the environment (in the example, `contextRoot`.) | |
*/ | |
object Config0 { | |
def fragment1(contextRoot: String) = <a href={contextRoot + "/foo"}>foo</a> |
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
// ©2012 Viktor Klang | |
package akka.klang | |
import akka.dispatch.{ DispatcherPrerequisites, ExecutorServiceFactory, ExecutorServiceConfigurator } | |
import com.typesafe.config.Config | |
import java.util.concurrent.{ ExecutorService, AbstractExecutorService, ThreadFactory, TimeUnit } | |
import java.util.Collections | |
import javax.swing.SwingUtilities |
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
// © 2012 Viktor Klang | |
import akka.dispatch.ExecutionContext | |
import javax.swing.SwingUtilities | |
import java.util.concurrent.Executor | |
// | |
object SwingExecutionContext { | |
implicit val swingExecutionContext: ExecutionContext = ExecutionContext.fromExecutor(new Executor { | |
def execute(command: Runnable): Unit = SwingUtilities invokeLater command |
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 | |
import akka.actor.ActorSystem | |
import akka.agent.Agent | |
import com.typesafe.config.ConfigFactory | |
import akka.event.Logging | |
import akka.actor.Props | |
import kafka.utils.Utils | |
import java.nio.ByteBuffer |
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
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |
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 se.fishtank; | |
import java.net.URI; | |
import java.util.Map; | |
import ch.qos.logback.classic.spi.ILoggingEvent; | |
import ch.qos.logback.core.sift.Discriminator; | |
import ch.qos.logback.core.spi.ContextAwareBase; | |
public class AkkaSourceDiscriminator extends ContextAwareBase implements Discriminator<ILoggingEvent> { |
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
case class State[S, +A](run: S ⇒ (A, S)) { | |
def map[B](f: A => B): State[S, B] = | |
State(s ⇒ { | |
val (a, t) = run(s) | |
(f(a), t) | |
}) | |
def flatMap[B](f: A ⇒ State[S, B]): State[S, B] = | |
State(s ⇒ { | |
val (a, t) = run(s) |
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
Please help compile a list of all Scala-related IRC rooms. | |
All of these channels are on Freenode. | |
#akka | concurrency & distribution framework | |
#argonaut | json library | |
#fp-in-scala | the book Functional Programming in Scala | |
#geotrellis | geoprocessing library | |
#indyscala | regional scala group | |
#json4s | json library |
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
/** | |
* "Select" off the first future to be satisfied. Return this as a | |
* result, with the remainder of the Futures as a sequence. | |
* | |
* @param fs a scala.collection.Seq | |
*/ | |
def select[A](fs: Seq[Future[A]])(implicit ec: ExecutionContext): Future[(Try[A], Seq[Future[A]])] = { | |
@tailrec | |
def stripe(p: Promise[(Try[A], Seq[Future[A]])], | |
heads: Seq[Future[A]], |
OlderNewer