Skip to content

Instantly share code, notes, and snippets.

View turnercore's full-sized avatar

Turner Monroe turnercore

View GitHub Profile
@turnercore
turnercore / stop-youtube-play-on-load.js
Last active November 28, 2023 17:36
Stop YouTube Play on Load
(() => {
let isVideoHandled = false; // Flag to indicate if the video has been handled
const checkVideoStart = () => {
const video = document.querySelector('#movie_player > div.html5-video-container > video');
if (!video) return;
// When the video starts playing (currentTime changes from 0), pause it
if (video.currentTime > 0 && !video.paused) {
video.pause();
@turnercore
turnercore / stop-youtube-play-on-load.js
Created November 28, 2023 17:35
Stop YouTube Play on Load
(() => {
let isInitialized = false; // Flag to indicate if the initial pause has been done
const pauseVideo = () => {
if (isInitialized) return; // If the initial pause has been done, do nothing further
const video = document.querySelector('#movie_player > div.html5-video-container > video');
// Pause the video if it's found and playing, and then perform cleanup
if (video && !video.paused) {
@turnercore
turnercore / install-shadcn.sh
Last active January 1, 2024 16:53
Install shadcn complete
#!/bin/bash
# Create directories and files
mkdir -p ./components/ui
mkdir -p ./lib
touch ./lib/utils.ts
# Prompt to move globals.css
echo "Would you like to move globals.css to styles/globals.css? (y/n)"
read -r -p "[Y/n]: " move_response
@turnercore
turnercore / generateIndex.ts
Last active November 20, 2023 20:40
Create index file for a folder of typescript files
// @ts-nocheck
import fs from 'fs'
import path from 'path'
import readline from 'readline'
import ts from 'typescript'
// Read directory path from command-line arguments or ask for it
let componentsDirectoryPath = process.argv[2]
if (!componentsDirectoryPath) {
const rl = readline.createInterface({
@turnercore
turnercore / serverActionOnFormData.ts
Created October 31, 2023 20:57
Zod & Server Action Form Pattern
'use server'
import { z } from 'zod'
export default async function serverActionOnFormData(formData: FormData) {
// Get the form data into a javascript object
const form = Object.fromEntries(formData.entries())
// Validate input with zod by passing the form object to the schema
const inputSchema = z.object({
id: z.string().uuid(),
@turnercore
turnercore / generateIndex.ts
Created October 13, 2023 19:15
ts-node script to generate a .ts index from a bunch of exports
// @ts-nocheck
const fs = require('fs')
const path = require('path')
const readline = require('readline')
const ts = require('typescript')
// Read directory path from command-line arguments or ask for it
let componentsDirectoryPath = process.argv[2]
if (!componentsDirectoryPath) {
const rl = readline.createInterface({
@turnercore
turnercore / psudo-json-to-json-parser.py
Created August 17, 2023 02:47
Parser for turning bad json into valid json, or PJTJP
import re
def convert_to_json_like(input_str):
# Preprocess the input by removing quotes and condensing spaces
input_str = re.sub(r'[\'"]', '', input_str)
input_str = re.sub(r'\s+', ' ', input_str).strip()
# Initialize variables
new_str = []
looking_for_first_alpha = True
@turnercore
turnercore / subcultures.json
Created July 14, 2023 23:20
subcultures in a json array
[
{"name": "Steampunk", "description": "Inspired by 19th-century industrial steam-powered machinery and the aesthetics of the Victorian era."},
{"name": "Furries", "description": "Interested in anthropomorphic animal characters with human personalities and characteristics."},
{"name": "Cosplay", "description": "Dress up and role-play as characters from movies, TV shows, anime, manga, video games, and more."},
{"name": "Goth", "description": "Originating from the post-punk scene in the 1980s, characterized by a fascination with the macabre, romanticism, and dark aesthetics."},
{"name": "Lolita", "description": "Originating in Japan, characterized by wearing clothing inspired by the Rococo and Victorian eras."},
{"name": "Biohackers", "description": "Individuals who seek to enhance their bodies with a combination of medical, nutritional, and electronic techniques."},
{"name": "Freegans", "description": "People who employ alternative strategies for living based on limited participatio