Skip to content

Instantly share code, notes, and snippets.

import java.util.concurrent.TimeUnit
import java.util.concurrent.atomic.AtomicInteger
import com.couchbase.client.java.document.JsonLongDocument
import com.couchbase.client.java.env.DefaultCouchbaseEnvironment
import com.couchbase.client.java.{Cluster, CouchbaseCluster}
import com.typesafe.config.{Config, ConfigFactory, ConfigValueFactory}
import ir.sahab.sepah.lib.resources.SepahStreamConst
import org.apache.logging.log4j.{LogManager, Logger}
import rx.functions.Func1
package org.apache.spark.metrics.source
import com.codahale.metrics.{Counter, Gauge, Meter, MetricRegistry}
import org.apache.spark.{Accumulator, SparkEnv}
import org.joda.time.DateTime
import scala.collection.mutable
/**
* <h1>SparkInstrumentation</h1>
package com.github.etacassiopeia.jna;
import com.sun.jna.LastErrorException;
import com.sun.jna.Native;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import sun.nio.ch.DatagramSocketAdaptor;
import java.io.FileDescriptor;
import java.io.IOException;

Advanced Functional Programming with Scala - Notes

Copyright © 2017 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
object Graduation extends DefaultRunnableSpec {
def spec =
suite("Graduation") {
test("bulkhead") {
type Task = Has[Console] with Has[Live]
val task = Live.live(ZIO.sleep(100.millis)) *> Console.print(".")
final case class Bulkhead(ref: TRef[Int], maxInProcess: Int) {
package com.ncl.vacation.analytics.utils
import scala.language.experimental.macros
import scala.reflect.macros.blackbox
import scala.reflect.runtime.universe.typeOf
object ExtendCaseClass {
def extendCaseClassImpl[T: c.WeakTypeTag](c: blackbox.Context)(additionalFields: c.Expr[Any]*): c.Expr[Any] = {
import c.universe._
import scala.meta._
class ExtendWith(additionalFields: (String, Type)*) extends scala.annotation.StaticAnnotation {
inline def apply(defn: Any): Any = meta {
// Extract the original case class fields
val q"..$mods case class $tname[..$tparams] $ctorMods(...$paramss) extends $template" = defn
// Create new fields using the additionalFields provided
val newFields = additionalFields.map {
case (name, tpe) => param"$name: $tpe"
# Function to list and switch Git branches using fzf
git_checkout_fzf() {
# Ensure we're inside a Git repository
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "Not a git repository!"
return 1
fi
# Fetch the latest remote branches
git fetch --prune
#!/bin/bash
# Path to your Hercules.properties file
PROPERTIES_FILE="Hercules.properties"
# Temporary files
SBT_OUTPUT="sbt_update_output.txt"
PROPERTIES_DEPS="properties_deps.txt"
SBT_DEPS="sbt_deps.txt"
import pytest
from moto import mock_dynamodb2, mock_sqs
import boto3
import os
import json
from lambdas.scanner.scanner_lambda import lambda_handler
@pytest.fixture
def aws_credentials():
os.environ['AWS_ACCESS_KEY_ID'] = 'testing'