Skip to content

Instantly share code, notes, and snippets.

@pixelprodev
pixelprodev / gist:190b6b9fa16b443e9c1668ad65003f45
Last active April 11, 2025 17:08
Domain Object Style state management using @preact/signals-react and React 19

I'll preface this by saying I have a LOT of freedom in the app that I'm currently working on, and I've taken that liberty to push the envelope of curiosities. I recently read about signals (specifically @preact/signal-react) and it got me to thinking. This is the brainchild first iteration of this. I am posting this with hopes that one of two things happen. I hope first and foremost that I can learn from someone in some way here. If I'm short-sighted or missing something, point it out, please. I've been coding for years but still feel brand new and still make a lot of mistakes. If it helps someone else learn something, well that's ok too.

Conceptually, I build my domain objects using a building block class that I call a "ReactiveMap". Feel free to swap this out for any type of implementation you want to use for your domain model's base, but this works for my particular use case.

The ReactiveMap mimics the api of a javascript Map object with some utility additions, and adds the ability for you to

Book on JavaScript

  • If you see a JavaScript feature in this book that you don’t understand, you can look it up in my book “Exploring JavaScript” which is free to read online. Some of the “Further reading” sections at the ends of chapters refer to this book.

Books on TypeScript

@wqyeo
wqyeo / Mullvad-VPN-OpenSUSE.md
Created May 9, 2024 14:54
Installation Guide for Mullvad VPN, OpenSUSE

How to rebuild Mullvad VPN for openSUSE Tumbleweed & Leap

Credits to a Reddit Thread.
This guide is 90% similar but with few more instructions to be beginner friendly...

Mullvad VPN comes with a Fedora RPM package. However, there might be dependencies issues when using it directly on OpenSUSE.
Hence, a good solution is to rebuild the RPM package for OpenSUSE.

1) Downloading the original RPM

  1. Open a Terminal/Console. (If you like a cleaner workspace, make a new directory, and cd into it)
  2. On the Mullvad VPN's website, find the current version of the linux package.It should be stated as something similar to "Latest version: 2024.2"
@OrionReed
OrionReed / dom3d.js
Last active June 4, 2026 22:02
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@jakub-g
jakub-g / async-defer-module.md
Last active June 4, 2026 20:19
async scripts, defer scripts, module scripts: explainer, comparison, and gotchas

<script> async, defer, async defer, module, nomodule, src, inline - the cheat sheet

With the addition of ES modules, there's now no fewer than 24 ways to load your JS code: (inline|not inline) x (defer|no defer) x (async|no async) x (type=text/javascript | type=module | nomodule) -- and each of them is subtly different.

This document is a comparison of various ways the <script> tags in HTML are processed depending on the attributes set.

If you ever wondered when to use inline <script async type="module"> and when <script nomodule defer src="...">, you're in the good place!

Note that this article is about <script>s inserted in the HTML; the behavior of <script>s inserted at runtime is slightly different - see Deep dive into the murky waters of script loading by Jake Archibald (2013)

const handler = {
get(target, propKey, receiver) {
if (/^_[0-9]+$/.test(propKey)) {
const result = [];
const first = Number(receiver);
const last = Number(propKey.slice(1));
for (let i=first; i<=last; i++) {
result.push(i);
}
return result;
@sportebois
sportebois / markdown_in_shell.sh
Created February 10, 2018 18:38
Read markdown file in the command line
# Markdown utilities (requires `brew install pandoc`)
function mdless () {
local mdfile=$1
if [ -z ${mdfile:+x} ]; then mdfile="README.md"; fi
case $mdfile in
-h | --help)
print "mdless usage: 'mdless myfile.md' or 'mdless' (defaults to README.md)"
;;
*)
mdcat $mdfile | less
@randallreedjr
randallreedjr / heroku-remote.md
Last active December 2, 2025 13:28
Add a Heroku remote to an existing git repo

Working with git remotes on Heroku

Generally, you will add a git remote for your Heroku app during the Heroku app creation process, i.e. heroku create. However, if you are working on an existing app and want to add git remotes to enable manual deploys, the following commands may be useful.

Adding a new remote

Add a remote for your Staging app and deploy

Note that on Heroku, you must always use master as the destination branch on the remote. If you want to deploy a different branch, you can use the syntax local_branch:destination_branch seen below (in this example, we push the local staging branch to the master branch on heroku.

$ git remote add staging https://git.heroku.com/staging-app.git