Skip to content

Instantly share code, notes, and snippets.

View fuunnx's full-sized avatar
💭
🤯

Géraud Henrion fuunnx

💭
🤯
View GitHub Profile
import Rx from 'rx'
// sources$
const request$ = new Rx.Subject()
const http = require('http')
const fs = require('fs')
const hostname = '127.0.0.1'
const port = 1337
/*
I have a queue that clients submit tasks to, this backend worker consumes them
firebaseDriver: provides a function that generates a one-element observable of a firebase location
queueConsumerDriver: provides a source of all incoming requests, consumes a sink that takes responses
knows via the uid in the response what channel to send it back on
*/
import {makeFirebaseDriver, makeQueueConsumerDriver} from 'cyclic-fire'
@fuunnx
fuunnx / helper.js
Created September 16, 2016 14:06 — forked from staltz/helper.js
How to use Stanga (https://github.com/milankinen/stanga) as a wrapper, not as a driver
// Generic helper function that takes a main() (the top-level component)
// and wraps it with Stanga logic
function wrapWithStanga(main, initialState) {
return function (sources) {
const modProxy$ = new Subject();
const modelSource = Model(initialState)(modProxy$);
sources.model = modelSource;
const sinks = main(sources);
sinks.model.subscribe(modProxy$);
@fuunnx
fuunnx / webpack.config.js
Created November 6, 2016 18:01 — forked from oxpa/webpack.config.js
webpack configuration suitable for static content generator plugin and chunks
var ReactDom = require("react-dom");
var Redux = require("redux");
var ReactRouter = require("react-router");
var ReactRedux = require("react-redux");
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var window={}
var getElementsByTagName = function (b) {
@fuunnx
fuunnx / esnextbin.md
Last active November 30, 2016 16:47
esnextbin sketch
.Checkbox input {
width: 0;
height: 0;
opacity: 0;
}
.Checkbox input + label {
display: block;
width: 1rem;
height: 1rem;
background: grey;
@fuunnx
fuunnx / component.js
Created July 31, 2017 08:48
flexible-canvas-component
import {addResizeListener} from './resizeListener'
import canvasPixelRatio from './pixelRatio'
export class FlexibleCanvas extends HTMLDivElement {
static get observedAttributes() {return ['width', 'height', 'pixelRatio'] }
createdCallback () {
this.canvas = this.appendChild(document.createElement('canvas')) //eslint-disable-line
this.canvas.setAttribute('style', `
display: block;\
@fuunnx
fuunnx / higherOrderVNodes.ts
Last active January 21, 2020 17:14
Higher order vnodes utility functions
const typeButton = extended({
attrs: {
type: 'button',
},
})
const blueBackground = extended({
style: {
'background-color': 'blue',
'color': 'white',
@fuunnx
fuunnx / 1.driver - DOMdriver.js
Last active October 11, 2017 08:12
Cycle Imperative DOM driver
import fromEvent from 'xstream/extra/fromEvent'
import xs from 'xstream'
export default function jqueryDriver () {
return (instruction$) => {
instruction$.addListener({
next: fn => {
if (typeof fn === 'function') {fn()}
else {fn.call()}
},
@fuunnx
fuunnx / snabbdom+0.7.0.patch
Last active September 4, 2018 07:46
Snabbdom - Shallow copy duplicated vnode on DOME node creation
```sh
mkdir patches
mv snabbdom+0.7.0.patch patches/snabbdom+0.7.0.patch
npm install snabbdom@0.7.0 patch-package@5.1.1 && ./node_modules/.bin/patch-package
```