Skip to content

Instantly share code, notes, and snippets.

View bramses's full-sized avatar
🤨

Bram Adams bramses

🤨
View GitHub Profile
<meta
http-equiv="Content-Security-Policy"
content="default-src * data: blob: filesystem: about: ws: wss: 'unsafe-inline' 'unsafe-eval';
script-src * data: blob: 'unsafe-inline' 'unsafe-eval';
connect-src * data: blob: 'unsafe-inline';
@bramses
bramses / cloudfalre-images-api-key.sh
Last active March 20, 2022 20:39
curl cf images
for f in "$@"
do
curl -X POST -F "file=@$f" -H "Authorization: Bearer API_KEY" https://api.cloudflare.com/client/v4/accounts/ACCOUNT_ID/images/v1
done
@bramses
bramses / retrieve-cf-variant-url.js
Created March 20, 2022 17:04
extract a variant url from cf
function run(input, parameters) {
var filename = "";
var uploaded = "";
var variants = "";
for (var i = 0; i < input.length; i++) {
if (input[i].includes("filename")) {
filename = input[i].split(":")[1].trim().replaceAll('"', "");
@bramses
bramses / algolia-hits-nextjs.js
Last active March 22, 2022 06:45
how im using algolia in nextjs with styled components
import { connectStateResults } from "react-instantsearch-dom";
import Link from "next/link";
import { StyledTitleLink } from "../components/StyledTitleLink";
import CustomHighlight from "./Highlight";
function Hits({ searchState, searchResults }) {
const validQuery = searchState.query?.length >= 1; // 1 is the minimum query length
return (
<>
@bramses
bramses / styled-components-impl.js
Created March 26, 2022 15:37
how to add a global theme to reference with styled components
import { createGlobalStyle, ThemeProvider } from "styled-components";
const GlobalStyle = createGlobalStyle`
body {
margin: 0;
padding: 0;
box-sizing: border-box;
}
`;
@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};
`;
@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 / 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
// ..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 / 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