Skip to content

Instantly share code, notes, and snippets.

View beardedtim's full-sized avatar
💭
I may be slow to respond.

Tim Roberts beardedtim

💭
I may be slow to respond.
View GitHub Profile
@beardedtim
beardedtim / from.tsx
Created February 7, 2024 14:09
Example form
'use client'
import { PortableText } from '@portabletext/react'
import { useState } from 'react'
import contactFormAction from '@/actions/contactForm'
import SubmitButton from '@/components/submitButton'
const Contact = ({ title, description }) => {
const [submitted, setSubmitted] = useState(false)
@beardedtim
beardedtim / action.ts
Created February 7, 2024 14:08
Example form action
'use server'
import { sql } from '@vercel/postgres'
import { Log } from '@/utils'
const handleFormSubmit = async (data: FormData) => {
const message = data.get('message') as string
const email = data.get('email') as string
const phoneNumber = data.get('phone') as string
const name = data.get('name') as string
@beardedtim
beardedtim / ingress.md
Last active August 30, 2022 15:44
How to create a local K8s development via Minikube

Add an Ingress

Step 1: Add Ingress

k8s/ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
@beardedtim
beardedtim / index.css
Created June 22, 2022 14:01
A way to have nested dropdown without any styling
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html, body {
width: 100%;
height: 100%;
}
@beardedtim
beardedtim / index.html
Last active June 11, 2022 21:25
Basic Form in JS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Input Example</title>
</head>
<body>
<form>
@beardedtim
beardedtim / index.html
Created May 31, 2022 20:02
html stuff
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
</style>
@beardedtim
beardedtim / wait-for-it.js
Created April 14, 2022 16:23
Waits for a URL to return 200 for a specified time, exits 1 if it is not available
/**
* Wait For It
*
* Given Env Vars of:
*
* - VALIDATE_URL: a fully qualified url starting with https:// that we want to validate
* - TIME_ALLOWED_IN_SECONDS: timeout we want to wait until we mark this URL dead. Defaults 30
* - TIME_BETWEEN_TRIES_IN_SECONDS: timeout between requests to the URL. Defaults to 1
*/
const https = require('https')
@beardedtim
beardedtim / async-happy-path.ts
Created March 11, 2022 00:08
Async Await Bites Again
const someDatabaseLogic: RequestHandler = async (req, res) => {
await setTimeout(1000)
res.end('Goodbye!')
}
export const someAPIHandler: RequestHandler = async (req, res, next) => {
try {
console.log('we are handling a requst')
return someDatabaseLogic(req, res, next)
} catch (e) {
@beardedtim
beardedtim / value.ts
Last active March 3, 2022 19:13
Fantasy Land Value
import EE from 'events'
export const EVENTS = {
NEW_VALUE: 'new value',
}
/**
* A Value is a way to represent a single, atomic _primitve_
* that we want to interact with. It can be observed over time
* and can be used to make things such as Records/Maps and
@beardedtim
beardedtim / import-dir.ts
Last active November 25, 2020 18:46
Import a directory of es modules
import glob from 'glob'
import Case from 'case'
import R from 'ramda'
interface ImportConfig {
case: 'snake' | 'kebab' | 'camel' | 'pascal' | 'constant' | 'header'
ext: 'js' | 'ts'
without?: string[]
}