Skip to content

Instantly share code, notes, and snippets.

View vi-kas's full-sized avatar
💭
Active 💯

Vikas Sharma vi-kas

💭
Active 💯
View GitHub Profile
@vi-kas
vi-kas / AkkaHttpRoutes
Created March 13, 2020 14:59
Explains concatenation of akka-http routes
/* Akka Http Routes
* ----------------
* Use of `concat` here:
* Tries the supplied routes in sequence, returning the result of the first route that doesn't reject the request.
*
* Eg.
* In the case of:
* GET /orders - `get(complete(StatusCodes.OK, s"GET All Orders request."))` will be executed.
*
* GET /orders/<some uuid> - `get(complete(StatusCodes.OK, s"GET request for id: $id"))` will be executed.
@vi-kas
vi-kas / CirceMarshallable.scala
Created October 5, 2019 04:14
Circe Json Marshaller for akka-http
import akka.http.scaladsl.marshalling.{Marshaller, ToEntityMarshaller}
import akka.http.scaladsl.model.MediaTypes.`application/json`
import akka.http.scaladsl.model.{ContentType, ContentTypeRange, HttpEntity, MediaType}
import akka.http.scaladsl.unmarshalling.{FromEntityUnmarshaller, Unmarshaller}
import akka.util.ByteString
import io.circe._
/**
* https://doc.akka.io/docs/akka-http/current/common/marshalling.html
@vi-kas
vi-kas / github_issues.py
Created July 9, 2019 10:25
Script to create a Github Issue
import os
import sys
print(sys.version)
print("\n \n")
print(sys.path)
sys.path.append('/usr/local/lib/python3.7/site-packages')
import json
import requests
import pandas as pd
@vi-kas
vi-kas / jsPromises.js
Last active July 9, 2019 09:13
Simple JavaScript Promises
/*
Promise Flow in JS - https://mdn.mozillademos.org/files/15911/promises.png
1. Creating a Promise by passing an executor
2. Using Promise prototype methods
2a. then handler
2b. catch handler
2c. finally handler
3. Using Promise static methods
3a. Promise.resolve
@vi-kas
vi-kas / OutcomeOfExample.scala
Created August 25, 2018 04:48
Ways we can use `outcomeOf` method from trait `OutcomeOf` at usage places.
package learning.gists
/**
* GIST shows -
* Ways we can use `outcomeOf` method at usage place from trait `OutcomeOf`.
* 1. We can mixin the trait.
* 2. We can import trait's comp object.
*/
//Outcome ADT