(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.
(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.
| // LZW-compress a string | |
| function lzw_encode(s) { | |
| var dict = {}; | |
| var data = (s + "").split(""); | |
| var out = []; | |
| var currChar; | |
| var phrase = data[0]; | |
| var code = 256; | |
| for (var i=1; i<data.length; i++) { | |
| currChar=data[i]; |
| /* | |
| UPDATE July 2016 , moved and updated to here: https://github.com/Sumbera/gLayers.Leaflet | |
| Generic Canvas Overlay for leaflet, | |
| Stanislav Sumbera, April , 2014 | |
| - added userDrawFunc that is called when Canvas need to be redrawn | |
| - added few useful params fro userDrawFunc callback | |
| - fixed resize map bug | |
| inspired & portions taken from : https://github.com/Leaflet/Leaflet.heat |
| !! | |
| !! Implementation of JSONPatch (http://jsonpatch.com/) using PostgreSQL >= 9.5 | |
| !! | |
| CREATE OR REPLACE FUNCTION jsonb_copy(JSONB, TEXT[], TEXT[]) RETURNS JSONB AS $$ | |
| DECLARE | |
| retval ALIAS FOR $1; | |
| src_path ALIAS FOR $2; | |
| dst_path ALIAS FOR $3; | |
| tmp_value JSONB; |
| var blob = window.atob("AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAAAAgD8AAAAA"), // Base64 string converted to a char array | |
| fLen = blob.length / Float32Array.BYTES_PER_ELEMENT, // How many floats can be made, but be even | |
| dView = new DataView( new ArrayBuffer(Float32Array.BYTES_PER_ELEMENT) ), // ArrayBuffer/DataView to convert 4 bytes into 1 float. | |
| fAry = new Float32Array(fLen), // Final Output at the correct size | |
| p = 0; // Position | |
| for(var j=0; j < fLen; j++){ | |
| p = j * 4; | |
| dView.setUint8(0,blob.charCodeAt(p)); | |
| dView.setUint8(1,blob.charCodeAt(p+1)); |
| {% assign array = 'c|c|b|b|a|a' | split: '|' %} | |
| {% assign tags = array[1] %} | |
| {% for item in array %} | |
| {% unless tags contains item %} | |
| {% capture tags %}{{ tags }}|{{ item }}{% endcapture %} | |
| {% endunless %} | |
| {% endfor %} | |
| {{ tags | split: '|' | sort | join: ', ' }} |
| license: mit |
A demonstration of how to calculate the areas of Voronoi regions clipped by geographic features using D3.
[D3’s implementation](Sutherland–Hodgman algorithm) of the Sutherland–Hodgman algorithm only works for convex clip polygons, but we exploit the fact that Voronoi regions are guaranteed to be convex, and use each Voronoi region as a clip polygon, with the projected geographic boundary as a subject polygon.
In response to a question by Gonzalo Bellver.
This is companion code to this guide.