Skip to content

Instantly share code, notes, and snippets.

💻
Think -> Code -> Solve

ShankarShastri shankarshastri

💻
Think -> Code -> Solve
Block or report user

Report or block shankarshastri

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@shankarshastri
shankarshastri / redis-master.yaml
Last active Jan 29, 2020
Redis And Redis Insight
View redis-master.yaml
apiVersion: v1
kind: Service
metadata:
name: redis-service
spec:
type: LoadBalancer
selector:
app: redis
ports:
- name: redis
View Applied-FP-with-Scala.md

Applied Functional Programming with Scala - Notes

Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@shankarshastri
shankarshastri / gist:4d496958d7d0b06f568ee043f2637ab4
Created Jan 2, 2020 — forked from cvogt/gist:9193220
Slick: Dynamic query conditions using the **MaybeFilter** (Updated to support nullable columns)
View gist:4d496958d7d0b06f568ee043f2637ab4
import scala.slick.lifted.CanBeQueryCondition
// optionally filter on a column with a supplied predicate
case class MaybeFilter[X, Y](val query: scala.slick.lifted.Query[X, Y]) {
def filter[T,R:CanBeQueryCondition](data: Option[T])(f: T => X => R) = {
data.map(v => MaybeFilter(query.filter(f(v)))).getOrElse(this)
}
}
// example use case
import java.sql.Date
View thread-pools.md

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.

@shankarshastri
shankarshastri / ScalaPbSerializer.scala
Created Aug 30, 2019 — forked from thesamet/ScalaPbSerializer.scala
Akka serializer for ScalaPB messages
View ScalaPbSerializer.scala
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)
View 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.
View PingPongRouter.scala
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 =>
View JumpingMario.scala
/**
* @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 =>
View JumpingMario.java
/**
* @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;
@shankarshastri
shankarshastri / LearnXInYMinProtocolBuffer.proto
Last active Feb 16, 2020
Self-Explanatory Protocol Buffer Lang Guide (CheatSheet)
View LearnXInYMinProtocolBuffer.proto
/*
* 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.
You can’t perform that action at this time.