Skip to content

Instantly share code, notes, and snippets.

View sethdavis512's full-sized avatar
🤖

Seth Davis sethdavis512

🤖
View GitHub Profile
import React from "https://esm.sh/react";
import ReactDOM from "https://esm.sh/react-dom/client";
// ==========
enum SeasonTypes {
SUMMER = "summer",
WINTER = "winter"
}
import React from "https://esm.sh/react";
import ReactDOM from "https://esm.sh/react-dom/client";
// ==========
enum SeasonTypes {
SUMMER = "summer",
WINTER = "winter"
}
// This function is IMPURE
// Because it depends on the current time, so it will always return a different output given the same input.
function getTime() {
return new Date().toLocaleTimeString();
}
// This function is PURE
// Because given the same input strings, it will always return the same output.
function compareDateStrings(s1, s2) {
@sethdavis512
sethdavis512 / auto-draft-email.json
Created August 1, 2025 18:29
Auto Draft Email - n8n Automation
{
"nodes": [
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 1
@sethdavis512
sethdavis512 / copilot-instructions.md
Created July 10, 2025 00:55
Custom Copilot Instructions
You are an AI programming assistant that is specialized in applying code changes to an existing document. Follow Microsoft content policies. Avoid content that violates copyrights. If you are asked to generate content that is harmful, hateful, racist, sexist, lewd, violent, or completely irrelevant to software engineering, only respond with "Sorry, I can't assist with that." Keep your answers short and impersonal. The user has the following code open in the editor, starting from line 1.
import { FlatCache } from 'flat-cache';
export const cache = new FlatCache();
// ===========
let isInitialRequest = true;
// Utility function to generate a unique cache key
function generateKey(request: Request): string {
// Define an enum with some color keys and their corresponding values
enum Colors {
Red = "#FF0000",
Green = "#00FF00",
Blue = "#0000FF",
}
// Function to get the value of a color by its key
function getColorValue(colorKey: keyof typeof Colors): string {
return Colors[colorKey];
@sethdavis512
sethdavis512 / vite.config.ts
Created April 8, 2025 14:12
Config to publish component library
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { resolve } from 'path';
import dts from 'vite-plugin-dts';
// https://vite.dev/config/
export default defineConfig({
plugins: [react(), dts({
include: ['src/components'],
rollupTypes: true,
function getSafe(fn) {
try {
return fn();
} catch (e) {
return undefined;
}
}
/**
* Safely retrieves a value from an object at the specified path.
async function encryptData(data, key) {
const encodedData = new TextEncoder().encode(data);
const iv = crypto.getRandomValues(new Uint8Array(12)); // Initialization vector
const encryptedData = await crypto.subtle.encrypt(
{
name: "AES-GCM",
iv: iv
},
key,
encodedData