Skip to content

Instantly share code, notes, and snippets.

debug = True
try:
their_md5 = 'c38f03d2b7160f891fc36ec776ca4685'
my_md5 = 'c64e53bbb108a1c65e31eb4d1bb8e3b7'
if their_md5 != my_md5:
raise ValueError('md5 sum does not match!')
except:
if debug:
# ==========================================================================
#
# 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 / gist:80ddc91daa44424cf951
Created February 27, 2015 16:45
simple ArcInfo GENERATE file
//Polygon
1, 0
253563.7471, 1327293.189, None, None
203563.7471, 1327293.189, None, None
203563.7471, 1377293.189, None, None
253563.7471, 1377293.189, None, None
253563.7471, 1327293.189, None, None
END
END
Python 2.7.4 (default, Apr 6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> my_list = 'one two tee'.split()
>>>
>>> my_list
['one', 'two', 'tee']
>>>
>>> [print x for x in my_list]
File "<stdin>", line 1
import sys
from osgeo import ogr
def main(in_file, in_format, out_file, out_format):
in_ds = ogr.GetDriverByName(in_format).Open(in_file)
out_ds = ogr.GetDriverByName(out_format).CopyDataSource(in_ds, out_file)
if __name__ == '__main__':
main(*sys.argv[1:])
Scaled_Residual,X,Y,Local_Std_Error,Vertical_Std_Error,Unscaled_Residual
97,314430.000,1605270.000,3048.00,3064.27,16.27
75,314550.000,1605270.000,3048.00,3064.27,16.27
33,314490.000,1605270.000,3048.00,3064.27,16.27
12,250410.000,1659810.000,3044.74,3047.10,2.36
12,244410.000,1670550.000,3035.15,3036.42,1.27
12,336090.000,1601070.000,13.61,14.79,1.18
-8,205650.000,1649130.000,32000.00,29985.86,-2014.14
-8,213690.000,1624110.000102000.00100047.75,-1952.25
@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