Skip to content

Instantly share code, notes, and snippets.

View Igosuki's full-sized avatar

Guillaume Balaine Igosuki

View GitHub Profile
@Igosuki
Igosuki / Endpoint.scala
Created May 7, 2019 10:11
Circe - Magnolia problem example
import io.circe.magnolia.derivation.encoder.auto._
import org.http4s.rho._
import cats.implicits._
import cats.effect._
import com.us.repos._
class AppsEndpoint[F[+ _]: Effect](appsDao: AppsRepo[F], swaggerSyntax: SwaggerSyntax[F]) extends RhoRoutes[F] {
import swaggerSyntax._
// If appsDao.list is F[Seq[App]] then the jsonEncoder outputs '[...]'
@Igosuki
Igosuki / ws.scala
Last active December 20, 2021 15:46
http4s fs2 websocket
abstract class UserWSEndpoint[F[+ _]: Timer: Concurrent: ContextShift](
broadcastTopic: Topic[F, PushNotification])(implicit F: ConcurrentEffect[F])
extends Http4sDsl[F]
with Loggable {
def broadcast(e: PushNotification) = broadcastTopic.publish1(e)
def toText[A: Encoder](a: A)(implicit e: Encoder[A], wse: Encoder[WSMessage]) =
Text(wse(WSMessage("", "", e(a).some, "", "".some)).asString.get)
@Igosuki
Igosuki / LateReduceExample.scala
Last active August 16, 2017 11:06
Buggy reduce in scio
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility
import com.fasterxml.jackson.annotation.PropertyAccessor
import com.fasterxml.jackson.databind.{DeserializationFeature, ObjectMapper, SerializationFeature}
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import com.fasterxml.jackson.module.scala.experimental.ScalaObjectMapper
import com.spotify.scio.ContextAndArgs
import com.spotify.scio.values.WindowOptions
import org.apache.beam.sdk.io.TextIO.CompressionType
import org.apache.beam.sdk.transforms.windowing.AfterProcessingTime
import org.apache.beam.sdk.values.WindowingStrategy.AccumulationMode
@Igosuki
Igosuki / db.clj
Created May 18, 2017 14:16
Initializing a database and migrating with ragtime
(ns db
(:require [[ragtime.jdbc :as ragjdbc]
[clojure.tools.logging :as log]
[clojure.java.jdbc :as jdbc]
[ragtime.repl :as ragrepl]])
(defn ragtime-config [database]
{:datastore (ragtime.jdbc/sql-database database)
:migrations (ragtime.jdbc/load-resources "migrations")})
@Igosuki
Igosuki / core.cljs
Created August 31, 2016 09:11
Add the following to relevant files to get react-select with reagent
(ns core
(:require [cljsjs.react-select]))
(defn my-select []
[:> js/Select {:name "Select"
:value "Tom"
:on-change #(println "Change ! : " %)
:filter-options false
:options [{:value "Tom" :label "Tommy"}
{:value "Tom2" :label "Tommy2"}
@Igosuki
Igosuki / README.md
Created July 29, 2016 10:29
Create a DC/OS Single Master Cluster on AWS

Usage :

  chmod u+x ./zen.sh
  ./zen.sh my-dcos-stack
@Igosuki
Igosuki / database.js
Created August 19, 2015 15:30
Example ECMA6 App
"use strict";
/**
* Copyright (c) 2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
@Igosuki
Igosuki / Dockerfile
Last active August 29, 2015 14:26
Tiny docker image and go runtime
FROM centurylink/ca-certs
MAINTAINER Travis Reeder "travis@iron.io"
EXPOSE 8080
WORKDIR /app
# copy binary into image
COPY hello /app/
ENTRYPOINT ["./hello"]
@Igosuki
Igosuki / main.go
Created January 26, 2015 20:43
Go Examples
package main
import (
"fmt"
"os"
)
const n = 500000000
func main() {
@Igosuki
Igosuki / duration.rb
Last active August 29, 2015 14:06
Pass-through struct to deserialize an API into YAML
class Duration < Struct.new(:value, :quantity)
def method_missing id, *args
raise "Illegal Duration" if !value.is_a?(Numeric) || ![:years, :days, :weeks, :months, :hours, :minutes, :seconds].include?(quantity.to_sym)
value.send(quantity.to_sym).send(id.id2name.to_sym)
end
end