Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@JeffJacobson
JeffJacobson / GetArcGis-Token.ps1
Last active March 30, 2023 20:32
ArcGIS Online / Portal Powershell scripts
class Token {
[string] $token
[System.DateTimeOffset] $expires
Token($response) {
$this.token = $response.token;
$this.expires = [System.DateTimeOffset]::FromUnixTimeMilliseconds($response.expires)
}
}
$rootUri = "https://www.arcgis.com/sharing/rest"
@JeffJacobson
JeffJacobson / Run-PythonUnitTests.ps1
Last active February 23, 2017 16:36
Runs Python unittests against multiple Python environments
<# Runs Python unit tests in multiple environments #>
# Get python.exe paths.
$pyenvs = Get-ChildItem -Path "C:\Python*\" -Filter "python.exe" -Recurse
$pyenvs += Get-ChildItem -Path "C:\Program Files\ArcGIS" -Filter "python.exe" -Recurse
# Build the list of modules that will be tested.
$modules_to_test = [string]::Join(" ", @(
"test_travelerinfo",
"test_armcalc",
@JeffJacobson
JeffJacobson / Clone-SvnToGit.ps1
Last active February 3, 2021 00:38
One-way clone from SVN to Git
<#
.SYNOPSIS
Clones an Subversion repository into a Git repository.
.DESCRIPTION
Clones a Subversion repository into a Git repository, for migrating from Subversion to Git.
This is a scripted version of the processed outlined here:
http://web.archive.org/web/20161107131841/https://git-scm.com/book/en/v2/Git-and-Other-Systems-Migrating-to-Git
.EXAMPLE
PS C:\> .\Clone-SvnToGit.ps1 https://example.com/path/to/svn/myrepo/trunk users.txt
This will clone the SVN repository at the given URL into a git repository folder called "myrepo",
@JeffJacobson
JeffJacobson / ExportToCsv.pyt
Last active October 9, 2017 10:25
ArcGIS conversion: Table View to CSV
import arcpy
import arcpy.da as da
import arcgiscsv
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
.pyt file)."""
self.label = "Export to CSV Toolbox"
self.alias = "csv"
@JeffJacobson
JeffJacobson / Tyr meds.md
Last active May 26, 2017 18:48
Tyr's Medications

Tyr's Medications

Pimobendan (Vetmedin) 1.25 mg tablets

Give 1 tablet (1.25mg) by mouth every 12 hours. This medication is used to increase cardiac contractile ability (inotropy) while also serving as a vasodilator (therefore an 'inodilator').

Clopidogrel 75 mg tablets

@JeffJacobson
JeffJacobson / FileSystemExtensions.cs
Created February 27, 2015 01:40
Utilities for walking through file systems
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
public static class FileSystemExtensions
{
/// <summary>
@JeffJacobson
JeffJacobson / extractattachments.py
Created February 4, 2015 00:06
Extract attachments from a file geodatabase
"""Extracts attachments from a file geodatabase.
"""
import os, re
from os.path import join, exists
from arcpy import da
def extract_attachments(gdb, attachment_dir="images"):
"""Extract attachments from a geodatabase to the filesystem.
"""
attach_table_name_re = re.compile(r"^\w+(?=__ATTACH$)", re.IGNORECASE)
@JeffJacobson
JeffJacobson / pills.md
Last active August 29, 2015 14:12
Pill Organizer

Don't wait until the end of the week to refill the pill organizer.

  • Starting on Tuesday, start refilling the pillbox for the next week.
  • Leave a blank day before the current day to avoid confusion (e.g., forgetting what day it is and taking the next day's dose).

Sunday

Sun. Mon. Tue. Wed. Thu. Fri. Sat.
Take 💊 💊 💊 💊 💊 💊 💊
@JeffJacobson
JeffJacobson / JSON_UDL.xml
Last active August 29, 2015 14:03
Notepad++ User Defined Languages
<NotepadPlus>
<UserLang name="JSON" ext=".json" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments"></Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
@JeffJacobson
JeffJacobson / jsdoc.txt
Created March 27, 2014 17:16
Convert JSDoc property descriptions to C# properties using Regex search & replace in Visual Studio

Property Regex:

^\s*\*\s@property\s{(\w+)}\s(\w+)(?:\s*-\s*)?([^\r\n]+)\s*$

Captures

  1. type name
  2. property name
  3. property description

Replace:

/// $3\npublic $1 $2 { get; set; }