Skip to content

Instantly share code, notes, and snippets.

View sderosiaux's full-sized avatar
💭
Need help?

Stéphane Derosiaux sderosiaux

💭
Need help?
View GitHub Profile
@sderosiaux
sderosiaux / InValueTimestampExtractor.java
Created July 19, 2017 09:19 — forked from nfo/InValueTimestampExtractor.java
Kafka Streams - Custom timestamp extractor, from a `long` field named "timestamp"
/**
* Handle records with a timestamp in their Avro value.
* Expects a LONG field named "timestamp".
* Any problem makes this extractor return the record's internal timestamp.
*/
public class InValueTimestampExtractor implements TimestampExtractor {
@Override
public long extract(ConsumerRecord<Object, Object> record) {
if (record != null && record.value() != null) {
@sderosiaux
sderosiaux / webpack dynamic require.md
Last active January 27, 2016 21:35 — forked from ryanflorence/polyfills.js
Webpack: inject bundle (or polyfills) on the fly
  • promise-loader returns a promise require("promise?bluebird!./file.js")(file => ...);
  • bundle-loader returns a callback require("bundle!./file.js")(file => ...);

Both are using require.ensure() behind the scene.

Manually :

@sderosiaux
sderosiaux / mcft.js
Created January 3, 2016 16:25 — forked from DrBoolean/mcft.js
Monoidal Contravariant Functors and Transducers
const daggy = require('daggy');
const {foldMap} = require('pointfree-fantasy')
const {concat, toUpper, prop, identity, range, compose} = require('ramda');
// Contravariant functors usually have this shape F(a -> ConcreteType).
// In other words, some type holding a function which is parametric on its input, but not output.
// They don't always have that shape, but it's a good intuition
// Covariant functors are what we're used to, which are parametric in their output
//================================================================