Skip to content

Instantly share code, notes, and snippets.

View rgwozdz's full-sized avatar

Rich Gwozdz rgwozdz

  • Esri
  • Bellingham, WA
View GitHub Profile
@rgwozdz
rgwozdz / geotrellis-cell-value.scala
Created July 27, 2017 15:32
sketch of getting cell values from geotrellis
val crs_coord_1 = ???
val crs_coord_2 = ???
// you first want to create a Raster
// assuming your rdd is a single tile representing the whole image, i.e. rdd.count == 1
val first = rdd.take(1)
val projExtent = first(0)._1
val tile = first(0)._2
// rgwozdz: My rdd isn't a single tile. On ingest my layer is tiled
// across zooms 0 - 6. Should I be reading a particular zoom level?
@rgwozdz
rgwozdz / tim-date.sql
Created September 1, 2017 20:41
Compare timestamp to date in Postgres
SELECT *
FROM table
WHERE update_date >= '2013-05-03'::date
AND update_date < ('2013-05-03'::date + '1 day'::interval);
@rgwozdz
rgwozdz / gist:9ac5ec00e826fa00587fe6384c83abd1
Created September 19, 2017 16:43
Find 10 largest files
#Type the following command at the shell prompt to find out top 10 largest file/directories:
du -a / | sort -n -r | head -n 10
@rgwozdz
rgwozdz / binary-search.js
Last active December 20, 2017 16:37
binary-search
/**
* Performs a binary search on the provided *sorted* list and returns the index of the item if found. If it can't be found it'll return -1.
*
* @param {*[]} sorted (ascending) list Items to search through.
* @param {*} item The item-value to look for.
* @return {Number} The index of the item if found, -1 if not.
*/
function binarySearch(list, searchValue) {
var minIndex = 0;
var maxIndex = list.length - 1;
@rgwozdz
rgwozdz / bubble-sort.js
Created December 20, 2017 16:28
bubble-sort with notes
function bubbleSort(arr){
// Get Array length
var len = arr.length;
// Create and outer-loop with a decrementing index i
for (var i = len-1; i>=0; i--){
// Create and inner-loop with incrementing index j that has a max index i
// So, the first time the innerloop cycles, it will loop a number of times equal to the array length.
// The next cycle it will be one less, and so forth
@rgwozdz
rgwozdz / parse-string-array.js
Created April 11, 2018 12:47
Parse a comma delimited list of arrays to an enclosing array
let geom = {"Polygon_Geometry": ["[-117.10, 34.20],[-117.19, 34.05],[-118.19, 34.20],[-117.10, 34.20]"]}
let json = `[${geom.Polygon_Geometry[0]}]`;
console.log(JSON.parse(json))
@rgwozdz
rgwozdz / provider-metadata.js
Last active May 30, 2018 17:41
Koop Provider metadata
metadata: {
name: String, // The name of the layer
description: String, // The description of the layer
extent: Array, // valid extent array e.g. [[180,90],[-180,-90]]
displayField: String, // The display field to be used by a client
geometryType: String // REQUIRED if no features are returned with this object Point || MultiPoint || LineString || MultiLineString || Polygon || MultiPolygon
idField: Integer || String, // unique identifier field,
maxRecordCount: Number, // the maximum number of features a provider can return at once
limitExceeded: Boolean, // whether or not the server has limited the features returned
timeInfo: Object // describes the time extent and capabilities of the layer,
@rgwozdz
rgwozdz / AGOL-secured-service.md
Last active April 24, 2018 14:54
Network details for AGOL secured service authentication and authorization

Network details during a AGOL session for adding a "secured item" to Content

1. ArcGIS checks resource server URL to see if its secure

Request GET https://www.arcgis.com/sharing/rest/portals/checkurl

GET params:

{ 
 url: https:///rest/services/Hosted/cb_2017_us_state_500k/FeatureServer?f=json
@rgwozdz
rgwozdz / trees-koopinfo.json
Last active April 30, 2018 20:19
trees-koopinfo
{
"_indexFields": false,
"retrieved_at": 1524775095476,
"failedLastImport": false,
"lastImportCompleted": 1524775109941,
"version": 3,
"fullFile": "files\/593b88391b614123890f54a1db8fbf55_0\/full\/593b88391b614123890f54a1db8fbf55_0.txt",
"type": "Feature Service",
"status": "Cached",
"generating": {
@rgwozdz
rgwozdz / census-koopinfo.json
Created April 30, 2018 20:18
census-koopinfo
{
"info": {
"_indexFields": false,
"_indexGeometry": false,
"url": "https:\/\/tigerweb.geo.census.gov\/arcgis\/rest\/services\/Census2010\/Tracts_Blocks\/MapServer",
"_indexGeohash": false,
"itemModified": 1500480948000,
"version": 3,
"itemTitle": "2010 Census Population & Housing Unit Counts",
"type": "Feature Service"