Skip to content

Instantly share code, notes, and snippets.

View mfenniak's full-sized avatar

Mathieu Fenniak mfenniak

View GitHub Profile
@mfenniak
mfenniak / immich.nix
Last active April 2, 2024 23:24
NixOS configuration for Immich, based upon upstream docker-compose.yml
{ config, ... }:
let
immichHost = "immich.example.com"; # TODO: put your immich domain name here
immichRoot = "/tank/immich"; # TODO: Tweak these to your desired storage locations
immichPhotos = "${immichRoot}/photos";
immichAppdataRoot = "${immichRoot}/appdata";
immichVersion = "release";
immichExternalVolume1 = "/tank/BackupData/Google Photos/someone@example.com"; # TODO: if external volumes are desired
@mfenniak
mfenniak / YNAB_Report____Google_Sheets.json
Created October 31, 2023 18:50
n8n Integration to Copy Data from YNAB to Google Sheets
{
"name": "YNAB Report -> Google Sheets",
"nodes": [
{
"parameters": {},
"name": "Start",
"type": "n8n-nodes-base.start",
"typeVersion": 1,
"position": [
-520,
@mfenniak
mfenniak / detect-reboot-needed.nix
Created January 6, 2023 15:39
NixOS module that provides hourly notifications when a reboot is needed for a kernel, initrd, or kernel-module upgrade
{ pkgs, ... }:
let
readlink = "${pkgs.coreutils}/bin/readlink";
notify-send = "${pkgs.libnotify}/bin/notify-send";
in {
systemd.user.services.detect-reboot-for-upgrade = {
script = ''
set -eu -o pipefail
@mfenniak
mfenniak / mdcheck.nix
Last active December 4, 2022 21:29
NixOS module to add mdcheck capabilities, which automatically scrubs swraid md devices on a fixed schedule; eventually I'd like to upstream this to nixpkgs but just shoved it here for now...
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.hardware.raid.swraid.monitor;
in
{
options.hardware.raid.swraid.monitor = {
@mfenniak
mfenniak / gist:2978805
Created June 23, 2012 16:01
An extension of Flask that adds file hashes to static file URLs built by url_for("static"...)
import os.path
import contextlib
import hashlib
from flask import Flask
from flask.helpers import safe_join
# Injects an "h" parameter on the URLs of static files that contains a hash of
# the file. This allows the use of aggressive cache settings on static files,
# while ensuring that content changes are reflected immediately due to the
# changed URLs. Hashes are cached in-memory and only checked for updates when
@mfenniak
mfenniak / generate_dialogs.py
Created May 7, 2013 13:13
Script to convert a graphviz file (idempotent.dot) into an HTML + svg file with clickable nodes and edges that display data in a Bootstrap dialog. Used to generate https://mathieu.fenniak.net/idempotent-api-roadmap-prototype/, a prototype of a graph-based information delivery system. This script is a real ... efficient use of developer time. It …
import pydot
import subprocess
import sys
import re
print """<!DOCTYPE html>
<html>
<head>
<title>Idempotency Concept Roadmap Prototype</title>
<link href="https://mathieu.fenniak.net/wp-content/uploads/2013/05/bootstrap.min_.css" rel="stylesheet" media="screen">
@mfenniak
mfenniak / sink-pin.rs
Created February 21, 2021 20:45
Not sure how to resolve this Rust compilation issue
pub struct SqsSink {
// ...snip...
sqs_client: SqsClient,
send_message_future: Option<std::pin::Pin<std::boxed::Box<dyn futures::Future<Output = std::result::Result<rusoto_sqs::SendMessageBatchResult, rusoto_core::RusotoError<rusoto_sqs::SendMessageBatchError>>> + std::marker::Send>>>,
}
impl Sink<Arc<Box<dyn MessageChunk>>> for SqsSink {
type Error = ();
// ...snip...
fn poll_flush(mut self: std::pin::Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
fun printGraphviz(builder: TopologyBuilder) {
println("digraph {")
val nodeGroups = builder.nodeGroups()
val processorTopologys = nodeGroups.map { kv -> builder.build(kv.key) }
val sourceTopics = processorTopologys.flatMap { it.sourceTopics() }
val sinkTopics = processorTopologys.flatMap { it.sinkTopics() }
val allTopics = sourceTopics.plus(sinkTopics).distinct().sorted()
println(" node [shape=\"rect\"]")
@mfenniak
mfenniak / dashboard.json
Last active January 25, 2020 15:07
iotawatt power & energy Grafana dashboard
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@mfenniak
mfenniak / gist:d1bfa2c1c94ee9980113e70ba19ca563
Created May 23, 2017 14:04
4.9.27-14.31.amzn.x86_64 ena issue
May 21 12:05:37 ip-172-16-15-126 ec2net: [get_meta] Trying to get http://169.254.169.254/latest/meta-data/network/interfaces/macs/06:1e:aa:71:34:ca/local-ipv4s
May 21 12:05:37 ip-172-16-15-126 ec2net: [rewrite_aliases] Rewriting aliases of eth0
May 21 12:06:50 ip-172-16-15-126 dhclient[3314]: XMT: Solicit on eth0, interval 125920ms.
May 21 12:07:59 ip-172-16-15-126 consul[3614]: 2017/05/21 12:07:59 [INFO] consul: New leader elected: i-0f14d98ae903e7de2
May 21 12:08:56 ip-172-16-15-126 dhclient[3314]: XMT: Solicit on eth0, interval 114310ms.
May 21 12:10:51 ip-172-16-15-126 dhclient[3314]: XMT: Solicit on eth0, interval 119760ms.
May 21 12:12:51 ip-172-16-15-126 dhclient[3314]: XMT: Solicit on eth0, interval 115570ms.
May 21 12:13:36 ip-172-16-15-126 consul[3614]: 2017/05/21 12:13:36 [INFO] serf: attempting reconnect to i-0bd3ab67982f1fe55 172.16.17.249:8301
May 21 12:14:46 ip-172-16-15-126 dhclient[3314]: XMT: Solicit on eth0, interval 114980ms.
May 21 12:15:54 ip-172-16-15-126 consul[3614]: 2017/