Skip to content

Instantly share code, notes, and snippets.

View ecaldwell's full-sized avatar

Evan Caldwell ecaldwell

  • Maxar
  • Silver Spring, MD
View GitHub Profile
@ecaldwell
ecaldwell / smooth-scrolling.html
Created October 10, 2020 14:39
Smooth scrolling with the ArcGIS JS API
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta
name="viewport"
content="initial-scale=1,maximum-scale=1,user-scalable=no"
/>
<title>
Intro to MapView - Create a 2D map | Sample | ArcGIS API for JavaScript
@ecaldwell
ecaldwell / bulk_update_details.py
Created February 12, 2016 19:29
Replace item details for content in ArcGIS Online and Portal for ArcGIS
#!/usr/bin/env python
# Sample Usage
# python bulk_update_details.py -u https://www.arcgis.com -o username -s password -p 'path/to/details.csv'
import argparse
import json
import csv
import requests
@ecaldwell
ecaldwell / publishShapefiles.py
Last active November 18, 2020 22:02
Bulk upload and publish shapefiles to ArcGIS Online
#!/usr/bin/env python
# Sample Usage
# python publishShapefiles.py -u https://www.arcgis.com -o username -s password -p 'path/to/my/shapefiles'
import argparse
import json
import os
import time
import csv
import urllib
import json
service = 'http://services1.arcgis.com/fGahaSQSAcHXfi8G/arcgis/rest/services/Social_Media_Reports/FeatureServer/0'
params = {
'where': '1=1',
'outFields': '*',
'returnGeometry': 'true',
'f': 'json'
@ecaldwell
ecaldwell / package.json
Last active March 22, 2016 14:33
A node script to simulate movement in a point feature service, overlay with a grid feature service, and update both.
{
"dependencies": {
"promise": "^7.0.4",
"request": "^2.65.0",
"terraformer": "^1.0.5",
"terraformer-arcgis-parser": "^1.0.4",
"turf": "^2.0.2"
}
}
@ecaldwell
ecaldwell / disableContextMenu.js
Created July 30, 2013 22:20
Disable the right click context menu
// Disable the right click context menu.
$(document).on("contextmenu", (function() {
return false;
}));
@ecaldwell
ecaldwell / Sieve_of_Eratosthenes.py
Last active September 9, 2016 12:56
Find all primes in a range using the Sieve of Eratosthenes (http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes).
#!/usr/bin/env python
# Find all primes in a range using the Sieve of Eratosthenes.
# http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
def SieveOfEratosthenes(start, stop):
numList = __build__(start, stop)
return __sieve__(numList)
def __build__(start, stop):
numList = []
@ecaldwell
ecaldwell / formatTime
Created May 6, 2013 03:23
Convert time in seconds to a pretty string summary in the format 1 h 5 minutes 10.3 seconds.
#!/usr/bin/env python
def formatTime(s):
'''Converts seconds to a pretty string like 1 h 5 minutes 10.3 seconds.'''
hours, remainder = divmod(s, 3600)
minutes, seconds = divmod(remainder, 60)
timestring = str(seconds) + ' sec'
if minutes > 0:
timestring = str(int(minutes)) + ' min ' + timestring
if hours > 0:
@ecaldwell
ecaldwell / collatz.py
Last active December 15, 2015 14:28
A python script to test the Collatz Conjecture against any number.
## The Collatz Conjecture (http://en.wikipedia.org/wiki/Collatz_conjecture)
## Take any natural number n.
## If n is even, divide it by 2.
## If n is odd multiply it by 3 and add 1.
## Repeat the process indefinitely.
## The conjecture is that, no matter what number you start with, you will always eventually reach 1.
## The property has also been called oneness.
import string