Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
Think -> Code -> Solve

ShankarShastri shankarshastri

💻
Think -> Code -> Solve
View GitHub Profile
View gist:fa57458b1c5c228346a25fddeb688652
to check if the server works - https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice
stun:
stun.l.google.com:19302,
stun1.l.google.com:19302,
stun2.l.google.com:19302,
stun3.l.google.com:19302,
stun4.l.google.com:19302,
stun.ekiga.net,
stun.ideasip.com,
View EditDistance.scala
def editDistance(s1: String, s2: String): Int = {
val s1Arr = s1.toCharArray
val s2Arr = s2.toCharArray
val mapOfEditDistance = scala.collection.mutable.HashMap.empty[(Int, Int), Int]
def editDistanceHelperDP(i: Int, j: Int): Int = {
mapOfEditDistance.getOrElseUpdate((i, j), if(i == -1) {
mapOfEditDistance.update((i, j), j + 1)
View MutableTrie.scala
import scala.annotation.tailrec
import scala.collection.mutable
case class MutableTrieNode(h: mutable.HashMap[Char, MutableTrieNode], isWord: Boolean = false)
object MutableTrieNode {
def empty = MutableTrieNode(mutable.HashMap.empty)
def buildTrieNode(s: List[Char], t: MutableTrieNode = MutableTrieNode.empty): MutableTrieNode = {
s match {
case Nil => t.copy(isWord = true)
View ImmutableTrie.scala
import scala.annotation.tailrec
import scala.collection.immutable.HashMap
case class TrieNode(h: HashMap[Char, TrieNode], isWord: Boolean = false)
object TrieNode {
def empty = TrieNode(HashMap.empty)
def buildTrieNode(s: List[Char], t: TrieNode = TrieNode.empty): TrieNode = {
s match {
case Nil => t.copy(isWord = true)
View Trie.scala
case class TrieNode[T](edgeList: Map[T, TrieNode[T]] = Map.empty[T, TrieNode[T]], isLeaf: Boolean = false,
isEntry: Boolean = false)
object TrieNode {
def emptyTrieNode[T]: TrieNode[T] = {
TrieNode[T]()
}
def newTrieNode[T](data: T): TrieNode[T] = {
TrieNode[T](edgeList = Map[T, TrieNode[T]]((data, emptyTrieNode[T])))
@shankarshastri
shankarshastri / Client example
Created Jun 8, 2020 — forked from rklaehn/Client example
akka http file server
View Client example
package akkahttptest
import akka.http.Http
import akka.stream.ActorFlowMaterializer
import akka.actor.ActorSystem
import akka.stream.scaladsl.{Sink, Source}
import akka.http.model._
object TestClient extends App {
@shankarshastri
shankarshastri / 2019-https-localhost.md
Created May 9, 2020 — forked from cecilemuller/2019-https-localhost.md
How to create an HTTPS certificate for localhost domains
View 2019-https-localhost.md

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 / letsencrypt_2020.md
Created May 9, 2020 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)
View letsencrypt_2020.md

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

View KafkaProducerConsumerAvro.scala
import java.io.ByteArrayOutputStream
import java.time.Duration
import java.util.concurrent.Executors
import java.util.{Properties, Timer, TimerTask, UUID}
import Models.{Message, SystemMessage, UserMessage, msgAvroSchema}
import com.sksamuel.avro4s.{AvroInputStream, AvroOutputStream, AvroSchema}
import org.apache.kafka.clients.consumer._
import org.apache.kafka.clients.producer._
import org.apache.kafka.common.errors.WakeupException
You can’t perform that action at this time.