Skip to content

Instantly share code, notes, and snippets.

@kylewlacy
kylewlacy / use-deep-state.ts
Created June 13, 2025 09:24
useDeepState - React useState hook that uses fast-deep-equal to avoid unnecessary state changes
import React from "react";
import deepEqual from "fast-deep-equal";
export function useDeepState<S>(
initialState: S | (() => S),
): [S, React.Dispatch<React.SetStateAction<S>>] {
const [value, setValue] = React.useState(initialState);
const deepSetValue: React.Dispatch<React.SetStateAction<S>> =
React.useCallback((action) => {
setValue((prevValue) => {
@kylewlacy
kylewlacy / Cargo.toml
Last active May 27, 2025 04:05
facet - size_of in const context
[package]
name = "facet-size-test"
version = "0.1.0"
edition = "2024"
[dependencies]
facet = { version = "0.27.6", default-features = false }
@kylewlacy
kylewlacy / justfile
Created April 9, 2025 03:03
Sketch of using Brioche + Just + Process Compose for managing services
test: services-start
node src/example.js
services-start:
process-compose up -D
@kylewlacy
kylewlacy / README.md
Created October 3, 2021 00:31
Systemd service to disable Proxmox VE nagware

Here's a Systemd service that will automatically disable the "No valid subscription" nagware dialog in Proxmox VE. I got the snippet to disable the dialog from this article from John's Computer Services.

  1. Save the systemd service to /etc/systemd/system/proxmox-patcher.service
  2. Save the shell script to /root/proxmox-patcher.sh
  3. Run chmod +x /root/proxmox-patcher.sh as root
  4. Run systemctl enable proxmox-patcher.service as root
  5. Restart
@kylewlacy
kylewlacy / attaching-a-directory.md
Last active May 6, 2021 17:44
Attaching a directory to a libvirtd VM

Attaching a directory from a host to a libvirtd guest VM

NOTE: These instructions aren't comprehensive! This just covers the main roadblocks every time I need to re-do this process...

(For context, I'm using a Debian 10 host and a Debian 10 guest)

1. Create the directory and update the permissions so libvirtd-qemu has access:

host $ mkdir vmshared
@kylewlacy
kylewlacy / prepend-append.sh
Last active February 24, 2022 09:25
How to prepend or append to a variable in bash
# Prepend to a variable
export PATH=/foo${PATH:+:$PATH} # Set path to "/foo:$PATH", or "/foo" if $PATH is empty
# Append to a variable
export PATH=${PATH:+$PATH:}/foo # Set path to "$PATH:/foo", or "/foo" if $PATH is empty

Keybase proof

I hereby claim:

  • I am kylewlacy on github.
  • I am kylewlacy (https://keybase.io/kylewlacy) on keybase.
  • I have a public key ASDjZ5rjzY281WRUgbzoHHVpqkAfc3IjfxWzuNtSbLv-FQo

To claim this, I am signing this object:

@kylewlacy
kylewlacy / nixos-install.log
Created March 10, 2018 07:30
Fix for error during NixOS UEFI installation: "Failed to create EFI Boot variable entry: No such file or directory"
# Tested with nixos-minimal-18.03pre130932.cc4677c36ee-x86_64-linux.iso
# Manually mounted /mnt (NixOS root), /mnt/boot (mkfs.ext4 Grub partition), /mnt/boot/efi (mkfs.vfat for EFI boot vars)
[root@nixos:~]# cat /mnt/etc/nixos/hardware-configuration.nix
# Do not modify this file! It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:
{
@kylewlacy
kylewlacy / kexec-installer.nix
Created March 5, 2018 03:00 — forked from Mic92/kexec-installer.nix
kexec-based installer for nixos to install nixos from every linux!
## USAGE
# $ nix-build kexec-installer.nix
# can be deployed remote like this
# $ rsync -aL -e ssh result/ root@host:
# $ ssh root@host ./kexec-installer
## Customize it like this
# # custom-installer.nix
# import ./kexec-installer.nix {
# extraConfig = {pkgs, ... } {
# user.extraUsers.root.openssh.authorizedKeys.keys = [ "<your-key>" ];
@kylewlacy
kylewlacy / loopback-fix.md
Created September 11, 2017 21:53
Linux Mint - Fixing loopback device not starting at startup

Recently, I had an issue where I had no loopback device in Linux Mint 18.2 MATE, which occurred after upgrading from 18.1 MATE.

Diagnosis

ping localhost fails, nc -v -l -p 1234 followed by nc localhost 1234 does not connect, etc. Running ifconfig does not show a loopback device present.

Running sudo service network-manager restart and sudo service networking restart doesn't fix the issue, nor does restarting.

The only clue shows up when inspecting /var/log/syslog: