Skip to content

Instantly share code, notes, and snippets.

View rveciana's full-sized avatar
🐢

Roger Veciana i Rovira rveciana

🐢
View GitHub Profile
@revolunet
revolunet / lzw_encoder.js
Created February 25, 2011 14:55
LZW javascript compress/decompress
// 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];
@ns-1m
ns-1m / leaflet-button-control.js
Created June 15, 2012 09:07 — forked from ejh/leaflet-button-control.js
Leaflet control button example
// How to use it?
// OnAdd() is called when you use:
// var footButton = new L.Control.Button(footButtonOpts).addTo(map);
// It is passed the map object to which your control is being added.
// The third parameter passed to L.DomEvent.addListener is the context ('this' keyword) which
// you wish to have in the callback (second parameter).
// I still don't know how to use it.
@tmcw
tmcw / README.md
Created October 31, 2012 15:25
GIS with Python, Shapely and Fiona Example 2 - Buffers
@christophermanning
christophermanning / README.md
Last active April 24, 2017 17:51
JSTS Polygon Intersection

Created by Christopher Manning

Summary

This is a map of the Chicago Wards that demonstrates how to use the JSTS Topology Suite and D3.js to find and display intersections between polygons.

Wards shaded grey are scanned since their bounding boxes intersect with the search envelope and wards shaded blue intersect with the search

@couchand
couchand / README.md
Last active February 22, 2018 07:53
Better force layout node selection

Object selection is tough, particularly when the things you'd like to select are moving around (like nodes in a force-directed layout, perhaps). Allowing a user the fudge factor of an area cursor helps, but can get in the way when targets are small enough. The use of a Voronoi tessellation promises a map of closest node for any given point.

This example illustrates the use of a Voronoi overlay to clip nodes in a force-directed simulation. By using the Voronoi shapes as the clipping path the nodes themselves can be drawn much simpler.

This builds on these two examples from Mike Bostock on force-directed graphs and voronoi tesselation, as well as Nate Vack's Voronoi selection example here and this first pass at an integration from Christopher Manning.

@pepelsbey
pepelsbey / duplicates.html
Last active June 28, 2019 12:15
Removing duplicates from Liquid array
{% 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: ', ' }}
@Sumbera
Sumbera / L.CanvasOverlay.js
Last active February 3, 2023 09:47
Leaflet Canvas Overlay
/*
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
@jasondavies
jasondavies / README.md
Last active October 29, 2018 11:08 — forked from monsieurBelbo/caba.json
Areas of Clipped Voronoi Regions

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.

@staltz
staltz / introrx.md
Last active July 25, 2024 08:00
The introduction to Reactive Programming you've been missing
@InfoSec812
InfoSec812 / jsonb_patch.sql
Last active July 2, 2024 21:52
Pure PostgreSQL implementation of JSONPatch
!!
!! 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;