Skip to content

Instantly share code, notes, and snippets.

@simlu
simlu / geo-merge-holeless.js
Created Apr 10, 2021
Merge polygons and exclude holeless, self-intersecting polygons
View geo-merge-holeless.js
const assert = require('assert');
const polygon = require('turf-polygon');
const point = require('turf-point');
const { default: distance } = require('@turf/distance');
const { default: union } = require('@turf/union');
const difference = require('@turf/difference');
const merge = (polygons) => polygons.reduce((p, c) => union(p, polygon([c])), polygon([]));
const normalize = (poly, ...holes) => [holes.reduce((p, h) => {
View gist:2f9ebc4cf24e6ceb90fb578a291b3a9c
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
public class T {
private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
private static String bytesToHex(byte[] bytes) {
@simlu
simlu / make-files-unique.js
Created Aug 22, 2018
Make files unique, ignoring different string / number value in object hierarchy
View make-files-unique.js
const fs = require("fs");
const path = require("path");
const get = require("lodash.get");
const set = require("lodash.set");
const objectScan = require("object-scan");
const objectHash = require("object-hash");
const data = Object.entries(fs.readdirSync(path.join(__dirname, "query"))
.map(f => f.slice(0, -5))
.reduce((p, f) => Object.assign(p, {
@simlu
simlu / npm-offline-cache.js
Last active Jul 1, 2018
NPM Offline Cache Experiment
View npm-offline-cache.js
// Unfortunately this doesn't work as expected (NPM is broken as usual)
const os = require("os");
const fs = require("fs");
const path = require("path");
const { execSync, exec } = require('child_process');
const async = require("async");
const objectScan = require("object-scan");
const get = require("lodash.get");
const difference = require("lodash.difference");
View gist:6735d181f0e79a1c87ba32a32620ba77
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"cloudformation:Describe*",
"cloudformation:List*",
"cloudformation:Get*",
"cloudformation:PreviewStackUpdate",
View gist:945b3073a15a378eaa00f2ac9becd016
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"cloudformation:Describe*",
"cloudformation:List*",
"cloudformation:Get*",
"cloudformation:PreviewStackUpdate",