Skip to content

Instantly share code, notes, and snippets.

View full-sized avatar
🤨

Bram Adams bramses

🤨
View GitHub Profile
@bramses
bramses / _result.md
Last active July 17, 2023 04:58
Use GPT-4 to automatically diagnose errors
View _result.md

TLDR

I wrapped Python traceback and Exception so whenever an Exception is raised, an automatic diagnosis is done by GPT-4. See results below:

Prompt (Automatically Generated by error_wrap function)

This error message occurred because of 'test' at line 177 in file api.py, function main. The exception type is <class 'Exception'>. The function is:

@bramses
bramses / twitch_thanker_guidance.ipynb
Created May 23, 2023 22:20
Using Guidance to create a Twitch thank you bot
View twitch_thanker_guidance.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bramses
bramses / obsidian-publish-swipe.js
Created January 5, 2023 04:10
swipe left to open menu; swipe right to close it
View obsidian-publish-swipe.js
// swipe left on mobile to open menu
let touchstartX = 0;
let touchendX = 0;
function checkDirection() {
// check if greater than 100px
// if swipe right close menu
if (touchendX < touchstartX && touchstartX - touchendX > 100) {
document
.querySelector(".published-container")
@bramses
bramses / publish.js
Last active January 5, 2023 03:49
testing remark42 on obsidian publish
View publish.js
var remark_config = {
host: "https://demo.remark42.com",
site_id: "remark",
};
// https://stackoverflow.com/a/74271142/3952024
async function waitForElement(selector, timeout = null, location = document.body) {
return new Promise((resolve) => {
let element = document.querySelector(selector);
if (element) {
@bramses
bramses / vercel.json
Created January 2, 2023 19:09
:path not working
View vercel.json
{
"rewrites": [
{
"source": "/zettelkasten/",
"destination": "https://publish.obsidian.md/serve?url=bramadams.dev/zettelkasten"
},
{
"source": "/zettelkasten/:path*",
"destination": "https://publish.obsidian.md/serve?url=bramadams.dev/zettelkasten/:path*"
}
@bramses
bramses / gitLastDay.js
Last active July 25, 2022 01:25
Note: this must be run in the repo that has the `.git` folder (https://www.bramadams.dev/projects/gitting-git-commits-for-your-work-journal)
View gitLastDay.js
import moment from "moment";
import { spawn } from "child_process";
import * as dotenv from "dotenv";
dotenv.config();
const OWNER = process.env.OWNER || process.argv[2];
const REPO = process.env.REPO || process.argv[3];
const AUTHOR = process.env.AUTHOR || process.argv[4];
const GH_URL = `https://github.com/${OWNER}/${REPO}/commit/`;
View wave-surfer-next.js
// npm install wavesurfer.js
import React, { useState, useEffect, useRef } from "react";
const formWaveSurferOptions = (ref) => ({
container: ref,
waveColor: "#eee",
progressColor: "#0178FF",
cursorColor: "OrangeRed",
barWidth: 3,
barRadius: 3,
@bramses
bramses / weekly-traversal-obsidian-templater.txt
Last active July 17, 2022 19:18
How To Traverse Weekly Notes in Obsidian with Templater
View weekly-traversal-obsidian-templater.txt
<< <% tp.date.now("YYYY") %>-W<% tp.date.now("WW") - -1 %> | <% tp.date.now("YYYY") %>-W<% tp.date.now("WW") - -3 %> >>
@bramses
bramses / extend-jest.ts
Last active July 15, 2022 00:19
Extend Jest in TS and fix: ES2015 module syntax, Augmentations for the global scope (https://www.bramadams.dev/projects/jest-ts-extentions)
View extend-jest.ts
export {}
// https://jestjs.io/docs/expect#expectextendmatchers
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace
namespace jest {
interface Matchers<R> {
toBeWithinRange(a: number, b: number): R;
}
}
@bramses
bramses / Daily Notes Template.txt
Last active July 12, 2022 19:12
How To Add a Conditional To-Do List To A Daily Note in Obsidian (https://www.bramadams.dev/projects/conditional-todo-list)
View Daily Notes Template.txt
<%* let day = tp.date.now("dd")
if (day == "Su") { %>
```tasks
not done
heading includes todo/sunday
```
<%* } else if (day == "Sa") { %>