Skip to content

Instantly share code, notes, and snippets.

View vdebergue's full-sized avatar

Vincent Debergue vdebergue

View GitHub Profile
use async_graphql::{InputType, InputValueError};
use serde::{de::DeserializeOwned, Deserialize, Serialize, Serializer};
#[derive(Debug, Eq, PartialEq, Clone)]
pub enum MaybeUpdateOrDelete<T> {
Update(T),
Delete,
Empty,
}
object Combs extends App {
/*
findAndPrint(7, 2)
findAndPrint(14, 3)
findAndPrint(11, 2)
findAndPrint(41, 8)
findAndPrint(41, 8)
*/
// 1
@vdebergue
vdebergue / transcode.sh
Last active December 4, 2019 13:07
Transcode h264 to h265
#! /bin/bash
set -x
set -e
FOLDER="$1"
MAX_BITRATE=3000000
if [ ! -d "$FOLDER" ]; then
echo "Please input a folder"
exit 1

Keybase proof

I hereby claim:

  • I am vdebergue on github.
  • I am atezsouai (https://keybase.io/atezsouai) on keybase.
  • I have a public key ASCa3Dqevo_nYUKDHI1HPYFniiJe0XVS9_CBwGlVx43qtAo

To claim this, I am signing this object:

@vdebergue
vdebergue / NAction.scala
Last active November 8, 2017 16:09
NAction: composable action builders for play framework
package core.controllers.utils
import akka.stream.Materializer
import akka.util.ByteString
import play.api.libs.streams.Accumulator
import play.api.mvc._
import scala.concurrent.Future
/**
* NAction are a replacement to play.api.mvc.Action.

Recommandations pour l'Islande

Alors déjà premier point: c'est très cher l'Islande, prévoir un x2 sur les prix par rapport à la France pour tout ce qui est restaurant, hôtel ou en rapport avec le tourisme

Équipement

  • Indispensable:
    • Veste coupe vent et imperméable (gore-tex)
    • Pantalon imperméable
  • Chaussures de randonnées
sealed trait RedisOverflowStrategy
object RedisOverflowStrategy {
case object DropHead extends RedisOverflowStrategy
case object DropBuffer extends RedisOverflowStrategy
case object DropNew extends RedisOverflowStrategy
case object Fail extends RedisOverflowStrategy
}
class RedisSourceStage(sedisPool: org.sedis.Pool, channel: String, bufferSize: Int, overflowStrategy: RedisOverflowStrategy) extends GraphStage[SourceShape[String]] {
val out: Outlet[String] = Outlet("Redis.out")
def withTransaction[A](block: Connection => Future[A]): Future[A] = {
val connection = db.getConnection(autocommit = false)
try {
val fut = block(connection)
fut.onComplete {
case Success(res) =>
connection.commit()
connection.close()
case Failure(exe) =>
connection.rollback()
@vdebergue
vdebergue / ActionPartial.scala
Last active December 14, 2015 12:36
ActionPartial
package play.api.mvc
// needed to access protected method ActionRefiner#refine
import scala.concurrent.Future
import scala.language.higherKinds
trait ActionPartial[R[_], P[_]] extends ActionRefiner[R, P] { self =>
def partial[A]: PartialFunction[R[A], Future[Either[Result, P[A]]]]
def refine[A](request: R[A]): Future[Either[Result, P[A]]] = partial(request)