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
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import akka.http.scaladsl.server.{ HttpApp, Route }
import spray.json.DefaultJsonProtocol
case class SomeFooData(foo: String)
object SomeFooDataSupport extends DefaultJsonProtocol with SprayJsonSupport {
implicit val PortofolioFormats = jsonFormat1(SomeFooData)
}
sealed trait PitStuff
case class Rise(start: Int, end: Int) extends PitStuff
case class Fall(start: Int, end: Int) extends PitStuff
object kek extends App {
def checkMax(current: Int, rise: Option[Rise], fall: Option[Fall], list: List[Int], maxPit: Int): Int ={
list match {
case Nil =>
if(rise.isDefined && fall.isDefined)
import scala.concurrent.duration._
object Hi extends App {
case class A[K](k: K)
/**
* Settings for producers. See `akka.kafka.producer` section in
* reference.conf. Note that the [[ProducerSettings companion]] object provides
* `apply` and `create` functions for convenient construction of the settings, together with
@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],
for fs2 chunk size: 4096
sbt:stream-benchmarks> jmh:run -i 10 -wi 10 -f1 -t1 .*LargeStream*
[info] Running (fork) org.openjdk.jmh.Main -i 10 -wi 10 -f1 -t1 .*LargeStream*
[info] # JMH version: 1.19
[info] # VM version: JDK 1.8.0_144, VM 25.144-b01
[info] # VM invoker: /usr/lib/jvm/java-8-oracle/jre/bin/java
[info] # VM options: <none>
[info] # Warmup: 10 iterations, 1 s each
[info] # Measurement: 10 iterations, 1 s each
package io.github.jmcardon.tseclogin
import tsec.common._
import tsec.mac.core.MAC
import tsec.mac.imports._
import java.util.UUID
import java.time._
import cats.effect.IO
//Using cats-effect 0.5.0 and tsec 0.0.1-M6
@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);
}
/** Method in question:
* https://github.com/circe/circe/blob/master/modules/core/shared/src/main/scala/io/circe/JsonObject.scala#L260
*/
object GucciMane extends App {
println(classOf[io.circe.JsonObject$].getMethod("fromLinkedHashMap")) //Throws NoSuchMethodException
}