Skip to content

Instantly share code, notes, and snippets.

View nicocavallo's full-sized avatar

Nicolas Cavallo nicocavallo

View GitHub Profile
@nicocavallo
nicocavallo / build.sbt
Last active November 19, 2015 08:38
Example of sbt-buildinfo plugin using environment variables.
lazy val root = (project in file("."))
.enablePlugins(PlayScala, SbtLiquibase, BuildInfoPlugin)
.settings(
buildInfoKeys := Seq[BuildInfoKey](name, version, scalaVersion, sbtVersion,
"buildNumber" -> Option(System.getenv("BUILD_NUMBER")).getOrElse("n/a"),
"gitCommit" -> Option(System.getenv("GIT_COMMIT")).getOrElse("n/a"),
"gitBranch" -> Option(System.getenv("GIT_BRANCH")).getOrElse("n/a")
),
buildInfoPackage := "picsolve.jenkins.metadata",
@nicocavallo
nicocavallo / The Technical Interview Cheat Sheet.md
Created February 2, 2017 14:20 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
@nicocavallo
nicocavallo / checkCryptoCurrency.ps1
Created June 28, 2017 23:03
PowerShell Script for notifying when a given crypto-currency's price is under a given threshold.
param(
$confPath = "./conf.txt"
)
while (1)
{
$props = convertfrom-stringdata (get-content -path $confPath -raw)
$period = [convert]::ToInt32($props.'app.interval', 10)
@nicocavallo
nicocavallo / Contenful.scala
Created September 8, 2017 21:37
Contentful Scala Library
package nicocavallo.contentful
import java.time.ZonedDateTime
import com.contentful.java.cda._
import com.typesafe.config.Config
import org.reactivestreams.{Subscriber, Subscription}
import scala.concurrent.{Future, Promise}
import scala.language.postfixOps
@nicocavallo
nicocavallo / validated.sc
Last active September 21, 2017 15:14
Minimalistic example of CATS Validated / ValidatedNel and Xor / XorT
import cats._
import cats.data.Validated.{Invalid, Valid}
import cats.data.{ValidatedNel, _}
import cats.implicits._
case class Person(name: String, jobTitle: String, age: Int)
case class Error(msg: String)
type ValidationResult[T] = ValidatedNel[Error,T]
@nicocavallo
nicocavallo / StripeSignatureValidationExample.sc
Created October 30, 2017 10:11
Example about manual checking Stripe signature in webhook calls in Scala
import javax.crypto.Mac
import javax.crypto.spec.SecretKeySpec
import org.apache.commons.codec.binary.Hex
val sharedSecret = "whsec_A2EdfajGiGHx9jFmkP7ia6j25VXh9IWV"
val payload = "{\n \"id\": \"evt_YEEz4JGN6UwGkCjdqr7wfPqL\",\n \"object\": \"event\",\n \"api_version\": \"2017-06-05\",\n \"created\": 1509023721,\n \"data\": {\n \"object\": {\n \"id\": \"my-first-test-plan\",\n \"object\": \"plan\",\n \"amount\": 599,\n \"created\": 1509023721,\n \"currency\": \"gbp\",\n \"interval\": \"month\",\n \"interval_count\": 1,\n \"livemode\": false,\n \"metadata\": {\n },\n \"name\": \"My first test plan\",\n \"statement_descriptor\": \"My first test plan\",\n \"trial_period_days\": 31\n }\n },\n \"livemode\": false,\n \"pending_webhooks\": 1,\n \"request\": {\n \"id\": \"req_6UwGkCjdqr7wfPqLAq\",\n \"idempotency_key\": null\n },\n \"type\": \"plan.created\"\n}"
val header = "t=1509023726,v1=e786c1d46f2fa3bbd57cf974e89533ecb89b
@nicocavallo
nicocavallo / euTerritories.json
Created June 8, 2018 13:27
EU and Special territories country codes
[
{"isoCode": "AT", "name": "Austria"},
{"isoCode": "BE", "name": "Belgium"},
{"isoCode": "BG", "name": "Bulgaria"},
{"isoCode": "HR", "name": "Croatia"},
{"isoCode": "CY", "name": "Cyprus"},
{"isoCode": "CZ", "name": "Czech Republic"},
{"isoCode": "DK", "name": "Denmark"},
{"isoCode": "EE", "name": "Estonia"},
{"isoCode": "FI", "name": "Finland"},
@nicocavallo
nicocavallo / functional_programming_kotlin.md
Created July 16, 2018 12:18
functional programming in Kotlin

Background

While Kotlin is not a pure functional language, it provides Higher order functions and an expressive way of writing programs vs statements provided by imperative languages like Java.

Functions

Function declaration