Skip to content

Instantly share code, notes, and snippets.

View ane's full-sized avatar

Antoine Kalmbach ane

View GitHub Profile
@ane
ane / StreamInterruption.scala
Created January 27, 2019 16:07
Interruptible Streams using fs2 and cats-effect
import scala.util.Random
import scala.concurrent.duration._
import cats.effect.{ExitCode, IO, IOApp}
import cats.implicits._
import fs2.Stream
import scala.concurrent.ExecutionContext.Implicits.global
import java.time.{Clock, ZoneOffset}
import fs2.concurrent.SignallingRef
@ane
ane / future.clj
Last active November 15, 2017 19:41
experimenting with a Scala Future/Task like library for Clojure
; experiments on a clojure future API
; http/get and/post are expected to return futures
; create a future
(run (Thread/sleep 100)
123)
; => java.util.concurrent.CompletableFuture[123]
; supports deref, implements java.util.concurrent.Future
@ane
ane / huh.rb
Created April 26, 2017 08:26
Huh
class Foo
def self.call(a, b, c)
"#{a} #{b} #{c}"
end
end
Foo.(1, "foo", bar)
# => "1 foo :bar"
val end: Sink[Foo, NotUsed] = ???
val route = Flow.fromGraph(GraphDSL.create(end) { implicit builder => dest =>
import GraphDSL.Implicits._
// todo: errors, request validation, etc.
val entityFlow = builder.add(Flow[HttpRequest].mapAsync(1)(r => Unmarshal(r.entity).to[Foo]))
val responseFlow = builder.add(Flow[Foo].map(_ => HttpResponse(StatusCodes.Created)))
val bcast = builder.add(Broadcast[Foo](2))
@ane
ane / # emacs - 2016-09-14_19-36-28.txt
Created September 14, 2016 16:39
emacs on Mac OS X 10.11.6 - Homebrew build logs
Homebrew build logs for emacs on Mac OS X 10.11.6
Build date: 2016-09-14 19:36:28
@ane
ane / repl.rs
Created November 17, 2015 17:26
Guile REPL in Rust
use std::ffi::CString;
use std::env;
use std::ptr;
use libc::{c_char, c_void, c_int};
#[link(name="guile-2.0")]
extern {
fn scm_shell(argc: c_int, argv: *const *const c_char) -> c_void;
fn scm_boot_guile(argc: c_int,
argv: *const *const c_char,
@ane
ane / Producer.fs
Last active August 29, 2015 14:14
Simple Producer&Consumer program using Redis lists and Pub/Sub.
module WorkerProducer.Producer
open Nessos.FsPickler
open StackExchange.Redis
open System
open System.Text
open System.Threading
open WorkerProducer.Worker
let pickler = FsPickler.CreateBinary()
@ane
ane / DTO2.fs
Created January 8, 2015 21:50
A more developed DTO handling that fails because .NET serialization can cast any null object to something.
// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.
open Suave
open Suave.Json
open Suave.Types
open Suave.Types.Methods
open Suave.Utils
open Suave.Http
open Suave.Http.Authentication
open Suave.Http.Writers
@ane
ane / WebApp.fs
Created January 8, 2015 17:19
Simple DTO passing in F# using Suave.
// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.
open Suave
open Suave.Json
open Suave.Types
open Suave.Types.Methods
open Suave.Utils
open Suave.Http
open Suave.Http.Authentication
open Suave.Http.Writers
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>asdf asdf asdf asdf</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<!-- { body: cont } from gulpfile.js:41 is rendered here -->