Skip to content

Instantly share code, notes, and snippets.

View aerohit's full-sized avatar

Rohit Saxena aerohit

View GitHub Profile
# Check the /etc/hosts file too.
server {
# The servers are distinguished by the paths
# Domain is same, but paths are different
# Supports request of the urls:
# http://prodapp.com/nodehost/hostandtime
# http://prodapp.com/node01/hostandtime
# http://prodapp.com/node02/hostandtime
@aerohit
aerohit / Communicator.scala
Last active July 2, 2017 09:32
The Communicator
// Taken from this blog post:
// http://ane.github.io/2016/10/14/communicator-functional-actors.html
import akka.actor.Actor
import akka.actor.ActorRef
import scala.concurrent.Future
trait Communicator[State, Input, Output] extends Actor {
<html>
<body>
<script src="https://blockexplorer.com/socket.io/socket.io.js"></script>
<script>
eventToListenTo = 'tx'
room = 'inv'
var socket = io("https://blockexplorer.com/");
socket.on('connect', function() {
// Join the room.

Keybase proof

I hereby claim:

  • I am aerohit on github.
  • I am aerohit (https://keybase.io/aerohit) on keybase.
  • I have a public key whose fingerprint is 9E92 688A 437A CE34 9B38 ACA6 B11A 9D6E 1EAE 35CB

To claim this, I am signing this object:

@aerohit
aerohit / argonaut.scala
Created February 23, 2018 15:35
argonaut sum types
import com.vimpelcom.ep.common.Msisdn
import org.scalatest.FunSpecLike
import org.scalatest.Matchers
import argonaut._
import Argonaut._
sealed trait ChallengeProof2FAOutcome
case class ChallengeProof2FAFailure(status: String, meta: String) extends ChallengeProof2FAOutcome
@aerohit
aerohit / TaglessFinalEg.hs
Last active July 9, 2020 05:36
Unit testing Tagless Final
-- Reference: https://jproyo.github.io/posts/2019-03-17-tagless-final-haskell.html
newtype UserName = UserName String deriving Show
newtype DataResult = DataResult String deriving (Show, Eq)
newtype AppConfig = AppConfig String deriving Show
newtype LogMsg = LogMsg String deriving Show
class Monad m => Cache m where
getFromCache :: UserName -> m (Maybe DataResult)
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
module HZK202007080846
()
where
import Control.Monad.Identity
import Test.Hspec
-- TAGS :tagless-final:
@aerohit
aerohit / TaglessFinalMockDataKinds.hs
Created August 21, 2020 06:01
Unit testing Tagless Final approach using DataKinds for mocking
import Control.Monad.Reader
import Control.Monad.Identity
import Test.Hspec
-- Reference: https://chrispenner.ca/posts/mock-effects-with-data-kinds
newtype UserName = UserName String deriving (Eq, Show, Ord)
newtype Data = Data String deriving (Show, Eq)
newtype AppConfig = AppConfig String deriving Show
newtype LogMsg = LogMsg String deriving Show
@aerohit
aerohit / StringTextByteString.hs
Created September 26, 2020 05:31
Convert between String Text And ByteString
-- Reference: Ecky Putrady, Practical Web Development with Haskell, Table 2-1
String Text fromString
String LText fromString
String ByteString fromString
String LByteString fromString
Text LText fromStrict
Text ByteString encodeUtf8
Text LByteString (fromStrict . encodeUtf8)
Text String unpack