Skip to content

Instantly share code, notes, and snippets.

View gavinr's full-sized avatar

Gavin Rehkemper gavinr

View GitHub Profile
@gavinr
gavinr / example.js
Created July 1, 2022 18:34
for esri blog
view.watch("center", (center) => {
const { latitude, longitude } = center;
centerText = `Center: Lat: ${latitude.toFixed(4)} | Lon: ${longitude.toFixed(4)}`;
});
@gavinr
gavinr / university-city-wards.geojson
Created August 18, 2020 00:14
Ward map of the City of University City, MO
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gavinr
gavinr / arcpy-export-as-image.py
Created July 8, 2020 17:37
Export an image (JPG) from an ArcGIS Pro project
# First create an ArcGIS Pro Project, with at least one template, and put the
# name of it below.
import arcpy
TEMPLATE_NAME = "Square"
aprx = arcpy.mp.ArcGISProject("basic.aprx")
for lyt in aprx.listLayouts():
if lyt.name == TEMPLATE_NAME:
# export!
print(f" {lyt.name} ({lyt.pageHeight} x {lyt.pageWidth} {lyt.pageUnits})")
lyt.exportToJPEG("out.jpg")
@gavinr
gavinr / useful-terminal-commands.md
Created June 23, 2020 14:56
A list of useful terminal commands I've come across over the years.

Subresource Integrity

If you'd like to use Subresource Integrity in your <script ...> tag, to generate the string for a particular JS file:

curl FULL_URL_TO_JS_FILE | openssl dgst -sha384 -binary | openssl base64 -A

For example:

@gavinr
gavinr / user.js
Last active June 27, 2020 02:23
place this in `C:\Users\zzzzzzz\AppData\Roaming\Mozilla\Firefox\Profiles\xxxxxxx\user.js` -- more info http://kb.mozillazine.org/User.js_file
// Most of these from https://restoreprivacy.com/firefox-privacy/ -
user_pref("media.peerconnection.enabled", false); // block WebRTC
user_pref("privacy.resistFingerprinting", true); // help to make Firefox more resistant to browser fingerprinting
user_pref("privacy.trackingprotection.fingerprinting.enabled", true); // [try to] block fingerprinting
user_pref("privacy.trackingprotection.cryptomining.enabled", true); // block cryptominers
user_pref("privacy.trackingprotection.enabled", true); // enable Mozilla’s built-in tracking protection feature
user_pref("privacy.firstparty.isolate", true); // isolate cookies to the first party domain, which prevents tracking across multiple domains
user_pref("network.cookie.cookieBehavior", 1); // Only accept cookies from the originating site (block third-party cookies)
user_pref("network.cookie.lifetimePolicy", 3); // set cookies to only last after N days [below]
user_pref("network.cookie.lifetime.days", 7);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Create a new ArcGIS Python API Environment

First Time

  1. Install conda with Anaconda for Python Distribution. Conda is a python package manager that will install python 3.x and other packages listed in the environment.yml file.
    • Choose the 3.x version
    • Note: Make sure to check "Add to PATH environment variable"
  2. Restart your computer. Because you added conda to the PATH variable, you should be able to use the conda command in any terminal (Windows command prompt, Powershell, etc). Open a terminal and type conda to make sure the conda command is recognized.
  3. In the terminal, navigate to the location of your code repository.
  4. Create a new environment with Conda (more info) > conda env create --name projectname