Skip to content

Instantly share code, notes, and snippets.


Timothy Michael tjmichael81

View GitHub Profile
View clouddatastoreblog.sql
-- Create table for PGH 311 requests
create table if not exists pgh_311_requests (
REQUEST_ID integer,
CREATED_ON varchar,
STATUS integer,
tjmichael81 / QBServiceChecker.ps1
Last active Oct 26, 2018
Basic PowerShell script to check the status of a Windows service, and start the service if the status is 'Stopped'
View QBServiceChecker.ps1
#requires -version 2
PowerShell script to check the status of a Windows service, and start the service if status is 'Stopped'
PowerShell script to check the status of a Windows service, and start the service if status is 'Stopped'
.PARAMETER <Parameter_Name>
tjmichael81 / dates.sql
Created Oct 12, 2018
SQL Date Selections
View dates.sql
/** Get date and time stamp for today/now: **/
/** Get today's date: **/
/** Select records with today's date **/
/** Example below using an Esri versioned view **/
tjmichael81 /
Last active Mar 27, 2018
Esri Python API Samples
# Boilerplate connection / authentication
import arcgis
from arcgis.gis import GIS
# Login credentials
url = "<url to agol or portal>"
username = "<user name>"
password = "<password>"
tjmichael81 / description.html
Created Aug 9, 2017
ArcGIS Online - Organization Description Tweaks
View description.html
Move the position of the Featured Maps container. With a banner image that is 472px high, a 25px margin will move the container toward the bottom of the image.
A 100px margin will add additional area below the banner image.
#featuredMaps {
margin-top: 25px;
tjmichael81 / Delete ami and snapshots.ps1
Last active Oct 2, 2022
Use a date search to find and delete AWS AMI's and their corresponding disk snapshots
View Delete ami and snapshots.ps1
### Resources: ###
# How-To Delete Unutilized EBS-Based AMIs And Corresponding Snapshots
# Deleting Snapshots by Using the AWS Tools for Windows PowerShell
# Adding and Removing Items from a PowerShell Array
tjmichael81 /
Created Feb 11, 2016
Calculate fields using arcpy.da.UpdateCursor and a dictionary containing values for new fields
import arcpy
gridID_dict = {1:'A1', 2:'A2', 3:'A3', 4:'A4',
5:'B1', 6:'B2', 7:'B3', 8:'B4',
9:'C1', 10:'C2', 11:'C3', 12:'C4',
13:'D1', 14:'D2', 15:'D3', 16:'D4'}
fc = r'<path to file>'
# Fields will need to be updated with fields from source
fields = ['OID@', 'br2PolyID', 'ID']
tjmichael81 /
Created Jan 4, 2016
Use arcpy.CalculateField_management to concatenate two fields with a separator
import arcpy
fc = '<path to fc or table>'
field_CommonName = 'Field_CommonName'
field_BotanicalName = 'Field_BotanicalName'
# Takeaway - enclose the entire expression in quotes, don't do this:
# commonNameExpression = !Field_Name! + ' - ' + !Current_Crop_2013!
commonNameExpression = "!Field_Name! + ' - ' + !Current_Crop_2013!"
tjmichael81 / aws_createsnapshots.ps1
Last active Oct 16, 2015
Create snapshots for each volume attached to an instance
View aws_createsnapshots.ps1
# Retrieve instance ID from EC2 Instance Metadata
$instanceID = (New-Object System.Net.WebClient).DownloadString("")
# Retrieve volumes that are attached to this instance
$volumes = Get-EC2Volume -Filter @{Name = "attachment.instance-id"; Value = $instanceID}
# Create a snapshot for each volume in the collection
foreach ($volume in $volumes){
$volID = $volume.VolumeId
$diskSnapshot = New-EC2Snapshot -VolumeId $volume.VolumeId -Description "Snapshot of $volID from $instanceID"
tjmichael81 / Esri feature row
Last active Oct 13, 2016
Use ArcPy to create a text file with datasets, feature classes, and row counts
View Esri feature row
import arcpy
arcpy.env.workspace = r"C:\TEMP\LocalGovernment.gdb"
outFile = open(r"C:\TEMP\dbinventory.txt", "a")
dsList = arcpy.ListDatasets(feature_type="feature")
for ds in dsList:
outFile.write("Dataset: {0}{1}".format(ds, "\n"))
for fc in arcpy.ListFeatureClasses(feature_dataset=ds):