Skip to content

Instantly share code, notes, and snippets.

Avatar
🦆
converting JSON to other JSON

Paul Murray plmrry

🦆
converting JSON to other JSON
View GitHub Profile
@plmrry
plmrry / proj4toD3.js
Last active Jun 4, 2021
proj4 to D3 projection
View proj4toD3.js
function radiansToDegrees(radians) {
return (radians * 180) / Math.PI;
}
function degreesToRadians(degrees) {
return degrees * (Math.PI / 180);
}
function proj4toD3(proj4String) {
const proj4 = require("proj4");
@plmrry
plmrry / fetchGeoJSON.js
Created Jun 4, 2021
Fetch shapefile, create GeoJSON
View fetchGeoJSON.js
const fetch = require("node-fetch");
const jszip = require("jszip");
const shapefile = require("shapefile");
async function fetchGeoJSON(endpoint) {
console.log(`🐞 Endpoint: ${endpoint}`);
console.log(`🐞 Fetching..`);
const res = await fetch(endpoint);
const buffer = await res.buffer();
console.log(`🐞 Un-zipping...`);
@plmrry
plmrry / README.md
Last active Oct 18, 2018
Line Hovering With Point Sampling
View README.md

Voronoi diagrams are often used to highlight nearby points based on mouse position.

However, the Voronoi will not always work as intended when working with paths.

Try hovering over the middle of the red path — although the mouse is closer to the red path, the blue line is highlighted.

We can fix this problem by sampling points along the path (similar to the technique used here), and adding these sampled points to the Voronoi mesh.

@plmrry
plmrry / iap_node.js
Last active Jul 28, 2020
Node.js GCP IAP Service Account Authentication
View iap_node.js
const request = require('request');
const jws = require('jws');
const OAUTH_TOKEN_URI = 'https://www.googleapis.com/oauth2/v4/token';
const APP_HOST = process.env.APP_HOST;
const APP_URI = `https://${APP_HOST}`;
const creds = require('./service_account');
var iat = Math.floor(new Date().getTime() / 1000);
@plmrry
plmrry / .block
Last active May 17, 2017
Tracking 3D Coordinates
View .block
license: mit
@plmrry
plmrry / stupid.ts
Created Jan 10, 2017
Stupid stream
View stupid.ts
class Stream<T> {
constructor(private start: Start<T>) {}
listen(next: Listener<T>) { this.start(next) }
}
class Stream<T> {
constructor(private start: Start<T>) {}
compose<U>(fn: (stream: Stream<T>) => Stream<U>): Stream<U> {
return fn(this);
}
@plmrry
plmrry / docker-compose.yml
Created Jan 10, 2017
Basic node/mongo Docker compose file
View docker-compose.yml
version: '2.1'
services:
node:
build: .
env_file: .env
working_dir: /usr/src/app
volumes:
- ./:/usr/src/app
depends_on:
- mongo
@plmrry
plmrry / capture.js
Created Oct 27, 2016
Capture XHR Requests
View capture.js
(function() {
var XHR = XMLHttpRequest.prototype;
var open = XHR.open;
var send = XHR.send;
XHR.open = function(method, url) {
requests.push(this);
this._method = method;
this._url = url;
return open.apply(this, arguments);
@plmrry
plmrry / .gitignore
Last active Sep 30, 2016
Sequential Tests with Tape and Bash
View .gitignore
node_modules
@plmrry
plmrry / .block
Last active May 17, 2017
Collision Radius Transition
View .block
license: gpl-3.0