Skip to content

Instantly share code, notes, and snippets.

View mathieuancelin's full-sized avatar

Mathieu ANCELIN mathieuancelin

View GitHub Profile
@mathieuancelin
mathieuancelin / Lens.java
Last active March 7, 2023 02:23
Lenses with Java 8
package bar.foo.lenses;
import java.util.function.BiFunction;
import java.util.function.Function;
public class Lens<A, B> {
private final Function<A, B> getter;
private final BiFunction<A, B, A> setter;
/*
"dependencies": {
"bcrypt": "3.0.3",
"node-jsencrypt": "1.0.0"
}
*/
const bcrypt = require('bcrypt');
const JSEncrypt = require('node-jsencrypt');
const _crypto = require('crypto');
package com.foo.loic;
import java.io.*;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.*;
package com.sample.ws;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.service.model.MessagePartInfo;
import org.apache.cxf.service.model.OperationInfo;
function jwt_decode() {
jq -R 'split(".") | .[0] | @base64d | fromjson' <<< "$1"
jq -R 'split(".") | .[1] | @base64d | fromjson | if .iat then (.iat_str = (.iat|gmtime|strftime("%Y-%m-%dT%H:%M:%S %Z"))) else . end | if .exp then (.exp_str = (.exp|gmtime|strftime("%Y-%m-%dT%H:%M:%S %Z"))) else . end | if .nbf then (.nbf_str = (.nbf|gmtime|strftime("%Y-%m-%dT%H:%M:%S %Z"))) else . end' <<< "$1"
}
package controllers;
import play.*;
import play.mvc.*;
import views.html.*;
import services.*;
import javax.enterprise.inject.*;
import javax.enterprise.context.*;
@mathieuancelin
mathieuancelin / otoroshi (2).json
Last active April 8, 2020 12:07
Keycloak docker mtls
{
"clientId": "otoroshi",
"name": "otoroshi",
"description": "otoroshi",
"rootUrl": "http://localhost:8080",
"adminUrl": "http://localhost:8080/*",
"surrogateAuthRequired": false,
"enabled": true,
"alwaysDisplayInConsole": false,
"clientAuthenticatorType": "client-x509",
package otoroshi.plugins.defer
import akka.http.scaladsl.util.FastFuture
import akka.stream.Materializer
import env.Env
import org.joda.time.DateTime
import otoroshi.script._
import play.api.libs.json._
import play.api.mvc.Result
@mathieuancelin
mathieuancelin / GoodOldPlayframework.scala
Last active April 28, 2019 19:06
A really dirty way to use Playframework without Guice
package old.play
import java.sql.Connection
import java.util.concurrent.atomic.{AtomicInteger, AtomicReference}
import java.util.concurrent.{Executors, ThreadFactory}
import akka.actor.{ActorSystem, Scheduler}
import akka.stream.Materializer
import play.api.ApplicationLoader.Context
import play.api.Mode.Mode

Otoroshi cluster demos

assuming your local ip address is 192.168.86.194

Getting otoroshi

curl -L -o otoroshi.jar 'https://dl.bintray.com/maif/binaries/otoroshi.jar/1.4.6/otoroshi.jar'
# or
curl -L -o otoroshi.jar 'https://dl.bintray.com/maif/binaries/otoroshi.jar/snapshot/otoroshi.jar'