Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View cassidoo's full-sized avatar
⌨️
sleepy

Cassidy Williams cassidoo

⌨️
sleepy
View GitHub Profile
@cassidoo
cassidoo / clearInputs.js
Created March 27, 2024 03:42
Clear all the inputs on the page
function clearInputs() {
let inputs = document.getElementsByTagName("input");
for (const i of inputs) {
i.value = "";
}
}
@cassidoo
cassidoo / tauri-file-diff.js
Created March 21, 2024 21:05
A script for a Tauri application to iterate over files and generate new file names and not overwrite old ones
const { BaseDirectory, exists } = window.__TAURI__.fs;
async function doesFileExist(fileName) {
let fileExists = await exists(fileName + ".pdf", {
baseDir: BaseDirectory.Download,
});
let fileCounter = 0;
while (fileExists) {
fileCounter++;
@cassidoo
cassidoo / wrapunicodespangpt4.md
Last active February 18, 2024 21:24
A GPT-4 prompt to write a simple JavaScript function

Prompt: Write a function in JavaScript that wraps a Unicode character in an HTML document in a <span> tag with a CSS class.


Raw GPT-4 Output:

You can use the following JavaScript function to achieve this:

function wrapUnicodeCharacter(char, cssClass) {
@cassidoo
cassidoo / mergerefs.jsx
Created January 10, 2023 22:57
Merge refs in React so a component can have more than one ref
export function mergeRefs(refs) {
return (value) => {
refs.forEach((ref) => {
if (typeof ref === "function") {
ref(value);
} else if (ref != null) {
ref.current = value;
}
});
};
@cassidoo
cassidoo / youtubeid.js
Created January 6, 2023 20:16
Get YouTube ID with JavaScript
let url = "https://www.youtube.com/watch?v=nVvxOwxuk_w";
url = url.split("v=")[1].split("&")[0]; // this removes out any extra parameters, like a playlist point etc
console.log(url);
// id = nVvxOwxuk_w
@cassidoo
cassidoo / base-css.md
Created May 4, 2022 06:37
Base CSS for a plain HTML document

If you don't want to deal with styling a mostly text-based HTML document, plop these lines in and it'll look good:

html {
  font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
  font-size: 1.3em;
  max-width: 40rem;
  padding: 2rem;
  margin: auto;
 line-height: 1.5rem;
@cassidoo
cassidoo / .zshrc
Created February 13, 2022 23:16
Latest .zshrc file
export HOMEBREW_INSTALL_BADGE="🧋"
# Bash/ZSH Stuff
alias reload='source ~/.zshrc'
alias a='echo "------------Your aliases------------";alias'
alias sa='source ~/.zshrc;echo "ZSH aliases sourced."'
alias bp='vim ~/.zshrc'
# Install git completion here: brew install git bash-completion
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
@cassidoo
cassidoo / 5letterdictionary.txt
Created January 10, 2022 02:50
Words that are 5 letters long
ABACI
ABACK
ABASE
ABASH
ABATE
ABBEY
ABBOT
ABEAM
ABEAR
ABETS
@cassidoo
cassidoo / support.html
Created December 3, 2021 18:38
Support Black Orgs
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Support Black Orgs</title>
<link rel="stylesheet" href="https://fonts.xz.style/serve/inter.css" />
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@exampledev/new.css@1.1.2/new.min.css"
@cassidoo
cassidoo / index.js
Created December 3, 2021 18:25
React demo
import React, { useState, useEffect, useReducer, useMemo } from 'react'
import ReactDOM from 'react-dom'
// let text = 'hellllooooo'
// I AM REACT
// let domTable = {}
// let element = Counter // state = 0
// commit(element, domTable)