Skip to content

Instantly share code, notes, and snippets.

View jmcardon's full-sized avatar
💭
Why on earth do we need statuses

Jose C jmcardon

💭
Why on earth do we need statuses
View GitHub Profile
@jmcardon
jmcardon / TestMultipartFileUpload.scala
Created March 8, 2017 04:39 — forked from jrudolph/TestMultipartFileUpload.scala
akka-http Multipart file-upload client + server example
package akka.http.scaladsl
import java.io.File
import akka.http.scaladsl.unmarshalling.Unmarshal
import akka.util.ByteString
import scala.concurrent.duration._
import akka.actor.ActorSystem
@jmcardon
jmcardon / Free conversation.md
Created August 8, 2017 20:52 — forked from SystemFw/Free conversation.md
Explaining some of the mechanics of interpretation of Free programs

Balaji Sivaraman @balajisivaraman_twitter

Hi all, I need some help understanding a piece of Doobie code from the examples. It is the StreamingCopy one: (https://github.com/tpolecat/doobie/blob/series/0.4.x/yax/example/src/main/scala/example/StreamingCopy.scala). I am using a modified version of the fuseMap2 example from that file. Here’s how I’ve modified it for my requirements:

  def fuseMap[F[_]: Catchable: Monad, A, B](
      source: Process[ConnectionIO, A],
      sink: Vector[A] => ConnectionIO[B],
      delete: ConnectionIO[Unit]
  )(
 sourceXA: Transactor[F],
@jmcardon
jmcardon / HttpPipelineFactory.java
Created February 1, 2018 08:46 — forked from sigbjod/HttpPipelineFactory.java
My implementation of a Netty server handling HTTP requests
public class HttpPipelineFactory implements ChannelPipelineFactory {
private final ExecutionHandler executionHandler;
private final ProductDaoImpl productDao;
public HttpPipelineFactory(ProductDaoImpl productDao,
OrderedMemoryAwareThreadPoolExecutor eventExecutor) {
this.productDao = productDao;
this.executionHandler = new ExecutionHandler(eventExecutor);
}
@jmcardon
jmcardon / HttpPipelineFactory.java
Created February 1, 2018 08:46 — forked from sigbjod/HttpPipelineFactory.java
My implementation of a Netty server handling HTTP requests
public class HttpPipelineFactory implements ChannelPipelineFactory {
private final ExecutionHandler executionHandler;
private final ProductDaoImpl productDao;
public HttpPipelineFactory(ProductDaoImpl productDao,
OrderedMemoryAwareThreadPoolExecutor eventExecutor) {
this.productDao = productDao;
this.executionHandler = new ExecutionHandler(eventExecutor);
}
@jmcardon
jmcardon / HotSpot JVM intrinsics
Created April 14, 2018 01:51 — forked from apangin/HotSpot JVM intrinsics
HotSpot JVM intrinsics
_hashCode java/lang/Object.hashCode()I
_getClass java/lang/Object.getClass()Ljava/lang/Class;
_clone java/lang/Object.clone()Ljava/lang/Object;
_dabs java/lang/Math.abs(D)D
_dsin java/lang/Math.sin(D)D
_dcos java/lang/Math.cos(D)D
_dtan java/lang/Math.tan(D)D
_datan2 java/lang/Math.atan2(DD)D
_dsqrt java/lang/Math.sqrt(D)D
_dlog java/lang/Math.log(D)D

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.