Skip to content

Instantly share code, notes, and snippets.

View arkatsy's full-sized avatar
🍂

Argi arkatsy

🍂
  • Greece
  • 15:41 (UTC +02:00)
View GitHub Profile
// Name: Toggle System Theme
// Author: arkatsy
// Description: Toggles the system theme between light and dark mode.
import "@johnlindquist/kit";
import * as _regedit from "regedit";
import { exec } from "child_process";
const regedit = _regedit.promisified;
const REGISTRY_PATH = "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize";
@arkatsy
arkatsy / zustand-internals.jsx
Last active November 2, 2024 12:36
How zustand works internally
import { useSyncExternalStore } from "react";
// For more on the useSyncExternalStore hook, see https://react.dev/reference/react/useSyncExternalStore
// The code is almost identical to the source code of zustand, without types and some features stripped out.
// Check the links to see the references in the source code.
// The links are referencing the v5 of the library. If you plan on reading the source code yourself v5 is the best way to start.
// The current v4 version contains lot of deprecated code and extra stuff that makes it hard to reason about if you're new to this.
// https://github.com/pmndrs/zustand/blob/fe47d3e6c6671dbfb9856fda52cb5a3a855d97a6/src/vanilla.ts#L57-L94
function createStore(createState) {