(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| 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", { |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| export class EnumSymbol { | |
| sym = Symbol.for(name); | |
| value: number; | |
| description: string; | |
| constructor(name: string, {value, description}) { | |
| if(!Object.is(value, undefined)) this.value = value; | |
| if(description) this.description = description; |
| var mqtt = require('mqtt') | |
| // Make sure to change this to the IP address of your MQTT server | |
| , host = '192.168.128.204' // or localhost | |
| client = mqtt.createClient(1883, host, {keepalive: 10000}); | |
| // Subscribe to the temperature topic | |
| client.subscribe('temperature'); | |
| // When a temperature is published, it will show up here | |
| client.on('message', function (topic, message) { |
These macros are designed to provide a literal notation for [immutable-js][1] using [sweetjs][2].
The most interesting being the Map literal
var map = im{"foo": "bar", "baz": "quux"};This compiles to the 2d array version of Immutable.Map.
This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.
A file below this one contains the steps for doing this with Travis CI. However, these days I recommend GitHub Actions, for the following reasons:
While this gist has been shared and followed for years, I regret not giving more background. It was originally a gist for the engineering org I was in, not a "general suggestion" for any React app.
Typically I avoid folders altogether. Heck, I even avoid new files. If I can build an app with one 2000 line file I will. New files and folders are a pain.
| var Bar1 = base => class extends base { | |
| componentWillMount(){ | |
| super.componentWillMount(); | |
| console.log('Bar1'); | |
| } | |
| }; | |
| var Bar2 = base => class extends base { | |
| componentWillMount(){ | |
| super.componentWillMount(); |
| import ParentStream from "workerstream/parent"; | |
| global.stream = ParentStream(); |
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.