Skip to content

Instantly share code, notes, and snippets.

View gbersac's full-sized avatar

Guillaume Bersac gbersac

  • 42
  • Paris
  • 11:49 (UTC -12:00)
View GitHub Profile
export function createOneDocument() {
const data = {
"url": "https://firebasestorage.googleapis.com/v0/b/louvcap-eea66.appspot.com/o/public%2FpdfTemplates%2FpdfBackoffice%2Fneo_bulletin-souscription.pdf?alt=media&token=9e026601-95cf-442c-9533-5e7a4eba8ff1",
"fields": [
{
"text": "true",
"type": "CheckBox",
"pages": "1",
"fieldname": "Check Box27."
},
@gbersac
gbersac / Toggle.tsx
Created January 10, 2022 08:49
A simple toggle for react + jss
import React from "react"
import { createUseStyles, useTheme } from "react-jss"
import { Integer } from "../../model/commonTypes"
import { Theme } from "../../theme"
import { injectStyles, StylableComponent } from "./utils"
const useStyles = createUseStyles((t: Theme) => {
return {
lab: {
<button class="gf_add-to-cart product-form-product-template button btn gf_button-stretch" id="" name="add" onclick="" type="submit">
<span class="AddToCartText">ADD TO CART</span>
<div class="bk-social-proof-embed">
<!--v-if-->
</div>
<div class="bk-stock-countdown">
<div class="stock-countdown-message">
<div class="message">
<span style="font-family:Arial,Helvetica,sans-serif;font-size:18px;color:#4f5154;text-align:left;">Only 7020 items left in stock!</span>
<!--v-html-->
@gbersac
gbersac / alpakka_deserialization_error.scala
Last active August 7, 2018 09:22
#akka #kafka consumer deserialization error
/* for ammonite users
interp.load.ivy("com.typesafe.akka" %% "akka-stream-kafka" % "0.22")
interp.load.ivy("com.typesafe.play" %% "play-json" % "2.6.7")
@
*/
import scala.concurrent.{ ExecutionContext, Future }
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.{ Failure, Success }
@gbersac
gbersac / kafka_producer_listener.sh
Last active August 6, 2018 13:50
kafka producer / listener
#! /bin/sh
if [ $# -lt 2 ]; then
echo "$0 container topic"
exit 1
fi
# listener
CONTAINER="$1"
TOPIC="$2"
@gbersac
gbersac / cats_either_list_sequence.scala
Created April 23, 2018 13:12
cats sequence on either list #scala #cats
/* for ammonite users
interp.load.ivy("org.typelevel" %% "cats-core" % "1.0.1")
interp.configureCompiler(_.settings.YpartialUnification.value = true)
@
*/
import cats.instances.list._
import cats.instances.either._
import cats.syntax.traverse._
@gbersac
gbersac / test_resources_extractor.scala
Created March 22, 2018 14:44
File from test resources folder #scala
import scala.io.Source
def fileToString(fileName: String, folder: String): String =
Source.fromURL(getClass.getClassLoader.getResource(folder + fileName)).mkString
@gbersac
gbersac / rinkebi_adress.txt
Created September 28, 2017 14:48
rinkebi adress
0x7adf277b6d4e4034fd1d230b9972824418a73566
trait Functor[F[_]] {
def map[A,B](fa: F[A])(f: A => B): F[B]
def distribute[A,B](fab: F[(A, B)]): (F[A], F[B]) =
(map(fab)(_._1), map(fab)(_._2))
def codistribute[A,B](e: Either[F[A], F[B]]): F[Either[A, B]] = e match {
case Left(fa) => map(fa)(Left(_))
case Right(fb) => map(fb)(Right(_))
}
// This new data type will employ Scala’s type system to gain two static guarantees. We want our code to not compile if it violates these invariants:
// - If we hold a reference to a mutable object, then nothing can observe us mutat- ing it.
// - A mutable object can never be observed outside of the scope in which it was created.
/**
* For state thread, state transi- tion, state token, or state tag
* A local-effects monad.
*
* A: type of the mutable value.
* S: represents the ability to mutate state