Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / contact.js
Last active January 16, 2024 03:55
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);
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 / 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,
@bramses
bramses / upsertPost.js
Last active April 5, 2024 04:38
upserting a markdown file from obsidian into mdx for nextjs
const { read } = require("gray-matter");
const { writeFileSync } = require('fs')
const HOMEPAGE_PATH = process.env.HOMEPAGE_PATH;
/*
This code is taking the markdown file and converting it to a mdx file
The frontmatter data is being extracted from the markdown file then converted into an object.
Then we are checking if there\'s a slug in the frontmatter or not.
If there isn\'t one throw an error because that means we can\'t create a post without a slug
// ..search-buddy!..
// 1. get json from bing search api
// query = Where was Abraham Lincoln born?
[
{
url: 'https://www.nps.gov/abli/planyourvisit/lincolnbio.htm',
name: 'President Abraham Lincoln - Abraham Lincoln Birthplace ...',
snippet: "Abraham Lincoln was born on Sunday, February 12, 1809, in a log cabin on his father's Sinking Spring Farm in what was at that time Hardin County (today LaRue County) Kentucky. His parents were Thomas Lincoln and Nancy Hanks Lincoln. He had an older sister, Sarah. In 1811, the Lincoln family moved to the Knob Creek Farm, just ten miles away ..."
},
{
@bramses
bramses / UIUtilities.swift
Last active April 9, 2022 18:15
tensorflow-posenet-firebending (view commit history for full code)
public static func addFireSegment(
atPoint point: CGPoint,
to view: UIView,
radius: CGFloat,
flip: Bool
) {
let divisor: CGFloat = 2.0
let xCoord = point.x - radius / divisor
@bramses
bramses / obsidian-request.js
Last active April 9, 2022 06:57
using the obsidian request API as a GET
import { request } from 'obsidian';
const res = await request({url: 'https://stackoverflow.com'}) // url passed in as object -- GET request
console.log(res);
@bramses
bramses / styled-components-usage.js
Created March 26, 2022 15:38
How to use a Styled Components Theme Provider
import styled from "styled-components";
export const StyledH1 = styled.h1`
font-family: ${(props) => props.theme.fonts.heading};
`;