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 / LearnXInYMinProtocolBuffer.proto
Last active February 2, 2024 03:18
Self-Explanatory Protocol Buffer Lang Guide (CheatSheet)
/*
* Self-Explanatory Protocol Buffer Lang Guide
*/
/*
* Why Protocol Buffers?
* Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.
* You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages.
* Protocol Buffers are Schema Of Messages. They are language agnostic.
@shankarshastri
shankarshastri / README.md
Created March 22, 2020 05:33 — forked from crypticmind/README.md
Setup lambda + API Gateway using localstack
@shankarshastri
shankarshastri / first-look-at-scala-3.md
Last active December 29, 2021 06:34
first-look-at-scala-3
We couldn’t find that file to show.
@shankarshastri
shankarshastri / 2019-https-localhost.md
Created May 9, 2020 10:19 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains

How to create an HTTPS certificate for localhost domains

This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.

Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).

@shankarshastri
shankarshastri / AkkaTypedWebsocketServer.scala
Created December 19, 2020 11:24
AkkaTypedWebsocketServer
package com.akka.websocket
import akka.NotUsed
import akka.actor.typed.scaladsl.Behaviors
import akka.actor.typed.{ActorRef, ActorSystem, Behavior}
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.StatusCodes
import akka.http.scaladsl.model.ws.{BinaryMessage, Message, TextMessage}
import akka.http.scaladsl.server.Directives._
import akka.stream.scaladsl.{Flow, Keep, Sink, Source}
@shankarshastri
shankarshastri / PingPongActorMain.scala
Created December 18, 2020 13:37
PingPongActorMain
import akka.NotUsed
import akka.actor.typed.scaladsl.Behaviors
import akka.actor.typed.{ActorRef, ActorSystem, Behavior}
import scala.concurrent.duration.DurationInt
object PingPongActorMain extends App {
case class Ping(counter: Int, replyTo: ActorRef[Pong])
@shankarshastri
shankarshastri / certificate.md
Last active December 13, 2020 11:20
scylladb_data_modelling
We couldn’t find that file to show.
@shankarshastri
shankarshastri / ExploreUnionTypes.scala
Last active October 24, 2020 04:58
ExploreUnionTypes
object ExploreUnionTypes {
final case class Some[T](t: T)
final case class None()
type Option[T] = Some[T] | None
def toOption[T](t: T): Option[T] = {
if (t == null) None() else Some(t)
}
@main
@shankarshastri
shankarshastri / ExploreIntersectionTypes.scala
Created October 23, 2020 16:54
ExploreIntersectionTypes
object ExploreIntersectionTypes {
trait Mapper[A, B] {
def map(l: List[A])(f: A => B): List[B] = l.map(f)
}
trait Reducer[A, B >: A] {
def reduce(l: List[A])(f: (B, B) => B): B = l.reduce(f)
}
object ExploreDependentFunctionValue {
trait Entry { type Key; val key: Key }
def extractKey(e: Entry): e.Key = e.key // a dependent method
val extractor: (e: Entry) => e.Key = extractKey // a dependent function value
final case class IntEntry() extends Entry {
type Key = Int
override val key = 10
}