Skip to content

Instantly share code, notes, and snippets.

maphew /
Created Feb 1, 2021
Figuring out how to generate an H3 hex grid from a given poly layer, in Qgis python processing environment.
# adapted from
import os
from qgis.utils import iface
from qgis.core import (
QgsFeature, QgsField, QgsFields,
QgsGeometry, QgsPointXY, QgsProject,
QgsProcessingFeedback, QgsMessageLog,
maphew /
Created Nov 13, 2020
Yukon NTS Index in various formats
'''Print Yukon NTS tile names as html table with links, arranged in same order as they appear in a map index.
License: X/MIT
nts_txt_ordered = '''117C 117D
117B 117A
116NO 116P
116JK 116I 106L 106K
maphew / outlook-taskboard-config.json
Created Sep 22, 2020
Outlook-taskboard config with To-Do flagged emails enabled and shown in BACKLOG lane
View outlook-taskboard-config.json
"ACTIVE": true,
"NAME": "",
"SORT": "-priority,duedate,categoryNames,subject",
"OWNER": false,
"PERCENT": false,
maphew / History Tracer.xml
Last active Jul 11, 2020
WIP: management scripts for History Tracer plugin for Leo
View History Tracer.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by Leo: -->
<leo_file xmlns:leo="" >
<leo_header file_format="2"/>
<v t="mhw.20200710235109.1"><vh>History Tracer</vh>
<v t="mhw.20200308223025.1"><vh>@int history-tracer-port=8088</vh></v>
<v t="mhw.20200710235122.1"><vh>@button leo-ver-serv-start</vh></v>
<v t="mhw.20200710235134.1"><vh>@button leo-ver-serv-list</vh></v>
<v t="mhw.20200710235410.1"><vh>@button leo-ver-serv-stop</vh></v>
maphew /
Last active Mar 17, 2020
Leo scripts to manage History Tracer plugin daemon

An edited excerpt from the console which started Leo

don't forget to launch leo-ver-serv!!!
==== @int history-tracer-port=8088 ====
Looking for 'leo-ver-serv' processes...
   PID   Name                   Status    
  3815   leo-ver-serv           sleeping  

This is just after Leo startup.

maphew /
Last active Mar 11, 2020
What is your "import arcpy" overhead?
'''Measure and report the time it takes to simply `import arcpy`
Part of
from timeit import default_timer as timer
start = timer()
from datetime import datetime, timedelta
from uuid import uuid4
eventid ='%Y%m-%d%H-%M%S-') + str(uuid4())
maphew /
Last active Nov 19, 2019
Git shallow clone: only branches with recent activity, as determined by Github
# from
export URL=
curl $URL > x.html
printf '\n-- Commands to add the remote branches to the fetch list:\n'
grep 'data-branch-name' x.html | sed -r 's/^.*data-branch-name="(.*?)"(.*$)/git remote set-branches --add origin \1/'
printf '\n-- Modification dates for these branches:\n'
grep 'time-ago' x.html | sed -r 's/^.*datetime="(....-..-..).*$/\1/'
maphew /
Last active Sep 7, 2019
Windows user "special folders" (Desktop, Start Menu, Documents, ...) info by enumerating constants from MS published list
'''List all User Shell Folders via ID number.
An alternative to the usual
objShell = win32com.client.Dispatch("WScript.Shell")
allUserProgramsMenu = objShell.SpecialFolders("AllUsersPrograms")
because "These special folders do not work in all language locales, a preferred
method is to query the value from User Shell folders"
maphew /
Created Aug 28, 2019
Windows python snippets
def get_exe_types():
'''Return list of valid executable file extensions [.com, .exe, ...]'''
exetypes = [ext.lower() for ext in os.environ['PATHEXT'].split(os.pathsep)]
return exetypes
View pip-uninstall-error-01.txt
$ pip uninstall shortcutter
Uninstalling shortcutter-0.1.20:
Would remove:
c:\users\me\appdata\roaming\microsoft\windows\start menu\programs\shortcutter.lnk
Proceed (y/n)? y
ERROR: Exception: