Skip to content

Instantly share code, notes, and snippets.

View danieltharp's full-sized avatar
💭
Computers help us solve problems we didn't have before.

Daniel Tharp danieltharp

💭
Computers help us solve problems we didn't have before.
  • ParkMobile
  • New Mexico
View GitHub Profile
@danieltharp
danieltharp / s3-push.yaml
Created June 10, 2023 21:04
Push a static site to an S3 bucket with Github Actions
name: Deploy to AWS
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ develop, main ]
paths:
- 'apps/io/**'
- '.github/workflows/io.yaml'
@danieltharp
danieltharp / furigana.min.js
Created May 23, 2023 02:29
Minified furigana renderer
const R=/{((?:[\u2E80-\uA4CF\uFF00-\uFFEF])+)((?:\|[^ -\/{-~:-@\[-`]*)+)}/gm,T="p, h1, h2, h3, h4, h5, h6, ol, ul, table";function cF(e){let t=Array.from(e.textContent.matchAll(R)),n=e;for(let l of t){let r=l[2].split("|").slice(1),h=1===r.length?[l[1]]:l[1].split("");if(h.length===r.length){let o=document.createElement("ruby");o.classList.add("furigana"),h.forEach((e,t)=>{o.insertAdjacentHTML("beforeend",e+"<rt>"+r[t]+"</rt>")});let a=n.splitText(n.textContent.indexOf(l[0]));n=a.splitText(l[0].length),a.replaceWith(o)}}return e}function rF(e){let t=e.querySelectorAll(T);0!==t.length&&t.forEach(e=>{!function e(t){let n=[];t.childNodes.forEach(t=>{3===t.nodeType?n.push(t):t.hasChildNodes()&&"CODE"!==t.nodeName&&"RUBY"!==t.nodeName&&e(t)}),n.forEach(e=>{e.replaceWith(cF(e))})}(e)})}window.onload=function(){rF(document.body)};
@danieltharp
danieltharp / furigana.js
Created May 23, 2023 01:48
furigana.js - Native ruby rendering for furigana.
// Adapted from https://github.com/steven-kraft/obsidian-markdown-furigana
const REGEXP = /{((?:[\u2E80-\uA4CF\uFF00-\uFFEF])+)((?:\|[^ -\/{-~:-@\[-`]*)+)}/gm;
// Main Tags to search for Furigana Syntax
const TAGS = "p, h1, h2, h3, h4, h5, h6, ol, ul, table";
function convertFurigana(element) {
const matches = Array.from(element.textContent.matchAll(REGEXP));
let lastNode = element;
for (const match of matches) {
const furi = match[2].split("|").slice(1); // First Element will be empty
const kanji = furi.length === 1 ? [match[1]] : match[1].split("");
@danieltharp
danieltharp / wikidot-clone.py
Created July 1, 2020 17:28
A quick way to clone Wikidot sites larger than 100 Pages with an API key.
# You will need to be a member of both sites.
# Both sites need to enable API Reads for members, and the new site needs to allow writes via the API.
# If you're an admin of the sites you can restrict the API to admins only.
# If you don't have a Wikidot API Key, unfortunately you can no longer get one.
# TODO: Handle files above the 6MB size limit the API imposes, although you also can't write files back of that size.
# They could be retrieved via files.get_meta, there's an attribute called download_url.
# E.g.,
# import requests
# for idx, file in enumerate(files):
from xmlrpclib import ServerProxy
import datetime
from time import sleep
from collections import OrderedDict
today = datetime.datetime.now()
DD = datetime.timedelta(days=7)
earlier = today - DD
idate = earlier.strftime("%Y-%m-%d")
@danieltharp
danieltharp / tabview
Last active July 21, 2018 01:53
Example tabview for Wikidot
[[tabview]]
[[tab Tab 1]]
This is the content of Tab 1.
[[/tab]]
[[tab Tab 2]]
This is the content of Tab 2.
[[/tab]]
[[tab Tab 3]]
This is the content of Tab 3.
[[/tab]]
[[module CSS]]
@import url('https://fonts.googleapis.com/css?family=Roboto');
.customtext { font-family: 'Roboto', sans-serif; }
[[/module]]
Then you'd use [[div class="customtext"]]Text with a custom font face goes here.[[/div]]
@danieltharp
danieltharp / one_year_on.py
Last active March 23, 2022 03:21
Source for the script to remind people of their new years resolution
import praw
reddit = praw.Reddit(client_id='',
client_secret='',
password='',
user_agent='',
username='')
readingfrom = reddit.submission('3ywu0b') # Last year's thread.
body = []
@danieltharp
danieltharp / DangItBobby.ps1
Created April 6, 2016 22:14
PowerShell script to find where a user is logged into on the network and disable their NIC.
# ********************************************************************************
#
# Script Name: DangItBobby.ps1
# Version: 1.0.0
# Author: bluesoul <https://bluesoul.me>
# Date: 2016-04-06
# Applies to: Domain Environments
#
# Description: This script searches for a specific, logged on user on all or
# specific Computers by checking the process "explorer.exe" and its owner. It