Skip to content

Instantly share code, notes, and snippets.

View esamattis's full-sized avatar

Esa-Matti Suuronen esamattis

View GitHub Profile
@esamattis
esamattis / ColdWater
Last active June 3, 2026 14:38
Reading Hydrodigit-S1 water meter with iM871A-USB and wmbusmeters to Home Asisstant sensor
# /etc/wmbusmeters.d/ColdWater
name=ColdWater
# the id printed on the meter
id=030xxxxx
key=NOKEY
driver=hydrodigit

SketchyBar widget for Github Copilot AI credits budget usage. Requires uses level budget to be set.

image
@esamattis
esamattis / utils.tsx
Created September 17, 2018 19:01
Typescript DeepRequired
type NotNill<T> = T extends null | undefined ? never : T;
type Primitive = undefined | null | boolean | string | number | Function;
type DeepRequired<T> = T extends Primitive
? NotNill<T>
: {
[P in keyof T]-?: T[P] extends Array<infer U>
? Array<DeepRequired<U>>
: T[P] extends ReadonlyArray<infer U2>
@esamattis
esamattis / Dockerfile
Last active January 19, 2026 10:22
How to deploy a single app to a container from a pnpm monorepo using `pnpm deploy` in Github Actions
FROM node:14-slim
ENV NODE_ENV=production
COPY pnpm-deploy-output /app
WORKDIR /app
ENTRYPOINT ["/app/entrypoint.sh"]
@esamattis
esamattis / launch.json
Last active July 23, 2025 11:40
Debug jest tests in vscode with pnpm
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"runtimeExecutable": "sh", // <-- The important bit!
"program": "node_modules/.bin/jest",
"args": ["${relativeFile}"],
@esamattis
esamattis / .gitignore
Created September 7, 2016 10:42 — forked from salcode/.gitignore
.gitignore file for WordPress - Bare Minimum Git
# -----------------------------------------------------------------
# .gitignore for WordPress
# Bare Minimum Git
# http://ironco.de/bare-minimum-git/
# ver 20150227
#
# This file is tailored for a WordPress project
# using the default directory structure
#
# This file specifies intentionally untracked files to ignore
@esamattis
esamattis / elements.js
Last active August 12, 2024 09:39
jsdoc type guards for dom elements
/**
* @template {keyof HTMLElementTagNameMap} T
* @param {any} el
* @param {T} elName
* @returns {el is HTMLElementTagNameMap[T]}
*/
function isElement(el, elName) {
return el?.constructor?.name === elName;
}
@esamattis
esamattis / HTMLEntities.php
Last active July 24, 2024 18:10
Automatically decode HTML entities from wp-graphql content fields
<?php
/**
* WordPress does automatic HTML entity encoding but so does React which
* results in double encoding. This reverts the one from WordPress when
* the content is requested using wp-graphql making your life as a React
* dev easier.
*
*/
class HTMLEntities
@esamattis
esamattis / type.scpt
Last active May 30, 2024 10:47
Type file contents using Apple Script on macOs
-- usage: osascript type.scpt <file>
on run {filePath}
set posixFilePath to filePath
set fileContent to do shell script "cat " & quoted form of posixFilePath
log "Will start typing in 3 seconds..."
delay 3
tell application "System Events"
set initialAppName to name of first application process whose frontmost is true
beep 1
log "Typing into: " & initialAppName
$ cat Cargo.toml
[package]
name = "rustdepstest"
version = "0.1.0"
edition = "2021"
[dependencies]
swc = "0.264.38"
$ cargo tree