Skip to content

Instantly share code, notes, and snippets.

View pmacMaps's full-sized avatar

Patrick McKinney pmacMaps

View GitHub Profile
@pmacMaps
pmacMaps / export_ags_portal_site.py
Created April 17, 2024 14:49
Export ArcGIS Server Site & ArcGIS Portal Site Sample Scripts
# see https://developers.arcgis.com/rest/enterprise-administration/portal/export-site.htm
# import modules
from arcgis.gis import GIS
from os import environ
from os import path
from datetime import date
import logging
import sys
import requests
@pmacMaps
pmacMaps / run-ags-enterprise-patch-tool.bat
Created October 14, 2022 17:29
BAT file for checking ArcGIS Enterprise for patches, and installing them. Write messages to a text file for further review.
rem turn off console printing
@echo off
rem set variables for date components (used in log file name)
For /f "tokens=2-4 delims=/ " %%a in ("%DATE%") do (
SET YYYY=%%c
SET MM=%%a
SET DD=%%b
)
@pmacMaps
pmacMaps / download-earthbound-songs.py
Last active May 9, 2022 20:17
Extract mp3 file links and download songs from Earthbound video game
import sys
import requests
import os
from urllib.parse import urlparse
from bs4 import BeautifulSoup
# page containing links to mp3's of songs from Earthbound
music_page_url = 'http://starmen.net/mother2/music/'
# container for mp3 links
mp3_links = []
@pmacMaps
pmacMaps / wild_kratts_race_game_spinner.html
Last active January 13, 2021 15:09
Game Spinner for Wild Kratts Race Around the World Board Game
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Spinner for Wild Kratts Race Around the World Game</title>
<meta name="description" content="A simple spinner app for the Wild Kratts Race Around the World board game.">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:title" content="">
<meta property="og:type" content="">
<meta property="og:url" content="">
@pmacMaps
pmacMaps / shuffle-gis-day-exhibitors.js
Created November 13, 2020 13:30
Function to randomize order of Central PA GIS Day exhibitors
'use strict';
let shuffleArray = array => {
let m = array.length, t, i;
// While there remain elements to shuffle
while (m) {
// Pick a remaining element…
i = Math.floor(Math.random() * m--);
@pmacMaps
pmacMaps / clip_layers_by_other_layers.py
Created June 24, 2020 15:26
Function and demo to Use ArcPy Search Cursors to loop through a layer and clip other layers by each feature in that layer
# Note: this script is designed to run with Python 3 and ArcGIS Pro ArcPy
# import modules
# arcpy => provides access to Esri ArcGIS Pro
# os => provides convient way to construct file paths
# sys => provides way to capture errors
# re => used for snake case helper function (taken from https://www.30secondsofcode.org/python/s/snake)
import arcpy, os, sys
from re import sub
@pmacMaps
pmacMaps / combine_road_component_fields_esri_arcade.js
Created March 11, 2020 17:27
An Esri Arcade expression for labeling features or map pop-ups that combines various road street name component fields into a single value.
// This is an Esri Arcade expression for labeling features or map pop-ups that combines various road street name component fields into a single value.
// It tests for empty values in the record. If the value is empty, it returns an empty string ('').
// If the value is not empty, it returns the value of the record.
// See https://developers.arcgis.com/arcade/ for more information on Arcade
// See https://www.nena.org/page/NG911GISDataModel for more information on NENA NextGen911 data model
// Example road: North Main Street
// variable to hold the contents of the label for roads
var road_label = "";
@pmacMaps
pmacMaps / esri-mapseries-alt-text-enhancement
Last active November 20, 2019 15:02
Solution to add alt text attribute to pop-ups with images for the Map Series StoryMap template. This assumes the layer with pop-up is in each web map within app
// this represents with "custom-scripts.js" file located within the "app" directory of appliation files
define(["dojo/topic"], function(topic) {
/*
* Custom Javascript to be executed while the application is initializing goes here
*/
// The application is ready
topic.subscribe("tpl-ready", function(){
/*
* Custom Javascript to be executed when the application is ready goes here
@pmacMaps
pmacMaps / esri-storymap-map-tour-alt-text-ie11.js
Created October 22, 2019 15:38
Add Alt Attribute to Images in Esri Map Tour StoryMap (Classic Series). Code is supported in IE11
require(["dojo/topic"], function(topic) {
// default alt text to apply to images
const defaultAltText = 'a view along the Yellow Breeches Creek';
// function to set alt attribute for images
function setAltText(title,img) {
// use grouped text if slide title text exists
if (title) {
// grouped text
const groupedAltText = "".concat(defaultAltText, "; map tour stop: ").concat(title);
@pmacMaps
pmacMaps / esri-storymap-map-tour-alt-text.js
Last active October 22, 2019 15:41
Add Alt Attribute to Images in Esri Map Tour StoryMap (Classic Series)
require(["dojo/topic"], function(topic) {
// default alt text to apply to images
const defaultAltText = 'a view along the Yellow Breeches Creek';
// function to set alt attribute for images
function setAltText(title,img) {
// use grouped text if slide title text exists
if (title) {
// grouped text
const groupedAltText = `${defaultAltText}; map tour stop: ${title}`;