Skip to content

Instantly share code, notes, and snippets.

View doitian's full-sized avatar
🎯
Focusing

ian doitian

🎯
Focusing
View GitHub Profile
@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 = "";
@doitian
doitian / hider.css
Last active October 14, 2022 12:35
Obsidian 1.0 Minimum UI
/* Hide aliases in read mode */
.frontmatter-container {
display: none;
}
/* Hide left ribbon bar */
.workspace-ribbon.mod-left {
display: none;
}
.is-hidden-frameless:not(.is-fullscreen):not(.is-popout-window) .workspace-tabs.mod-top-left-space .workspace-tab-header-container {
@doitian
doitian / BetterBibTexCitationKeyFormat.txt
Created October 4, 2022 10:53
Example of Using Jieba Word Segmentation in Zotero Better BibTex
extra("tex.shortauthor").transliterate.clean.lower.len+year+title.nopunct.clean.skipwords.select(1,2) | auth.lower.len+year + title.nopunct.clean.skipwords.select(1,2) | "anon" + year + title.nopunct.clean.skipwords.select(1,3)
@doitian
doitian / unicodes_abbrevations.vim
Created October 3, 2022 11:02
Frequently Used Unicode Symbols
exec 'digraphs AH ' .. 0x27A4
noreabbrev vvah ➤
noreabbrev vveop ∎
noreabbrev vvref ※
noreabbrev vvreturn ↩︎
noreabbrev vvsec §
noreabbrev vvsharp ♯
noreabbrev vvspace ␣
const JSON_RPC_ENDPOINT = "http://localhost:23119/better-bibtex/json-rpc";
const HEADERS = {
"User-Agent": "Obsidian",
"Zotero-Allowed-Request": "true",
};
module.exports = async (params) => {
const {
app: { workspace, vault },
} = params;
#!/usr/bin/env python3
import fileinput
import re
from dataclasses import dataclass, field
ANNOTATION_RE = re.compile(r"""
“(.*)”
(\ \(\[.*\]\(.*\)\))+
(?:\ (.*))?