Skip to content

Instantly share code, notes, and snippets.

View fmonniot's full-sized avatar

François Monniot fmonniot

View GitHub Profile
@fmonniot
fmonniot / TestCats.scala
Created February 22, 2017 14:13 — forked from atamborrino/TestCats.scala
Using Cats for error validation with error accumulation. Comparison with Scalactic: https://gist.github.com/atamborrino/5d2780512ea3eccc98bccd4557f7207e
object TestCats {
import cats._
import cats.data._
import cats.instances.future._
import cats.syntax.either._
import cats.syntax.cartesian._
import cats.instances.list._
import cats.syntax.traverse._
@fmonniot
fmonniot / keybase.md
Created January 31, 2018 17:38
keybase.md

Keybase proof

I hereby claim:

  • I am fmonniot on github.
  • I am fmonniot (https://keybase.io/fmonniot) on keybase.
  • I have a public key ASB7QCqaDi9y8PPLttohHudiDMQ3Ys7Y-Vv5vnw2XzYCYQo

To claim this, I am signing this object:

@fmonniot
fmonniot / fm.zsh-theme
Last active January 24, 2019 17:41
Custom ZSH theme
# Custom theme inspired by agnoster and norm
local fm_lambda_status="%(?:%{$fg[green]%}λ:%{$fg[red]%}λ)"
local fm_bg_status="%(1j.%{$FG[068]%}[%j] .)" # %(x.true.false)
local fm_dir_status="%{$fg[green]%}%~"
local fm_end_status="%{$fg[yellow]%}$ %{$reset_color%}"
PROMPT='${fm_bg_status}${fm_lambda_status} ${fm_dir_status} $(git_prompt_info)${fm_end_status}'
ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg[yellow]%}$ %{$fg[blue]%}"
@fmonniot
fmonniot / failing-path-dependent-types.scala
Last active February 7, 2019 22:39
Failing path dependent types
object test {
trait Entity {
type Id
type Attribute <: EntityAttribute
def attributes: NonEmptyList[Attribute]
}
trait EntityCompanion {
@fmonniot
fmonniot / keys.scala
Created February 12, 2020 01:07
A short snippet to remember how to convert base64 encoded keys to their `java.security.PublicKey/PrivateKey` representation, using the i2p crypto library
import java.security.{KeyFactory, Security}
import java.util.Base64
import net.i2p.crypto.eddsa.EdDSASecurityProvider
import net.i2p.crypto.eddsa.spec.{EdDSANamedCurveTable, EdDSAPrivateKeySpec, EdDSAPublicKeySpec}
import net.i2p.crypto.eddsa.EdDSAEngine
import java.security.MessageDigest
import java.nio.charset.StandardCharsets
val pubKeyEdDSA = "e1ylCW17UIGCOrKH9zI6cceZxNe93sPsKpM0sm72bEQ="
@fmonniot
fmonniot / scope_structure.rs
Created January 28, 2021 06:08
A trait offering a scoped hashmap using references
use std::{collections::HashMap};
fn main() {
println!("Hello, world!");
let words = ["hello", "my", "world"];
let mut env = new_env();
env.insert_value("my", "MY".to_string());
@fmonniot
fmonniot / README.md
Last active March 16, 2021 22:09
A Great way to put few badges on the side
[<img src="https://daffodil.apache.org/assets/themes/apache/img/apache-daffodil-logo.svg" height="85" align="left" alt="Apache Daffodil"/>][Website]
[<img src="https://img.shields.io/github/workflow/status/apache/daffodil/Daffodil%20CI/master.svg" align="right"/>][GitHub Actions]
<br clear="right" />
[<img src="https://img.shields.io/codecov/c/github/apache/daffodil/master.svg" align="right"/>][CodeCov]
<br clear="right" />
[<img src="https://img.shields.io/maven-central/v/org.apache.daffodil/daffodil-core_2.12.svg?color=brightgreen&label=version" align="right"/>][Releases]
<br clear="both" />
@fmonniot
fmonniot / generate-certificates.ts
Last active June 9, 2021 15:29
Generate a root CA (self-signed), a CSR and a leaf certificate
import { writeFileSync, mkdirSync } from "fs";
import * as x509 from "@peculiar/x509";
import { Crypto } from "@peculiar/webcrypto";
import { execSync, spawnSync } from "child_process";
// We're okay with setting a global config for a simple script
const crypto = new Crypto();
x509.cryptoProvider.set(crypto);
const algorithm = {
@fmonniot
fmonniot / introduction.scala
Created May 28, 2021 22:04
Introduction to type classes and some of their usage pattern
// ignore this, boilerplate for later
import Instances._
import scala.concurrent.Future