Skip to content

Instantly share code, notes, and snippets.

View doitian's full-sized avatar
🎯
Focusing

ian doitian

🎯
Focusing
View GitHub Profile
This file has been truncated, but you can view the full file.
"use strict";
var obsidian = require("obsidian");
/******************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
#!/bin/bash
# Start Python REPL and setup rich
# https://rich.readthedocs.io/en/latest/introduction.html#rich-in-the-repl
""":"
PYTHON=${PYTHON:-python}
if command -v python3 &>/dev/null; then
PYTHON=python3
fi
import base64
from Crypto.Hash import SHA256
from Crypto.PublicKey import ECC
from Crypto.Signature import DSS
from Crypto.Util.asn1 import DerSequence
response = {
"signature": "MEUCICF25qdO6nLreEoBHnyaw-9R6XFHbIu-NwsAI53t016qAiEAgmhlwTEMxoWx"
"Kj79R1rUkB_6nrhJfws82DqHkY_HnqQ",
{
"openrpc": "1.0.0-rc1",
"info": {
"version": "1.0.0",
"title": "Petstore",
"license": {
"name": "MIT"
}
},
"servers": [
@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)"