Skip to content

Instantly share code, notes, and snippets.

@maphew
maphew / make-yt-nts-index-html-table.py
Created November 13, 2020 05:29
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.
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 September 22, 2020 23:25
Outlook-taskboard config with To-Do flagged emails enabled and shown in BACKLOG lane
{
"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 July 11, 2020 08:23
WIP: management scripts for History Tracer plugin for Leo
<?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 March 17, 2020 04:53
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
maphew / arcpy-overhead.py
Last active March 11, 2020 13:00
What is your "import arcpy" overhead?
'''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 November 19, 2019 17:43
Git shallow clone: only branches with recent activity, as determined by Github
# 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 September 7, 2019 05:16
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
maphew / snips-windows.py
Created August 28, 2019 19:54
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
$ 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 April 19, 2019 06:27
trumbowyg editor via cdn test
<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/