Skip to content

Instantly share code, notes, and snippets.

@oevans
oevans / AGO_PullHostedFeatures.py
Last active April 16, 2024 18:37
Python script to pull hosted features with attachments into a local file geodatabase. See ReadMe below.
import os, urllib, urllib2, datetime, arcpy, json
## ============================================================================== ##
## function to update a field - basically converts longs to dates for date fields ##
## since json has dates as a long (milliseconds since unix epoch) and geodb wants ##
## a proper date, not a long.
## ============================================================================== ##
def updateValue(row,field_to_update,value):
outputfield=next((f for f in fields if f.name ==field_to_update),None) #find the output field
@mkropat
mkropat / knownpaths.py
Last active February 4, 2025 17:31
Python wrapper around the SHGetKnownFolderPath Windows Shell function
import ctypes, sys
from ctypes import windll, wintypes
from uuid import UUID
class GUID(ctypes.Structure): # [1]
_fields_ = [
("Data1", wintypes.DWORD),
("Data2", wintypes.WORD),
("Data3", wintypes.WORD),
("Data4", wintypes.BYTE * 8)
@joyrexus
joyrexus / README.md
Last active November 26, 2018 16:48
Map a stream of tweets from location

Map tweets from a place

This is a very simple node-based client demonstrating how you can use the Twitter streaming API with the locations parameter specified. It uses geojson.io to map any tweets it hears within a user-specified duration.

Setup

Before running the map.coffee script, place your app's OAuth keys in keys.json and run npm install to install dependencies (viz., ntwitter and opener).

@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active March 31, 2025 09:20
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@stuart11n
stuart11n / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@MagicAndi
MagicAndi / Install-Programs
Created April 22, 2014 21:18
A Chocolatey PowerShell script to install programs to a newly paved Windows 8 machine, including development tools. Based on a gist from @amogram (https://gist.github.com/amogram/8217460)
# ==========================================================================
#
# Script Name: Install-Programs.ps1
#
# Author: Andy Parkhill
#
# Date Created: 27/03/2014
#
# Description: A simple environment setup script for my personal laptop.
#
@maphew
maphew / generateQDS.ps1
Last active January 25, 2022 22:02
Generates a Query Directory Service file which runs a search for the %USERNAME% environment variable in the Windows integrated search tool. Adapted from "How to generate a QDS files which runs a user or group search" by FS76. In support of http://community.spiceworks.com/topic/278782-allow-users-to-update-their-own-information-in-active-directory
cls
# Author: Frank Schneider
# Date: 2015-04-20
# Version:1.0
# Synopsis:
# this sample script generates a QDS file which runs a search for the
# string "Domain Users" in the Windows integrated search tool.
# https://gallery.technet.microsoft.com/scriptcenter/How-to-generate-a-QDS-05fe4ff5
@maphew
maphew / setenv.bat
Last active August 29, 2015 14:20
A pattern I find myself repeating a lot: "Test if program is in path, attempt to extend path, list available commands in .\bin." The example here is for LAS Tools, but really it could be anything.
@echo off
:: Test if Lastools are in path, if not extend path and try again.
:: we assume desired tool folder is ".\bin" relative to the batch file
lasinfo -i >nul 2>&1
if %errorlevel%==9009 set path=%~dp0\bin;%path%
lasinfo -i >nul 2>&1
if not "%errorlevel%"=="1" goto :NoTools
call :ShowCommands
@maphew
maphew / run.bat
Last active August 29, 2015 14:21
Print the command line to screen and then execute it. Useful when you want to have echo turned off everywhere else, and not speckle code with `echo on && {cmd line here} && @echo off`
@echo off
:: --- Run.bat ---
:: Echo the command line to screen and then execute it.
::
:: Useful when you want to have echo turned off everywhere else,
:: and not speckle code with `echo on && {cmd line here} && @echo off`
if "%*"=="" goto :Usage
setlocal
echo === Run =================
set _cmd=%*
@maphew
maphew / Raster Toolbox.pyt
Last active August 29, 2015 14:22
Automatically crop a raster to the minimum bounding rectangle of actual data values, by @lpinner following @whuber advice at http://gis.stackexchange.com/questions/45159/finding-minimum-bounding-extent-of-given-pixel-value-within-raster
import arcpy
class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
.pyt file)."""
self.label = "Raster Toolbox"
self.alias = ""
# List of tool classes associated with this toolbox