Skip to content

Instantly share code, notes, and snippets.

View shankarshastri's full-sized avatar
💻
Think -> Code -> Solve

ShankarShastri shankarshastri

💻
Think -> Code -> Solve
View GitHub Profile
@shankarshastri
shankarshastri / AkkaHttpChunked.scala
Created May 20, 2017 17:35
AkkHttpChunked.scala
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.marshalling.Marshaller
import akka.http.scaladsl.marshalling.ToResponseMarshallable.apply
import akka.http.scaladsl.marshalling.ToResponseMarshaller
import akka.http.scaladsl.model.{ ContentTypes, HttpEntity }
import akka.http.scaladsl.model.HttpEntity.ChunkStreamPart
import akka.http.scaladsl.model.HttpResponse
import akka.http.scaladsl.server.Directive.addByNameNullaryApply
import akka.NotUsed
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.common.{ EntityStreamingSupport, JsonEntityStreamingSupport }
import akka.http.scaladsl.model.{ HttpEntity, StatusCodes, _ }
import akka.http.scaladsl.server.Directives._
import akka.stream.ActorMaterializer
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport._
import akka.http.scaladsl.marshalling.{ Marshaller, ToEntityMarshaller, ToResponseMarshaller }
import akka.http.scaladsl.model.TransferEncodings.gzip
import akka.actor.{Actor, ActorRef, ActorSystem, CoordinatedShutdown, Props}
import scala.concurrent.Future
import scala.concurrent.ExecutionContext.Implicits.global
import scala.math.BigInt
import scala.util.Success
import akka.pattern._
import akka.util.Timeout
import scala.concurrent.duration._
@shankarshastri
shankarshastri / AWSArchNotes.txt
Last active November 10, 2018 14:02
AWS Solution Arch Notes
IAM
IAM => Identity And Access Management
It contains Users, Groups, Roles
Users => Normal Person As An User.
Groups => Based On Functions Designate it to particular groups. Example: Dev-Ops, Engineering.
Roles => Machine.
Policies Are In Json.
Lease Privilege Principles.
/**
* @author ShankarShastri
* Algorithm: JumpingMario (https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2864)
*/
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.Vector;
import java.util.function.BiFunction;
/**
* @author ShankarShastri
* Algorithm: JumpingMario (https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2864)
*/
import scala.io.StdIn._
object JumpingMario {
def main(args: Array[String]): Unit = {
val n = readLine().toInt
loopWithIndex(n) { i =>
@shankarshastri
shankarshastri / PingPongRouter.scala
Last active June 14, 2019 05:33
PingPongRouter
import akka.actor._
import akka.routing.{ Broadcast, DefaultResizer, RoundRobinPool }
case object Init
case object Pong
case object Ping
class PingActor(pongActorRef: ActorRef) extends Actor {
def receive: Receive = {
case Init =>
@shankarshastri
shankarshastri / machine_learning_scikit_kaggle.ipynb
Created July 3, 2019 20:04
machine_learning_scikit_kaggle.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@shankarshastri
shankarshastri / ScalaPbSerializer.scala
Created August 30, 2019 08:47 — forked from thesamet/ScalaPbSerializer.scala
Akka serializer for ScalaPB messages
package protoser
import java.util.concurrent.atomic.AtomicReference
import akka.actor.ExtendedActorSystem
import akka.serialization.BaseSerializer
import com.trueaccord.scalapb.GeneratedMessageCompanion
class ScalaPbSerializer(val system: ExtendedActorSystem) extends BaseSerializer {
private val classToCompanionMapRef = new AtomicReference[Map[Class[_], GeneratedMessageCompanion[_]]](Map.empty)

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.