Skip to content

Instantly share code, notes, and snippets.

View doitian's full-sized avatar
🎯
Focusing

ian doitian

🎯
Focusing
View GitHub Profile
@doitian
doitian / settings.json
Created September 1, 2023 02:38
vscode settings
{
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
@doitian
doitian / input.js
Last active August 11, 2023 03:31
Obisidian CustomJS module to ask for user input
class Input {
PromptModal = class extends customJS.obsidian.Modal {
title = "Input";
value = "";
submitted = false;
placeholder = "Type text here";
constructor(opts = {}) {
super(app);
Object.assign(this, opts);
@doitian
doitian / config.yml
Last active August 10, 2023 12:57
Open history version files from Git in Vim via LazyGit
# yaml-language-server: $schema=https://json.schemastore.org/lazygit.json
promptToReturnFromSubprocess: false
os:
editPreset: "nvim"
customCommands:
- key: E
context: commitFiles
subprocess: true
# - When a file is selected, open the file before the commit
#!/usr/bin/env python3
import os
import re
import sys
import subprocess
import json
from collections import namedtuple, OrderedDict
import requests
from requests.auth import HTTPBasicAuth
@doitian
doitian / ifttt-google-calendar-to-discord-webhook-filter.ts
Created March 23, 2023 13:24
Send Google Calendar events to Discord via Webhook
function htmlToMarkdown(input: string) {
const linkRegex = /<a\s+[^>]*href="([^"]*)"[^>]*>(.*?)<\/a>/gi;
return input.replace(linkRegex, '[$2]($1)');
}
const TZ = 8*60*60;
function formatDiscordTimestamp(input: string) {
const ts = moment.utc(input, "MMMM D, YYYY at hh:mmA", "MMMM D, YYYY").unix() - TZ;
return `<t:${ts}>`;
}
@doitian
doitian / ai-git-commit
Last active March 7, 2023 13:21
Git commit with OpenAI generated message based on https://goonlinetools.com/snapshot/code/#42rshrrrk3gq5h171lxiu
#!/bin/bash
if [ -z "${OPENAI_API_KEY:-}" ]; then
export OPENAI_API_KEY="$(gopass show key/openai.com/personal)"
fi
system_message="You are a helpful assistant who writes short git commit messages."
user_message="Write the commit message for the following changes:
$(git diff --cached)"
#!/usr/bin/env bash
set -e
set -u
[ -n "${DEBUG:-}" ] && set -x || true
ALL_CATEGORIES="
ΓFA Family Album
ΓFE Family Event
ΓFT Family Travel

GitHub requires extra escaping on \{ and \;.

markdown
$$
HPS_{i} = \left \\{
      \begin{aligned}
          & HPS_{i-1} \times \frac{1}{\tau} \\;, & \overline{HPS_{i}} \lt \frac{1}{\tau} HPS_{i-1} \\
          & HPS_{i-1} \times \frac{1}{\tau} \\;, & \overline{HPS_{i}} \gt \tau HPS_{i-1} \\
@doitian
doitian / pinboard-images.js
Created October 18, 2022 07:56
Display the cached images in Pinboard
document.querySelectorAll("a.cached").forEach(async (a) => {
const cacheResp = await fetch(a.href);
const htmlText = await cacheResp.text();
const doc = new DOMParser().parseFromString(htmlText, "text/html");
const iframes = doc.querySelectorAll("body > iframe");
const img = document.createElement("img");
img.setAttribute("src", iframes[1].src);
img.setAttribute("style", "max-width: 100%");
a.innerHTML = "";