Skip to content

Instantly share code, notes, and snippets.

{"contents":{"launch":{"version":"0.2.0","configurations":[{"type":"node","request":"launch","name":"Mocha All","program":"${workspaceFolder}/node_modules/mocha/bin/_mocha","args":["--timeout","999999","--colors","${workspaceFolder}/test"],"console":"integratedTerminal","internalConsoleOptions":"neverOpen"},{"type":"node","request":"launch","name":"Mocha Current File","program":"${workspaceFolder}/node_modules/mocha/bin/_mocha","args":["--timeout","999999","--colors","${file}"],"console":"integratedTerminal","internalConsoleOptions":"neverOpen"}]}},"overrides":[],"keys":["launch.version","launch.configurations"]}
@ningunaparte
ningunaparte / gist:08499682680b49d20745ca5970e91d8e
Created December 15, 2016 11:30
Devuelve el área de un polígono en javascript
// DEVUELVE EL AREA DE TERMINADO POLIGONO
// http://www.mathopenref.com/coordpolygonarea2.html
function polygonArea(X, Y, numPoints) {
area = 0; // Accumulates area in the loop
j = numPoints - 1; // The last vertex is the 'previous' one to the first
for (i = 0; i < numPoints; i++) {
area = area + (X[j] + X[i]) * (Y[j] - Y[i]);
@ningunaparte
ningunaparte / gist:bdb0e6be3b7f675d66b7f7320c0c8682
Created October 4, 2016 08:38
Formatting numbers with d3
//BASED ON Michael Stanaland’s Block 6106487
//http://bl.ocks.org/mstanaland/6106487
Starting number: 1500
d3.format(",") : 1,500
d3.format(".1f") : 1500.0
@ningunaparte
ningunaparte / README.md
Last active December 14, 2015 12:33 — forked from mbostock/.block
Save SVG as PNG

Say you have an SVG built dynamically on the client by D3. Now say you want to save it to a static PNG as a fallback for old browsers. There are lots of ways to do this using alternative renderers (such as Batik and PhantomJS), but what if you want your browser to do it, so that you the static PNG matches the dynamic SVG exactly, down to the subpixel, including transparency?

Here’s how.

1. Save as SVG.

Use the SVG Crowbar bookmarklet to save the SVG to a file. Call this file “fallback.svg”. Open the SVG in your browser to verify that it looks right.

SVG Crowbar helpfully inlines any stylesheets you may have on the page, but you might find you need to edit a few of the styles by hand to get things to look right. For example, the font-family “sans-serif” won’t work in an SVG image, even though it works when the SVG is built client-side; you’ll have to make the font name explicit, s

@ningunaparte
ningunaparte / README.md
Last active August 29, 2015 14:25 — forked from mbostock/.block
Bubble Chart

Bubble charts encode data in the area of circles. Although less perceptually-accurate than bar charts, they can pack hundreds of values into a small space. Implementation based on work by Jeff Heer. Data shows the Flare class hierarchy, also courtesy Jeff Heer.

@ningunaparte
ningunaparte / onComplete endAll
Last active August 29, 2015 14:23
D3 transition "onComplete"
//Cuando finalizan todas las animaciones ejecuta el callback
function endAll(transition, callback) {
var n = 0;
transition.each(function() { ++n; })
.each('end', function() {
if (!--n) callback.apply(this, arguments);
});
}
@ningunaparte
ningunaparte / d3.locale.ES.js
Created April 22, 2015 14:26
How to format D3.js dates and numbers to spanish - Localizar al español fechas y números
// https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.js
// SAMPLE https://jsfiddle.net/ningunaparte/9gm68vmn/
var nowDate = new Date();
// ES LOCATION
// d3.locale Spanish Spain / Español
// https://github.com/mbostock/d3/wiki/Localization
var es_ES = {