This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { projectionMatrix, viewMatrix } from './turntable-camera' | |
import mouseChange from 'mouse-change' | |
import mouseWheel from 'mouse-wheel' | |
import identity from 'gl-mat4/identity' | |
import key from 'key-pressed' | |
// const isBrowser = typeof window !== 'undefined' | |
const getStartingState = (initialStatePlusOptions) => ({ | |
view: identity(new Float32Array(16)), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import defined from 'defined' | |
const TO_PX = 35.43307 | |
const DEFAULT_SVG_LINE_WIDTH = 0.03 | |
export function shapesToSVG(shapes, opt = {}) { | |
const dimensions = opt.dimensions | |
if (!dimensions) throw new TypeError('must specify dimensions currently') | |
const decimalPlaces = 5 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function wrapTextCanvas(context, text, x, y, maxWidth, lineHeight, drawFlag = true) { | |
const cars = text.split('\n') | |
for (let ii = 0; ii < cars.length; ii++) { | |
let line = '' | |
const words = cars[ii].split(' ') | |
for (let n = 0; n < words.length; n++) { | |
const testLine = line + words[n] + ' ' | |
const metrics = context.measureText(testLine) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// install prot globally https://github.com/mattdesl/prot | |
import React, { Component } from 'react' | |
import ReactDOM from 'react-dom' | |
import { scaleTime } from 'd3-scale' | |
import format from 'd3-time-format' | |
function VerticalLine({ x, height, stroke="#888" }) { | |
return <line | |
x1={x} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in one terminal | |
$ nc -l 9090 | |
# in one another terminal | |
$ curl -X POST -v http://localhost:9090/ -F file=@../../Desktop/test-222.csv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node { | |
constructor(id, prev, isValid) { | |
this.id = id | |
this.prev = prev | |
this.isValid = isValid | |
} | |
disabled() { | |
return this.isValid && (this.prev ? this.prev.disabled() : true) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
FAMOUS MAP FUNCITON FROM PROCESSING.ORG PROGRAMMING LANGUAGE | |
Taken from: https://stackoverflow.com/a/17135426 | |
*/ | |
export function map(value, istart, istop, ostart, ostop) { | |
return ostart + (ostop - ostart) * ((value - istart) / (istop - istart)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
zip2topojson() { | |
NAME=$(basename $1 .zip) | |
OUTPUT="$2" | |
unzip -o $NAME.zip -d $NAME | |
cd $NAME/ | |
[ -f $NAME.geo.json ] && rm $NAME.geo.json | |
ogr2ogr -f GeoJSON -s_srs $NAME.prj -t_srs EPSG:4326 $NAME.geo.json $NAME.shp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function htmlDecode(input) { | |
var doc = new window.DOMParser().parseFromString(input, 'text/html') | |
return unescape(doc.documentElement.textContent) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'draw-triangles-2d' { | |
function draw( | |
context: CanvasRenderingContext2D, | |
positions: Vec3[], | |
cells: Vec2[], | |
start?: number, | |
end?: number, | |
): void | |
export = draw | |
} |