Skip to content

Instantly share code, notes, and snippets.

View nickpeihl's full-sized avatar

Nick Peihl nickpeihl

View GitHub Profile
@nickpeihl
nickpeihl / timezones.json
Created April 12, 2023 15:24
Vega clocks time zones PoC (Does not include Daylight saving time!)
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"title": "Timezones (Standard time only!)"
"description": "This does not account for Daylight Savings time.",
"autosize": "pad",
"signals": [
{"name": "centerX", "init": "100/2"},
{"name": "centerY", "init": "100/2"},
{"name": "radiusRef", "init": "min(100,100)*0.8"},
{"name": "sizeFactor", "init": "radiusRef/400"},
@nickpeihl
nickpeihl / spec.json
Last active February 2, 2023 13:45
Vega Address search
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"width": 500,
"padding": 5,
"signals": [
{
"name": "address_input",
"value": "",
"bind": {
"placeholder": "Search for an address",
@nickpeihl
nickpeihl / gist:178b6ab72f575212891b6f9591403170
Created December 15, 2022 19:31
JQ command to convert array of JSON docs to NDJSON for bulk input
`jq -c ' .[] | { index: { _index: "<my-index>"} }, .' < ./<my-file>.json > my-file-bulk.ndjson`
@nickpeihl
nickpeihl / index.js
Last active July 9, 2021 18:02
GBFS to GeoJSON
var gbfs2geojson = require("gbfs2geojson-js");
var fs = require("fs");
var autoDiscoveryUrl =
"https://ckan0.cf.opendata.inter.prod-toronto.ca/dataset/2b44db0d-eea9-442d-b038-79335368ad5a/resource/142dfb32-d81b-474b-811a-dfc47560ac26/download/bike-share-json.json";
var data;
gbfs2geojson.getAllData(autoDiscoveryUrl, data, (data, err) => {
if (err) {
GET _search
{
"query": {
"match_all": {}
}
}
GET openstreetmap-2021.03.10/_mapping
GET openstreetmap-ways/_mapping
@nickpeihl
nickpeihl / custom_patterns
Created March 6, 2021 00:11
Grok expression for OpenStreetMap OPL format
OSMID [n|r|w][0-9]+
NODES (%{OSMID},?)+
MEMBERS (%{OSMID}@(\S+)?,?)+
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Display a map</title>
<meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
<script src="https://api.mapbox.com/mapbox-gl-js/v1.7.0/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v1.7.0/mapbox-gl.css" rel="stylesheet" />
<style>
body {
@nickpeihl
nickpeihl / make.sh
Created August 9, 2019 15:40
Convert file to base64 and store in JSON object
jq -Rs @base64 MYFILENAME | jq "{ data: . }" > myobject.json
@nickpeihl
nickpeihl / README.md
Last active January 18, 2024 19:47
GDAL and Elasticsearch examples

GDAL and Elasticsearch examples

Shapefile

GDAL Shapefile docs

Import shapefile into Elasticsearch

ogr2ogr -f ElasticSearch \
-lco NOT_ANALYZED_FIELDS={ALL} \
http://elastic:changeme@localhost:9200 \
@nickpeihl
nickpeihl / index.js
Last active September 25, 2022 15:58
Fake NGINX access.log
const faker = require('faker');
const moment = require('moment');
const fs = require('fs');
const stream = fs.createWriteStream('./access.log', {
flags: 'a'
});
function writeToStream(n) {
for (; n < 1000000; n++) {