Skip to content

Instantly share code, notes, and snippets.

View bmorrisondev's full-sized avatar

Brian Morrison II bmorrisondev

View GitHub Profile
@bmorrisondev
bmorrisondev / convex.code-snippets
Created August 22, 2024 19:48
VSCode snippets to quickly generate Convex queries and mutations
{
"Convex Query": {
"prefix": "cvq",
"scope": "typescript",
"body": [
"export const ${1} = query({",
"\targs: {",
"\t\t${2}",
"\t},",
"\thandler: async (ctx, args) => {",
export const config = {
matcher: [
// Skip Next.js internals and all static files, unless found in search params
'/((?!_next|[^?]*\\.(?:html?|css|js(?!on)|jpe?g|webp|png|gif|svg|ttf|woff2?|ico|csv|docx?|xlsx?|zip|webmanifest)).*)',
// Always run for API routes
'/(api|trpc)(.*)',
],
};
import { WebhookEvent } from "@clerk/nextjs/server";
import { headers } from "next/headers";
import { NextRequest, NextResponse } from "next/server";
import { Webhook } from "svix"
type WebhooksHandler = {
config: WebhookRegistrationConfig
POST: (req: NextRequest) => Promise<NextResponse | Response>
}
import { WebhookEvent } from "@clerk/nextjs/server";
import { headers } from "next/headers";
import { NextRequest, NextResponse } from "next/server";
import { Webhook } from "svix";
export type WebhookRegistrationConfig = {
secret?: string
urlPrefix?: string
onUserCreated?: (event: WebhookEvent) => Promise<void | NextResponse>;
onUserUpdated?: (event: WebhookEvent) => Promise<void | NextResponse>;
@bmorrisondev
bmorrisondev / ps-workflow.yaml
Created April 5, 2023 21:35
Creates a new branch & deploy request in PlanetScale when a PR is opened and schema.prisma is changed
name: Prisma PR PlanetScale Demo
on:
pull_request:
types: [opened]
paths:
- schema.prisma
env:
PLANETSCALE_ORG: bmorrison-ps
PLANETSCALE_DB: recipes_db
@bmorrisondev
bmorrisondev / main.js
Created August 18, 2022 14:38
Query Notion DB with JS
const { Client } = require("@notionhq/client")
const notion = new Client({
auth: "<NOTION_SECRET>",
notionVersion: "2022-02-22"
})
;(async() => {
const res = await notion.databases.query({
database_id: "<NOTION_DBID>"
import { graphql } from 'gatsby'
import React from 'react'
import { Helmet } from 'react-helmet'
import styled from 'styled-components'
export const pageQuery = graphql`
query PostById(
$id: String
) {
wpPost(id: {
@bmorrisondev
bmorrisondev / sqs-consumer.js
Last active November 11, 2021 16:42
A simple SQS setup in JavaScript
// npm install sqs-consumer
const { Consumer } = require('sqs-consumer')
const app = Consumer.create({
queueUrl: "SQS_URL",
handleMessage: async (message) => {
// Do stuff
}
});
import React, { useState, useEffect, useContext } from 'react'
import styled from 'styled-components'
import copy from "copy-to-clipboard";
import { GlobalContext } from '../../contexts/GlobalContext'
import Loading from "../../components/Loading"
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import Stat from '../../components/build/Stat'
import SubclassCard from '../../components/build/SubclassCard'
import ItemCard from '../../components/build/ItemCard'
import UpvoteButton from '../../components/build/UpvoteButton';
@bmorrisondev
bmorrisondev / index.js
Created September 4, 2021 23:00
Ocr stuffz
const axios = require('axios')
const fs = require('fs')
const { PDFImage } = require('pdf-image')
const { createWorker } = require('tesseract.js')
async function ocrStuffz(fileName) {
let pdfImage = new PDFImage(fileName, { combinedImage: true })
let convertedImage = await pdfImage.convertFile()
const worker = createWorker({