I was playing around with functional and reactive programming in Javascript, and the UI framework Cycle.js. In order to better understand how that framework works, I pared down the core functionality to a single concept: given a function that takes in an input stream and returns an output stream, resolve the circular dependency of feeding its output back into itself as input. I also built a naive re-implementation of the core Cycle.run
command on top of that.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<element name="cs-component"> | |
<template> | |
I am a {{ language }} component | |
</template> | |
<script type="text/coffeescript"> | |
Polymer.register @, | |
language: "CoffeeScript" | |
ready: -> | |
console.log "READY", @ | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var SerialPort = require('serialport').SerialPort; | |
var xbee_api = require('xbee-api'); | |
var C = xbee_api.constants; | |
var Q = require('q'); | |
// following settings work for me on my Raspberry pi, your config may differ! | |
var xbeeAPI = new xbee_api.XBeeAPI({ | |
api_mode: 1 | |
}); | |
var serialport = new SerialPort("/dev/ttyAMA0", { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#install esseintal packages for opencv | |
apt-get -y install build-essential | |
apt-get -y install cmake | |
apt-get -y install pkg-config | |
apt-get -y install libgtk2.0-dev libgtk2.0 | |
apt-get -y install zlib1g-dev | |
apt-get -y install libpng-dev | |
apt-get -y install libjpeg-dev | |
apt-get -y install libtiff-dev | |
apt-get -y install libjasper-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ParentStream from "workerstream/parent"; | |
global.stream = ParentStream(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Limit the rate of flow to an event every 250ms: | |
// const stream$ = other$.thru(limitFlow(250)); | |
export function limitFlow(period) { | |
return function limitFlow(stream) { | |
const source = new RateLimitSource(stream.source, period); | |
return new stream.constructor(source); | |
}; | |
} |
First experiments with NodeMCU to publish the current settings of my adjustable height working desk to MQTT.
NodeMCU can be found here: https://github.com/nodemcu/nodemcu-firmware
Note that you'll need a current version with support for floats (which the ultrasonic sensor library utilizes), I'm using 0.9.5 2015-03-18 with float support myself.
Support for the HC-SR04 sensor in NodeMCU can be found here: https://github.com/sza2/node_hcsr04
I provided my slightly adjusted version which makes measuring a non-blocking afair, allowing for callbacks when the measurement completes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
/* | |
* Webpack 2 loader that can take CommonJS output by psc 0.9.1 and convert | |
* it into tree shakable ES6 modules. No transpiling required. | |
*/ | |
const fs = require('fs') | |
const commonJsRequire = /var ([$\w]+) = require\("(.*)"\)/g | |
const moduleExports = /module\.exports = \{(\n( ([$\w]+): ([$\w]+)(, )?\n)*)?\};/m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
## | |
## Parse metadata variables from a markdown file. | |
## | |
## The key-values are returned as field-deliminated lines to | |
## stdout, or, as a variable string that can be passed to pandoc | |
## as command-line parameters. | |
## | |
## Delcare metadata in the markdown file using the format: | |
## % meta keyname1="value1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original tweet size in JSON 2624 Msgpack = 1817 Gzip + Json = 1058 Gzip + Msgpack = 1116 LZ4 + Json = 1628 LZ4 + Msgpack = 1361 | |
Original tweet size in JSON 1863 Msgpack = 1443 Gzip + Json = 0783 Gzip + Msgpack = 0835 LZ4 + Json = 1153 LZ4 + Msgpack = 1040 | |
Original tweet size in JSON 2074 Msgpack = 1670 Gzip + Json = 0842 Gzip + Msgpack = 0894 LZ4 + Json = 1229 LZ4 + Msgpack = 1139 | |
Original tweet size in JSON 2025 Msgpack = 1617 Gzip + Json = 0845 Gzip + Msgpack = 0895 LZ4 + Json = 1238 LZ4 + Msgpack = 1143 | |
Original tweet size in JSON 2069 Msgpack = 1663 Gzip + Json = 0846 Gzip + Msgpack = 0901 LZ4 + Json = 1243 LZ4 + Msgpack = 1164 | |
Original tweet size in JSON 2035 Msgpack = 1634 Gzip + Json = 0852 Gzip + Msgpack = 0907 LZ4 + Json = 1247 LZ4 + Msgpack = 1167 | |
Original tweet size in JSON 1988 Msgpack = 1464 Gzip + Json = 0804 Gzip + Msgpack = 0862 LZ4 + Json = 1220 LZ4 + Msgpack = 1061 | |
Original tweet size in JSON 1910 Msgpack = 1502 Gzip + Json = 0775 Gzip + Msgpack = 0832 LZ4 + Json = 1154 LZ4 + Msgpack = 1060 |
OlderNewer