Skip to content

Instantly share code, notes, and snippets.

@yawnt
yawnt / monad_error.scala
Created August 10, 2017 17:55 — forked from etorreborre/monad_error.scala
Why is MonadError helpful?
/**
* Let's say I can read things from a "Store"
*/
trait Store[F] {
def read(path: Path): F[String]
}
/**
* Now I want to read more specific things, like a Configuration
*
import static java.lang.System.out;
public class InterThreadLatency
{
private static final int REPETITIONS = 100 * 1000 * 1000;
private static volatile int ping = -1;
private static volatile int pong = -1;
public static void main(final String[] args)
package kx; //jar cf c.jar kx/*.class
import java.net.*;
import javax.net.ssl.*;
import java.io.*;
import java.sql.*;
import java.lang.reflect.Array;
import java.text.*;
import java.util.UUID;
import java.util.Calendar;
import java.util.TimeZone;
-module(hello_world).
-export([start/0,pong/0]).
pong() ->
receive
stop ->
io:format("Pong finished...~n",[]);
{PingId,ping} ->
io:format("Ping~n",[]),
PingId ! {self(),pong},
import java.util.concurrent.ConcurrentLinkedQueue
/*
* ConcurrentLinkedQueue is used in `Mailbox.scala`
* to hold incoming messages for actors
*/
case class Envelope(a: Int)
class MessageQueue {
{ emptyList, singletonList }
iterator
{ Iterator ⇒ JIterator }
AtomicBoolean
AtomicBoolean
ConcurrentLinkedQueue
AtomicInteger
Comparator
Pattern
TimeUnit
┌[yawnt@xantico] [/dev/pts/2] [git|v2.3.9]
└[~/Code/akka]> fgrep -ri "java.lang.reflect" akka-actor | cut -d':' -f2
import java.lang.reflect.{ Array ⇒ JArray }
import java.lang.reflect.Constructor
import java.lang.reflect.Type
import java.lang.reflect.ParameterizedType
import java.lang.reflect.InvocationTargetException
@tailrec def clearFirst(fields
import java.lang.reflect.Constructor
import java.lang.reflect.Modifier

This histogram shows the distribution of GitHub Gist API response times (in milliseconds) for a sample of 10,000 requests as observed by bl.ocks.org.

The distribution roughly follows a log-normal distribution, which is unsurprising for a complex process that has multiple independently-random sources of delay. The mode response time was in the range 120-140ms, while the median response time was 206ms. The middle 80% of requests were in the range 114-527ms. About 11% of requests took longer than 500ms, and 5% of requests took longer than one second. (The rightmost bin in the histogram includes these long requests.)

Since API endpoints vary dramatically in their computational cost, the distribution of response times is likely multimodal. In this dataset, 96% of requests were for a single gist (/gists/42), while the remaining 4% of requests were to list a user’s gist (/users/fred/gists). By separating the API r

val refdMessage: AnyRef =
message match {
case b: jl.Boolean => AkkaWorker.Boxed(Boolean.unbox(b))
case b: jl.Byte => AkkaWorker.Boxed(Byte.unbox(b))
case c: jl.Character => AkkaWorker.Boxed(Char.unbox(c))
case s: jl.Short => AkkaWorker.Boxed(Char.unbox(s))
case i: jl.Integer => AkkaWorker.Boxed(Int.unbox(i))
case l: jl.Long => AkkaWorker.Boxed(Long.unbox(l))
case f: jl.Float => AkkaWorker.Boxed(Float.unbox(f))
case d: jl.Double => AkkaWorker.Boxed(Double.unbox(d))