Skip to content

Instantly share code, notes, and snippets.

@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
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<Date>2015-10-27T04:32:20.2209506</Date>
<Author>localhost\Matt</Author>
<Description>Workaround for the capture service halting on suspend/hibernate and resume (https://github.com/codebox/bitmeteros/issues/30). Fires on Startup (30s delay), Logon and Workstation Unlock.</Description>
</RegistrationInfo>
<Triggers>
<SessionStateChangeTrigger>
<Enabled>true</Enabled>
@chimerast
chimerast / e2d3_manifest.xml
Created November 10, 2015 01:42
Manifest file of E2D3 (Id is changed)
<?xml version="1.0" encoding="UTF-8"?>
<OfficeApp xmlns="http://schemas.microsoft.com/office/appforoffice/1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ContentApp">
<Id>00000000-0000-0000-0000-000000000000</Id>
<Version>1.5.0.0</Version>
<ProviderName>e2d3.org</ProviderName>
<DefaultLocale>en-US</DefaultLocale>
<DisplayName DefaultValue="E2D3" />
<Description DefaultValue="Dynamic, interactive, and more interesting graphing from your Excel!" />
<IconUrl DefaultValue="http://e2d3.org/wp-content/uploads/2015/05/logo.png" />
<SupportUrl DefaultValue="http://www.e2d3.org/" />
@maphew
maphew / install-pip.py
Last active December 16, 2015 06:49
A pure python script to download and install the distribute_setup and pip utilities. Tested on Windows 7, Python 3.2.
"""
pip-install.py
A pure python script to download and install the distribute_setup and
pip utilities
Adapted from:
http://stackoverflow.com/questions/4750806/how-to-install-pip-on-windows/15294806#15294806
http://stackoverflow.com/questions/2792650/python3-error-import-error-no-module-name-urllib
http://stackoverflow.com/questions/1093322/how-do-i-check-what-version-of-python-is-running-my-script
@maphew
maphew / Run Elevated.xml
Last active December 18, 2015 05:39
An experimental Leo button which executes the currently selected node as a python script after invoking User Account Control (UAC). Not fully functional yet -- and dangerous. You could easily bork all your data or even your computer with this: it runs code with admin privileges, no sanity checking, and very limited feedback. Tracebacks etc. are …
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by Leo (http://webpages.charter.net/edreamleo/front.html) -->
<?xml-stylesheet ekr_test?>
<leo_file xmlns:leo="http://www.leo-editor.org/2011/leo" >
<leo_header file_format="2"/>
<vnodes>
<v t="maphew.20130607222534.1739" a="E"><vh>@button Run Elevated</vh>
<v t="maphew.20130608014320.1983"><vh>docstring</vh></v>
<v t="maphew.20130608014320.1743"><vh>imports</vh></v>
<v t="maphew.20130608014320.1744"><vh>Leo preparation</vh></v>
@maphew
maphew / Remove-Win10-nag.bat
Last active December 23, 2015 20:47
Implementation of "I Cancelled Microsoft 10 Reservation and uninstalled KB3035583 but Window 10 is still trying to install", http://superuser.com/questions/955444/i-cancelled-microsoft-10-reservation-and-uninstalled-kb3035583-but-window-10-is/
:: --{ Remove-Win10-nag.bat }--
:: http://superuser.com/questions/955444/i-cancelled-microsoft-10-reservation-and-uninstalled-kb3035583-but-window-10-is
:: must be run from elevated command prompt (Run As Administrator)
for %%a in (3035583 3022345 3068708 3075249 3080149 2990214 3012973 2952664 2976978) do (
wusa /uninstall /kb:%%a /norestart /quiet
)
echo Windows Registry Editor Version 5.00 >> "%temp%\disable-win10-upgrade.txt"
echo. >> "%temp%\disable-win10-upgrade.txt"
echo [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade] >> "%temp%\disable-win10-upgrade.txt"
@lpinner
lpinner / setup.py
Last active April 7, 2016 02:28
Simple usercustomize.py to set up separate site.USER_BASE directories for 32 and 64bit python installs on Windows
from setuptools import setup
long_description = '''Simple usercustomize.py to keep separate site.USER_BASE/USER_SITE directories for 32 and 64bit
python installs on Windows.
Only required if you're installing extension modules (compiled pyd/dll) to the user site-packages directory, i.e.:
python setup.py install --user
pip install --user somepackage