Skip to content

Instantly share code, notes, and snippets.

View bramses's full-sized avatar
🤨

Bram Adams bramses

🤨
View GitHub Profile
@bramses
bramses / startHompageServer_openPostInChrome.js
Last active May 10, 2022 04:11
Starting the kanieki server and opening posts in Chrome
const { spawn } = require( 'child_process' );
const open = require('open');
const startHomepageServer = () => {
// spawn a new process
// change directory to HOMEPAGE_PATH
// run npm run dev
// run it in a shell
const server = spawn( `cd ${HOMEPAGE_PATH} && npm`, [ 'run', 'dev' ], {
shell: true,
getFrontmatter () {
const file = this.app.workspace.getActiveFile();
const fm = this.app.metadataCache.getFileCache(file)?.frontmatter;
if (fm === undefined) {
new Notice('No frontmatter found.');
return;
}
if (fm.slug === undefined) {
@bramses
bramses / contact.js
Last active May 19, 2024 23:40
Create a Contact Form in NextJS/Vercel
// frontend - react
import { useState } from "react";
import Alert from "@reach/alert";
export default function Contact() {
const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [message, setMessage] = useState("");
const [messageSent, setMessageSent] = useState(false);
@bramses
bramses / blurred-edges.css
Created May 20, 2022 06:58
blurring edges w css
{
background-image: url('img.jpg');
/* you need to match the shadow color to your background or image border for the desired effect*/
box-shadow: 0 0 50px 50px white inset;
}
@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)
<%* let day = tp.date.now("dd")
if (day == "Su") { %>
```tasks
not done
heading includes todo/sunday
```
<%* } else if (day == "Sa") { %>
@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)
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 / weekly-traversal-obsidian-templater.txt
Last active July 17, 2022 19:18
How To Traverse Weekly Notes in Obsidian with Templater
<< <% tp.date.now("YYYY") %>-W<% tp.date.now("WW") - -1 %> | <% tp.date.now("YYYY") %>-W<% tp.date.now("WW") - -3 %> >>
// 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 / 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)
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/`;
@bramses
bramses / vercel.json
Created January 2, 2023 19:09
:path not working
{
"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*"
}