Skip to content

Instantly share code, notes, and snippets.

@scott1991
scott1991 / ReactDark.jsx
Last active November 12, 2023 09:55
Implementing Local Storage and System Preference Color Mode with React-Dark-Mode-Toggle
import DarkModeToggle from "react-dark-mode-toggle";
import { useState, useEffect } from "react";
function ReactDark() {
const [isDarkMode, setIsDarkMode] = useState(() => {
const theme = localStorage.getItem("theme");
if (theme) {
return theme === "dark";
}
// If theme not found in localStorage, use system prefers setting
@scott1991
scott1991 / git_tar_exclude.sh
Last active July 17, 2023 13:27
A script to create a tar archive from a directory, excluding files as per the .gitignore file.
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Please provide the target directory path as an argument."
exit 1
fi
CURRENT_DIR=$(pwd)
TARGET_DIR=$1
DIR_NAME=$(basename $TARGET_DIR)