Skip to content

Instantly share code, notes, and snippets.

@maphew
maphew / make-yt-nts-index-html-table.py
Created Nov 13, 2020
Yukon NTS Index in various formats
View make-yt-nts-index-html-table.py
'''Print Yukon NTS tile names as html table with links, arranged in same order as they appear in a map index.
2015-Aug-19, Matt.Wilkie@gov.yk.ca
License: X/MIT
'''
nts_txt_ordered = '''117C 117D
117B 117A
116NO 116P
116JK 116I 106L 106K
@maphew
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
{
"BACKLOG_FOLDER": {
"ACTIVE": true,
"NAME": "",
"TITLE": "BACKLOG",
"SORT": "-priority,duedate,categoryNames,subject",
"RESTRICT": "",
"DISPLAY_PROPERTIES": {
"OWNER": false,
"PERCENT": false,
@maphew
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: http://leoeditor.com/leo_toc.html -->
<leo_file xmlns:leo="http://leoeditor.com/namespaces/leo-python-editor/1.1" >
<leo_header file_format="2"/>
<vnodes>
<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
maphew / console-log.md
Last active Mar 17, 2020
Leo scripts to manage History Tracer plugin daemon
View console-log.md

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
maphew / arcpy-overhead.py
Last active Mar 11, 2020
What is your "import arcpy" overhead?
View arcpy-overhead.py
'''Measure and report the time it takes to simply `import arcpy`
Part of https://community.esri.com/message/914048-re-what-is-your-import-arcpy-overhead?
'''
from timeit import default_timer as timer
start = timer()
from datetime import datetime, timedelta
from uuid import uuid4
eventid = datetime.now().strftime('%Y%m-%d%H-%M%S-') + str(uuid4())
@maphew
maphew / add-recent-branches-list.sh
Last active Nov 19, 2019
Git shallow clone: only branches with recent activity, as determined by Github
View add-recent-branches-list.sh
# from https://stackoverflow.com/questions/58702233/git-shallow-clone-only-branches-with-activity-last-x-months
export URL=https://github.com/leo-editor/leo-editor/branches/active
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
maphew / list-user-special-folders.py
Last active Sep 7, 2019
Windows user "special folders" (Desktop, Start Menu, Documents, ...) info by enumerating constants from MS published list
View list-user-special-folders.py
'''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
maphew / snips-windows.py
Created Aug 28, 2019
Windows python snippets
View snips-windows.py
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:\tools\miniconda3\envs\test\lib\site-packages\shortcutter-0.1.20.dist-info\*
c:\tools\miniconda3\envs\test\lib\site-packages\shortcutter\*
c:\tools\miniconda3\envs\test\scripts\shortcutter.exe
c:\users\me\appdata\roaming\microsoft\windows\start menu\programs\shortcutter.lnk
d:\test-link.lnk
Proceed (y/n)? y
ERROR: Exception:
@maphew
maphew / tb-edit.html
Created Apr 19, 2019
trumbowyg editor via cdn test
View tb-edit.html
<html>
<head>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/Trumbowyg/2.15.2/ui/trumbowyg.min.css">
</head>
<body>
<div id="editor">
$('#trumbowyg-demo').trumbowyg();
</div>
Adapted from https://alex-d.github.io/Trumbowyg/documentation/