- Monad
- Promise
- Observable
- Demo
/* | |
Interface to Shinyei Model PPD42NS Particle Sensor | |
Program by Christopher Nafis | |
Written April 2012 | |
http://www.seeedstudio.com/depot/grove-dust-sensor-p-1050.html | |
http://www.sca-shinyei.com/pdf/PPD42NS.pdf | |
JST Pin 1 (Black Wire) => Arduino GND | |
JST Pin 3 (Red wire) => Arduino 5VDC |
Redux is so popular, and it really can handle component state pretty well, but after working around with large scale project, it seems not as good as it’s promising.
#What’s the problem
##1. Reusability
All reducers is a pure function which is really great, which makes all reducers composible, predictable. However, the switch case statement in reducer ruined all those good parts from pure function.
Switch cases make function multiple purpose, which breaks both single responsibility and open close principle. Breaking the principles means it’s hard to compose and reuse any data flow(tiny reducer) in switch cases.
digraph { | |
node[shape=record] | |
newrank=true; | |
subgraph cluster_level1{ | |
style=dotted; | |
vec2[shape=plaintext] | |
node0[label = "<f0> root |<f1> tail"]; | |
node1[label="<f0>|<f1>"]; | |
node2[label="<f0>|<f1>"]; | |
node3[label="<f0>|<f1>"]; |
require "nokogiri" | |
require "open-uri" | |
url = "https://github.com/#{params['username']}" | |
document = Nokogiri::HTML(open(url)) | |
contrib_boxes = document.css('svg.js-calendar-graph-svg')[0] | |
contrib_boxes['xmlns']="http://www.w3.org/2000/svg" | |
width = (params['width']||54*13-2).to_i | |
height = (params['height']||89).to_i | |
contrib_boxes.css('text').remove | |
contrib_boxes['width']=(width+11).to_s+'px' |
general: | |
branches: | |
only: | |
- master | |
machine: | |
node: | |
version: 5.0.0 | |
dependencies: | |
pre: | |
- npm install -g babel-cli |
we all know orgmode can #+include localfile
, but how we can include a file somewhere on the web, for example gist.
here's how you can embedding a org source from gist and include in your org file.
#+BEGIN_SRC sh :exports results :results raw
curl https://gist.githubusercontent.com/jcouyang/d8086961761f28f35bb9/raw/2c6df28e349ab81ac10e3f6f63d65e20df296729/glist-testing.md
#+END_SRC
require "nokogiri" | |
require "open-uri" | |
url = "https://github.com/#{params['username']}" | |
document = Nokogiri::HTML(open(url)) | |
{ | |
:pop_repos => document.css('.js-pinned-items-reorder-list').to_html, | |
:calendar => document.css('.js-calendar-graph-svg').to_html | |
} |
{"todos":{ | |
"0":{"name":"get milk from corner store","done":false}, | |
"1":{"name":"take a dump","done":true}, | |
"2":{"name":"make someone eat the dump","done":false}, | |
"length":10} | |
} |
macro caseFunc { | |
case {_ ($args...) {$body... $last:expr}} => | |
{ | |
letstx $len = [makeValue(#{$args...}.length , null)]; | |
return #{ | |
case $len: | |
return (function($args...){$body... return $last}).apply(this, arguments) | |
} | |
} | |
} |