Skip to content

Instantly share code, notes, and snippets.

View abdheshkumar's full-sized avatar

Abdhesh Kumar abdheshkumar

View GitHub Profile
@abdheshkumar
abdheshkumar / digest.scala
Created September 8, 2017 13:18
Akka stream flow fold
import java.nio.ByteBuffer
import java.security.MessageDigest
import javax.xml.bind.DatatypeConverter
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.model.HttpMethods.GET
import akka.http.scaladsl.model.{HttpRequest, HttpResponse}
import akka.stream.ActorMaterializer
import akka.stream.scaladsl.{Flow, Keep, Sink}
```javascript
{
"title":"Report Properties",
"description":"A JSON Schema describing a Report Properties",
"$schema":"http://json-schema.org/draft-04/schema#",
"type":"object",
"properties":{
"server":{
"type":"string",
"description":"URL of JRS instance."
@abdheshkumar
abdheshkumar / facades.scala
Last active August 22, 2017 13:01
ScalaJs facades
@js.native
trait Auth extends js.Object {
val byToken: js.UndefOr[LoginWithSSOToken] = js.undefined
val byCredentials: js.UndefOr[LoginWithPlainText] = js.undefined
}
object Auth {
def apply(authType: AuthType): Auth = authType match {
case byToken: LoginWithSSOToken => js.Dynamic.literal(byToken = byToken).asInstanceOf[Auth]
case byCredentials: LoginWithPlainText => js.Dynamic.literal(byCredentials = byCredentials).asInstanceOf[Auth]
@abdheshkumar
abdheshkumar / function-translation.scala
Last active August 10, 2017 09:58
Function Translation
val fun: ((Int, Int)) => Int = (kv: Tuple2[Int, Int]) => kv match {
case (k, v) => k + v
}
val fun1: Function1[Tuple2[Int, Int], Int] = (kv: Tuple2[Int, Int]) => kv match {
case (k, v) => k + v
}
val myMap = Map(1 -> 2, 2 -> 3)
myMap.map(fun)
@abdheshkumar
abdheshkumar / Typeclasses.scala
Created August 10, 2017 09:33
How to implement typeclasses
trait Named[E] {
val name: String
}
case class EOL()
implicit val namedInt = new Named[Int] {
override val name: String = "Int"
}
** Working */
sealed class AB[+A] protected(protected val in: List[A], protected val out: List[A])
object AB {
class ABC(override protected val in: List[Int],
override protected val out: List[Int])
extends AB(in, out)
}
/**Not Working*/
sealed class AB[+A] protected(protected val in: List[A], protected val out: List[A])
Command:
connect\n\n
Response:
Event-Name: CHANNEL_DATA
Core-UUID: d01fd5af-47d1-4cc0-9135-72be72656b21
FreeSWITCH-Hostname: abdhesh-System-Product-Name
FreeSWITCH-Switchname: abdhesh-System-Product-Name
FreeSWITCH-IPv4: 10.0.0.29
FreeSWITCH-IPv6: %3A%3A1
@abdheshkumar
abdheshkumar / README.md
Created July 9, 2017 09:46 — forked from pathikrit/README.md
My highly opinionated list of things needed to build an app in Scala
import cats.Id
import cats.implicits._
import freestyle._
import freestyle.implicits._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
/**
* Created by abdhesh on 05/05/17.
import freestyle._
import freestyle.implicits._
import freestyle.implicits.interpretAp
import cats.implicits._
case class ValidationResult(isValid:Boolean, events:List[Event])
trait Command
case class UnknownCommand(cmd:Any) extends Command
sealed trait Event {val name:String}