Skip to content

Instantly share code, notes, and snippets.

@reagle
reagle / ai-code.enhanced-sublime-snippet
Created September 5, 2023 18:06
description: "Add top-level ethnographic codes for interviews about AI & moderation"
---
# https://github.com/STealthy-and-haSTy/EnhancedSnippets
# Optional: Set a tabTrigger to define how to trigger the snippet
#tabTrigger: "code"
# Optional: Set a scope to limit where the snippet will trigger
scope: "text.html.markdown"
# Optional: Set a filename glob to limit where the snippet will trigger
#glob: "test_*.md"
# Optional: Set a description for what this snippet does
description: "add ethnographic coding for interviews about AI & moderation"
@reagle
reagle / obsidian-config-copy.py
Last active January 16, 2024 05:40
Create symbolic links from source Obsidian vault config to target vaults.
#!/usr/bin/env python3
"""Create symbolic links from main Obsidian vault config to other vaults.
Obsidian configuration folder can be copied between vaults; this script
copies a configuration from a main vault to other vaults.
"""
from pathlib import Path
from shutil import copytree, rmtree
@reagle
reagle / markdown-zim-to-obsidian.py
Last active September 24, 2023 15:12
Convert Zim exported markdown to Obsidian by removing first heading and converting setext to atx headers
#!/usr/bin/env python3
"""Convert Zim exported markdown to Obsidian by:
1. removing first heading
2. converting setext to atx headers
"""
# https://gist.github.com/reagle/7418f54fb6e40fe8d925e1c3f5325076
import re
from pathlib import Path
@reagle
reagle / mediawiki.sublime-completions
Last active March 4, 2023 13:56
Sublime Text completions for frequently used Wikipedia templates when using Mediawiker package
{
"scope": "text.html.mediawiki",
"completions":
[
// MACROS
{
"trigger": "ur",
"annotation": "user respond",
"contents": ":{{u|$1}} "
},
@reagle
reagle / tz.py
Created October 12, 2022 12:58
Print world clock in terminal
#!/usr/bin/env python3
# Print world clock in terminal
# (c) Copyright 2022 by Joseph Reagle
# Licensed under the GPLv3, see <http://www.gnu.org/licenses/gpl-3.0.html>
#
# replacing: https://superuser.com/questions/164339/timezone-conversion-by-command-line
import argparse # http://docs.python.org/dev/library/argparse.html
import sys
@reagle
reagle / gpa-calc.py
Last active December 15, 2023 18:30
Using dictionary of letter grades, calculate mean GPA from list of letter grades converted to points
#!/usr/bin/env python3
"""Using dictionary of letter grades, calculate mean GPA from list
of letter grades converted to points"""
# https://gist.github.com/reagle/9cc2f4e2f98446528128d1f6edfe3d73
# add results to e-statement-1b-teaching-trace-table.xlsx
__author__ = "Joseph Reagle"
__copyright__ = "Copyright (C) 2021-2024 Joseph Reagle"
__license__ = "GLPv3"
@reagle
reagle / mbx-pp.py
Last active February 20, 2023 15:54
Pretty print a mailbox, since some previous date, as a simple HTML file
#!/usr/bin/env python3
"""Pretty print a mailbox, since some previous date, as a simple HTML file"""
import argparse # http://docs.python.org/dev/library/argparse.html
# http://docs.python.org/lib/module-email.Utils.html
# from email.utils import parsedate
import email.parser
import html
import logging
@reagle
reagle / sublime_semantic_wrap.py
Created May 13, 2021 18:32
A Sublime Text 3 (python 2.7) plugin for wrapping text, including semantic wraps.
# A Sublime Text 3 (python 2.7) plugin for wrapping text, including
# semantic wraps.
import re
import sublime # https://www.sublimetext.com/docs/3/api_reference.html
import sublime_plugin
SEMANTIC_BREAK_RE = re.compile(
r"""
( # end of sentence includes...
[a-z]{2,}| # end of word
@reagle
reagle / pel2pan.py
Created December 9, 2020 15:29
Given a FOLDER, replicate all markdown files with pelican metadata converted to pandoc YAML metadata in `new-FOLDER`
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# DESCRIPTION
# (c) Copyright 2020 by Joseph Reagle
# Licensed under the GPLv3, see <http://www.gnu.org/licenses/gpl-3.0.html>
#
import argparse # http://docs.python.org/dev/library/argparse.html
import codecs
import logging
@reagle
reagle / pandoc_identifier.py
Last active February 20, 2020 23:09
Convert string to pandoc auto_identifiers default algorithm. Intended as a CopyQ clipboard function.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# (c) Copyright 2019 by Joseph Reagle
# Licensed under the GPLv3, see <http://www.gnu.org/licenses/gpl-3.0.html>
#
""" Convert string to pandoc auto_identifiers default algorithm.
Intended as a CopyQ clipboard function.
"""