Skip to content

Instantly share code, notes, and snippets.

View zopieux's full-sized avatar

Alexandre Macabies zopieux

View GitHub Profile
@zopieux
zopieux / satisfiactory-status.nix
Created October 19, 2024 19:15
Satisfactory status (API) to Discord message
{
systemd.timers.satisfactory-status = lib.mkIf botEnabled {
description = "Satisfactory status to Discord";
wantedBy = [ "timers.target" ];
requires = [ "network-online.target" ];
timerConfig = {
OnCalendar = "minutely";
Persistent = true;
};
};
@zopieux
zopieux / essentia_bpm.py
Created August 11, 2024 17:59
BPM detection with essentia
import essentia
import essentia.standard as es
# Initialize the audio loader
loader = es.MonoLoader(filename='path_to_your_audio_file.mp3')
# Load the audio
audio = loader()
# Initialize the RhythmExtractor2013
@zopieux
zopieux / pgvectors_sqlx.rs
Created July 10, 2024 20:08
pgvecto.rs & sqlx interrop
use std::ops::Deref;
use sqlx::encode::IsNull;
use sqlx::error::BoxDynError;
use sqlx::postgres::{PgArgumentBuffer, PgTypeInfo, PgValueRef};
use sqlx::{Decode, Encode, Postgres, Type};
/// A vector.
#[derive(Clone, PartialEq, Default)]
pub struct Vector(Vec<f32>);
@zopieux
zopieux / ffmpeg_to_hls_6s_latency_chromecast.sh
Created May 3, 2024 22:49
Chromecast friendly HLS from any live input (latency ~6s)
ffmpeg -y -f lavfi -i color=c=black:s=128x128:r=25/1 \
-f pulse -ac 2 -i pulse[or source name] \
-fflags nobuffer -vcodec libx264 -r 24 -preset superfast -pix_fmt yuv420p -g 6 \
-hls_list_size 3 -hls_time 1 -hls_flags delete_segments -strict -2 out.m3u8
height = 40; width = 80; depth = 80;
thickness = 2.7; cornerRadius = 10; tabLength = 10;
slotRepeatMin=2; slotLengthMin=20; slotLengthGap = 2; slotWidth = 0.2;
PI = 3.142*1.02; //Add a fudge factor for the bend radius
function hingeLength(angle, radius) = 2*PI*radius*(angle/360);
//Use true to generate 3D models of the box parts
//Use false to generate 2D models which can be exported
@zopieux
zopieux / living_hinge.inx
Last active February 11, 2024 00:02
Modernize version of the Living Hinge extension that works on recent Inkscape versions
<?xml version="1.0" encoding="UTF-8"?>
<inkscape-extension xmlns="http://www.inkscape.org/namespace/inkscape/extension">
<_name>Living Hinge</_name>
<id>org.lvl1.living_hinge</id>
<dependency type="executable" location="extensions">living_hinge.py</dependency>
<param name="unit" _gui-text="Unit" type="enum">
<_item value="mm">mm</_item>
<_item value="cm">cm</_item>
#! /usr/bin/env nix-shell
#! nix-shell -i python3 -p "python3.withPackages (p: [ p.numpy ])"
import json
import sys
import numpy as np
import collections
import binascii
data = json.load(open(sys.argv[1]))
@zopieux
zopieux / panzoom.js
Created December 25, 2023 23:29
SVG *coordinate* (abstract, manual, maths) pan zoom, *not* using SVG transforms
const s = document.querySelector('svg');
const [c1, c2] = [...s.querySelectorAll('circle')];
const mat = new DOMMatrix();
let origScene = null, lastWorld = null;
s.addEventListener('mousedown', (evt) => {
lastWorld = { x: evt.offsetX || (evt.pageX - s.offsetLeft), y: evt.offsetY || (evt.pageY - s.offsetTop) };
origScene = new DOMPoint(lastWorld.x, lastWorld.y).matrixTransform(mat.inverse());
});
@zopieux
zopieux / dune3d.nix
Created October 28, 2023 16:55
dune3d nix package
{ stdenv, fetchFromGitHub, meson, pkg-config, cmake, ninja, python3, gobject-introspection, gtkmm4, libepoxy, eigen, opencascade-occt, mimalloc, glm, libuuid, range-v3, librsvg }:
stdenv.mkDerivation {
pname = "dune3d";
version = "9af108e";
src = fetchFromGitHub {
owner = "dune3d";
repo = "dune3d";
rev = "9af108e591b3cdadf71f23e366f72dc8af8359bf";
@zopieux
zopieux / 0001-Audio-export-conversion-hack-for-training-aids.patch
Created September 21, 2023 20:55
MuseScore audio export hack for training aids
From bbd014bf407b2ec97fa18cca89d46d1867f62c83 Mon Sep 17 00:00:00 2001
From: Alexandre Macabies <[email protected]>
Date: Thu, 21 Sep 2023 22:53:31 +0200
Subject: [PATCH] Audio export conversion hack for training aids.
---
default.nix | 174 +++++++++++++
flake.lock | 61 +++++
flake.nix | 27 ++
src/app/app.cpp | 2 +