Skip to content

Instantly share code, notes, and snippets.

View matterche's full-sized avatar

Matthias Erche matterche

View GitHub Profile
@ogazitt
ogazitt / auth.go
Created April 14, 2020 05:53
Auth0 PKCE flow for a CLI built in golang
package auth
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net"
"net/http"
"net/url"
@fdietze
fdietze / Readme.md
Last active October 10, 2017 14:24
Functional Programming Insights

Jitpack

https://jitpack.io

For testing purposes, the easiest way to go is jitpack:

resolvers += "jitpack" at "https://jitpack.io"
libraryDependencies += "com.github.User" % "Repo" % "Tag"

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

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@rmtsrc
rmtsrc / postgres-json-cheatsheet.md
Last active June 7, 2024 05:21
Using JSON in Postgres by example

PostgreSQL JSON Cheatsheet

Using JSON in Postgres by example.

Quick setup via Docker

  1. Download and install: Docker Toolbox
  2. Open Docker Quickstart Terminal
  3. Start a new postgres container:
    docker run --name my-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres
@kiritsuku
kiritsuku / ComplexTcpClient.scala
Last active August 15, 2018 06:11
Complex TCP server and client
import scala.io.StdIn
import scala.util._
import akka.actor._
import akka.stream._
import akka.stream.scaladsl._
import akka.stream.stage._
import akka.util._
object ComplexTcpClient extends App {
// this works in play 2.4 with the 1.9.29 version of async http client
def securePostMultipart(requestPath: String, etsyToken: RequestToken,
fileName: String, file: File, fileMimeType: String,
stringParts: (String, String)*): Future[WSResponse] = {
val fullUrl = "http://foo/bar/zar"
val parts : List[Part] = List(
new FilePart(fileName, file, fileMimeType),
@cb372
cb372 / jargon.md
Last active May 14, 2024 03:45
Category theory jargon cheat sheet

Category theory jargon cheat sheet

A primer/refresher on the category theory concepts that most commonly crop up in conversations about Scala or FP. (Because it's embarassing when I forget this stuff!)

I'll be assuming Scalaz imports in code samples, and some of the code may be pseudo-Scala.

Functor

A functor is something that supports map.

@carymrobbins
carymrobbins / pretty-print.scala
Last active January 17, 2024 14:02
Pretty print Scala case classes and other data structures.
/**
* Pretty prints a Scala value similar to its source represention.
* Particularly useful for case classes.
* @param a - The value to pretty print.
* @param indentSize - Number of spaces for each indent.
* @param maxElementWidth - Largest element size before wrapping.
* @param depth - Initial depth to pretty print indents.
* @return
*/
private def prettyPrint(a: Any, indentSize: Int = 2, maxElementWidth: Int = 30, depth: Int = 0): String = {