Skip to content

Instantly share code, notes, and snippets.

View SKalt's full-sized avatar

Steven Kalt SKalt

View GitHub Profile
@SKalt
SKalt / formatXML.js
Last active April 25, 2017 23:50 — forked from sente/formatXML.js
javascript to format/pretty-print XML
/*
The MIT License (MIT)
Copyright (c) 2016 Stuart Powers
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@SKalt
SKalt / Wfs-T-2-examples.md
Last active June 27, 2024 01:15
WFS-T 2.0.0 example requests

WFS-T 2.0.0 examples

Here I've translated the geoserver Web Feature Service Transactions (WFS-T) 1.0.0 examples into WFS-T 2.0.0 xml. All of these have been verified to work on geoserver 2.11.

Additional resources

action docs examples
delete docs examples
insert docs examples
replace docs example
update docs examples
@SKalt
SKalt / replaceSchemaLocations.js
Last active May 14, 2017 19:45
SchemaLocation replacer
/**
* Correct all schemaLocation paths with new relative or absolute paths to the
* .xsd files.
* @param {String} inputStr a string of an .xsd file to reprocess
* @param {String|Object} dirOrLocations a string directory containing all
* imported/included schemas or an object mapping the current schema filename
* with an optional extension .xsd to a new location
* @returns {String} the xsd file with all schemaLocations replaced with
* corrected relative or absolute paths
* @throws {Error} throws an error if schema location translations are missing
@SKalt
SKalt / pandas_df_to_geojson.py
Last active July 1, 2017 22:14
Aggregating lat, lon points into higher GeoJSON geometries.
"Functions to extract geojson from pandas.DataFrames"
import pandas as pd
import geojson
def to_list(pd_series):
"Shorthand: Coerce a pd.Series to a list of its elements"
return pd_series.tolist()
def make_position(df, lat, lon):
"""
@SKalt
SKalt / Better_mapbox_gl_js_legends.md
Last active July 7, 2017 13:48
Better adaptive mabox-gl.js legends

The mapbox updating choropleth example uses a precomputed legend: both the stops and the colors they correspond to are already written into the webpage. In maps that follow Tobler's law that "everything is related to everything else, but near things are more related than distant things", some regions will contain features that have small but significant differences from each other that are difficult to see on a pre-computed legend. Here are two solutions: change the style and change the legend to match the displayed data (adapt_style and adapt_legend.js, respectively).

@SKalt
SKalt / _0_xml_to_json.md
Last active August 6, 2017 05:03
Functions to transform xml to JSON-able dicts

Lxml's current FAQ includes a method of transforming xml to a dict of dicts, but not JSON. The mismatch between a dict of dicts and JSON occurs when an element has mulitple children with the same tag name. Under JSON conventions, multiple children of the same name are equivalent to an array or tuple. The below python functions attempt to add the repeated tags to list functionality. I'd appreciate suggestions for improvements.

@SKalt
SKalt / get-atom-service-names.js
Created July 3, 2018 19:27
List all available service names in the atom editor
/* global atom */
const allServiceNames = () => {
return atom.packages.serviceHub.providers.map((s) => {
return Object.values(s.servicesByVersion)
.map((v) => Object.keys(v));
}).reduce((acc, red) => acc.concat(...red), []);
}
@SKalt
SKalt / 0_script.sh
Created November 3, 2018 19:24
Run a jupyter lab with json folding viewing
docker run -it -p 8888:8888 -v $(pwd):/home skalt/dev-env
# in container
jupyter labextension install @jupyterlab/json-extension
jupyter lab --ip=0.0.0.0 --port=8888 --allow-root
@SKalt
SKalt / .gitignore
Last active June 9, 2022 13:51
node.js client, python asyncio TCP server connection
__pycache__
node_modules
@SKalt
SKalt / README.md
Last active May 29, 2019 02:55
sci-stack