Skip to content

Instantly share code, notes, and snippets.

@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 / semester.py
Last active January 3, 2024 20:17
Generate a class calendar using duration of semester, the days of the week a class meets, and holidays. It can modify a markdown syllabus if they share the same number of sessions and classes are designed with the pattern "### Sep 30 Fri"
#!/usr/bin/env python3
"""Generate a class calendar using duration of semester, the days of the week a
class meets, and holidays. It can modify a markdown syllabus if they share the
same number of sessions and classes are designed with the pattern "### Sep 30 Fri"
"""
# https://gist.github.com/reagle/19806122fdb22515ea0b
__author__ = "Joseph Reagle"
@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 / 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 / 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 / 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 / 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 / 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 / semantic_wrap.py
Last active July 13, 2021 12:00
Wrap text, including semantically by add breaks at terminal punctuation.
#!/usr/bin/env python2.7
"""Wrap text, including semantically by add breaks at
terminal punctuation."""
# Using python 2.7 so portions can be used in Sublime Text 3 plugin
import argparse # http://docs.python.org/dev/library/argparse.html
import logging
import re
import sys
@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