Skip to content

Instantly share code, notes, and snippets.

Abdhesh Kumar abdheshkumar

Block or report user

Report or block abdheshkumar

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
View Typeclass.scala
//In library
trait Event
trait EventCombiner[A <: Event] {
def initialValue: Int
def combineEvents(value: Int, e2: A): Int
}
def foldEvents[A <: Event](list: Seq[A])(implicit C: EventCombiner[A]): Int =
list.foldLeft(C.initialValue)(C.combineEvents)
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
@abdheshkumar
abdheshkumar / fpmax.scala
Created Jul 13, 2018 — forked from jdegoes/fpmax.scala
FP to the Max — Code Examples
View fpmax.scala
package fpmax
import scala.util.Try
import scala.io.StdIn.readLine
object App0 {
def main: Unit = {
println("What is your name?")
val name = readLine()
View DML_DDL_DCL_TCL.cql
DDL
DDL is short name of Data Definition Language, which deals with database schemas and descriptions, of how the data should reside in the database.
CREATE – to create database and its objects like (table, index, views, store procedure, function and triggers)
ALTER – alters the structure of the existing database
DROP – delete objects from the database
TRUNCATE – remove all records from a table, including all spaces allocated for the records are removed
COMMENT – add comments to the data dictionary
RENAME – rename an object
@abdheshkumar
abdheshkumar / Conversions.scala
Created Apr 11, 2018 — forked from SystemFw/Conversions.scala
Typed schema conversion with shapeless
View Conversions.scala
object Conversions {
import cats._, implicits._, data.ValidatedNel
import mouse._, string._, option._
import shapeless._, labelled._
private type Result[A] = ValidatedNel[ParseFailure, A]
case class ParseFailure(error: String)
trait Convert[V] {
View scala-exception-handling.scala
val tryCatch = try {
//Code here that might raise an exception
throw new Exception
} catch {
case ex: Exception =>
//Code here for handle an exception
}
val tryMultipleCatch = try {
//Code here that might raise an exception
View generic-type-pattern.scala
sealed trait A
case class B[Req, Res](r: Req, rs: Res) extends A
case class C[Req](r: Req, errorCode: Int, errorMessage: String) extends A
trait TypeA[Req, Res] {
def success(t: Req, r: Res): Unit
def error(t: Req): Unit
}
implicit val forString = new TypeA[String, String] {
override def success(t: String, r: String): Unit = ???
View Contravariance.scala
trait Item
trait PlasticItem extends Item
trait PlasticBottle extends PlasticItem
trait PaperItem extends Item
trait NewsPaper extends PaperItem
View Object-Function.js
Html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
Office = {
initialize: function (reason) {
View options.js
{
type: 'devs.Model',
inPorts: [],
outPorts: [],
size: {
width: 80,
height: 80
},
attrs: {
You can’t perform that action at this time.