Skip to content

Instantly share code, notes, and snippets.

Debasish Ghosh debasishg

Block or report user

Report or block debasishg

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
debasishg /
Created Nov 28, 2019
Keeping a remote fork in sync
git status
git checkout master
git remote -v
git remote add upstream
git remote -v
git fetch upstream
git pull upstream master
git push origin master
debasishg /
Last active Sep 27, 2019
Useful links to read ..

Visitor Pattern

View gist:738436be246179293c50f4ab7bef02b1
Can we do it with `ClassTag` ?
You can't with a class tag, as it represents the erased type as known to the JVM. You could use a TypeTag
to reify the full type, but that depends on full scala reflection, which has its own downsides
(not thread safe, basically pulls in the compiler,...)
scala> import scala.reflect.runtime.universe.TypeTag
import scala.reflect.runtime.universe.TypeTag
View GDP.scala
trait Coercible[A, B] {
def coerce(a: A): B
def coerce[A, B](a: A)(implicit coerceAB: Coercible[A, B]): B = {
trait Newtype[+T] {
val value: T
debasishg /
Created Mar 23, 2019 — forked from ibraheem4/
Installing Postgres via Brew (OSX)

Installing Postgres via Brew


Brew Package Manager

In your command-line run the following commands:

  1. brew doctor
  2. brew update
View postgresql.txt
# start postgresql
pg_ctl -D /usr/local/var/postgres start
# stop postgresql
pg_ctl -D /usr/local/var/postgres stop
debasishg / state.hs
Created Mar 11, 2019 — forked from sdiehl/state.hs
State monad implementation + example
View state.hs
import Control.Monad
-- State Monad Implementation
newtype State s a = State { runState :: s -> (a,s) }
instance Monad (State s) where
return a = State $ \s -> (a, s)
Given a dictionary, transform it to a string. Then byte encode that string. Then base64 encode it and since this will go
on a url, use the urlsafe version. Then decode the byte string so that it can be else where.
data = base64.urlsafe_b64encode(json.dumps({'a': 123}).encode()).decode()
# And the decode is just as simple...
data = json.loads(base64.urlsafe_b64decode(query_param.encode()).decode())
# Byte encode the string, base64 decode that, then byte decode, finally transform it to a dictionary
debasishg /
Created Aug 24, 2018 — forked from coacoas/
Using Scala collections from Java
package org.example;
import scala.Function1;
import scala.collection.generic.CanBuildFrom;
import scala.collection.immutable.List;
import scala.collection.immutable.List$;
import scala.collection.immutable.Vector;
import scala.collection.immutable.Vector$;
import scala.collection.mutable.Builder;
debasishg / service_types.scala
Created Aug 12, 2018
algebra of effects for a domain service
View service_types.scala
type Valid[M[_], A] = EitherT[M, AccountServiceException, A]
type AccountOperation[M[_], A] = Kleisli[Valid[M, ?], AccountRepository[M], A]
You can’t perform that action at this time.