Skip to content

Instantly share code, notes, and snippets.

Avatar

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,
REQUEST_TYPE varchar,
REQUEST_ORIGIN varchar,
STATUS integer,
DEPARTMENT varchar,
NEIGHBORHOOD varchar,
COUNCIL_DISTRICT integer,
@tjmichael81
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
<#
.SYNOPSIS
PowerShell script to check the status of a Windows service, and start the service if status is 'Stopped'
.DESCRIPTION
PowerShell script to check the status of a Windows service, and start the service if status is 'Stopped'
.PARAMETER <Parameter_Name>
None
@tjmichael81
tjmichael81 / dates.sql
Created Oct 12, 2018
SQL Date Selections
View dates.sql
/** Get date and time stamp for today/now: **/
SELECT GETDATE()
/** Get today's date: **/
SELECT CONVERT(date, GETDATE())
/** Select records with today's date **/
/** Example below using an Esri versioned view **/
SELECT [OBJECTID]
,[DYETESTNUMBER]
@tjmichael81
tjmichael81 / esri_python.py
Last active Mar 27, 2018
Esri Python API Samples
View esri_python.py
#-------------------------------------------------------------
# Boilerplate connection / authentication
#-------------------------------------------------------------
import arcgis
from arcgis.gis import GIS
# Login credentials
url = "<url to agol or portal>"
username = "<user name>"
password = "<password>"
@tjmichael81
tjmichael81 / description.html
Created Aug 9, 2017
ArcGIS Online - Organization Description Tweaks
View description.html
<style>
/**
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
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
# http://www.n2ws.com/how-to-guides/how-to-delete-unutilized-ebs-based-amis-and-corresponding-snapshots.html
# Deleting Snapshots by Using the AWS Tools for Windows PowerShell
# http://docs.aws.amazon.com/storagegateway/latest/userguide/DeletingSnapshotsUsingPowerShell.html
# Adding and Removing Items from a PowerShell Array
@tjmichael81
tjmichael81 / calcFieldWithDict.py
Created Feb 11, 2016
Calculate fields using arcpy.da.UpdateCursor and a dictionary containing values for new fields
View calcFieldWithDict.py
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
tjmichael81 / calculateFieldExampleWithSeparator.py
Created Jan 4, 2016
Use arcpy.CalculateField_management to concatenate two fields with a separator
View calculateFieldExampleWithSeparator.py
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
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("http://169.254.169.254/latest/meta-data/instance-id")
# 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
tjmichael81 / Esri feature row count.py
Last active Oct 13, 2016
Use ArcPy to create a text file with datasets, feature classes, and row counts
View Esri feature row count.py
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):