Skip to content

Instantly share code, notes, and snippets.

View mpellegrini's full-sized avatar

Michael Pellegrini mpellegrini

View GitHub Profile
@mediacutlet
mediacutlet / HA_Voice_Shuffle_Plex.yaml
Last active April 20, 2025 15:29
Home Assistant Script to Enable LLM Voice Assistants to Shuffle Plex TV Shows
sequence:
- variables:
tv_show_query: " { other_tv_show_title } "
- if:
- condition: or
conditions:
- condition: state
entity_id: media_player.living_room
state: "off"
- condition: state
@dvins
dvins / pnpm-peerdependency-override.md
Last active February 24, 2025 00:53
Overriding A Peer Dependency With PNPM

Overriding A Peer Dependency With PNPM

This guide explains how to override peer dependencies in a PNPM monorepo by using a custom hook. It provides a step-by-step solution to ensure consistent versioning across packages that rely on different versions of the same dependency.

Background

When working with a monorepo a challenges arises if you need to use multiple versions of the same package.

Nominally, this can be solved through package aliases and overides. However, a particularly sticky situation is when downstream packages rely peer dependencies of uptstream packages you need two or more versions of.

@EdamAme-x
EdamAme-x / mergeRoutes.ts
Created July 17, 2024 09:29
Hono MergeRoutes
import { Hono } from 'hono';
import type { MergeSchemaPath, MergePath, Env, Schema } from 'hono/types';
export interface Module {
path: string
routes: Hono
}
export function mergeRoutes<T extends Module[], H extends Hono>(base: H, ...routes: T) {
for (const route of routes) {
@rphlmr
rphlmr / clear-db.ts
Last active April 22, 2025 18:38
Drizzle snippets
// Credits to Louistiti from Drizzle Discord: https://discord.com/channels/1043890932593987624/1130802621750448160/1143083373535973406
import { sql } from "drizzle-orm";
const clearDb = async (): Promise<void> => {
const query = sql<string>`SELECT table_name
FROM information_schema.tables
WHERE table_schema = 'public'
AND table_type = 'BASE TABLE';
`;
@PabloSzx
PabloSzx / test-esm.mjs
Created August 12, 2021 16:45
Quick test Node.js ESM
// Using:
// [email protected]
// [email protected]
import globby from 'globby';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import chalk from 'chalk';
async function main() {
@Alia5
Alia5 / cheatsheet.ts
Last active October 25, 2024 07:19
Advanced Typescript Cheatsheet
export type Await<T> = T extends PromiseLike<infer U> ? Await<U> : T;
export type IsPromise<T> = PromiseLike<infer U> ? true : false;
export type Length<T> = T extends { length: infer L } ? L : never;
export type KeysOfType<O, T> = {
[K in keyof O]: O[K] extends T ? K : never;
}[keyof O];
// ConvertLiterals would convert literal types like `1337` to their base type like `number` if set to true
/** Used by Flavor to mark a type in a readable way. */
export interface Flavoring<FlavorT> {
_type?: FlavorT;
}
/** Create a "flavored" version of a type. TypeScript will disallow mixing flavors, but will allow unflavored values of that type to be passed in where a flavored version is expected. This is a less restrictive form of branding. */
export type Flavor<T, FlavorT> = T & Flavoring<FlavorT>;
/** Used by Brand to mark a type in a readable way. */
export interface Branding<BrandT> {
_type: BrandT;
@gam-phon
gam-phon / docker-compose.yml
Last active April 24, 2022 09:42
pi-hole and DNS over HTTPS docker-compose
version: "3"
# Thanks to https://visibilityspots.org/dockerized-cloudflared-pi-hole.html
# echo "alias dns-up='cd /path/to/folder; docker-compose up -d'" >> ~/.bash_profile
services:
dns-over-https:
container_name: dns-over-https
image: fardog/secureoperator:latest # google dns
# image: visibilityspots/cloudflared:amd64 # cloudflare dns
restart: unless-stopped
networks:
@jokeru
jokeru / aws_delete-default-vpc.sh
Created March 31, 2018 15:14
Script to delete all AWS default VPCs from all regions using AWS CLI
#!/usr/bin/env bash
if [ "$AWS_PROFILE" = "" ]; then
  echo "No AWS_PROFILE set"
  exit 1
fi
for region in $(aws ec2 describe-regions --region eu-west-1 | jq -r .Regions[].RegionName); do
@TechnologistAU
TechnologistAU / unifi.sh
Last active October 10, 2019 02:57
UniFi 5 Installation Script for Raspberry Pi
#!/bin/bash
################################################################################
#
# This script automates the installation of the UniFi controller software on the
# Raspberry Pi.
#
# http://www.technologist.site/ubnt
#
################################################################################