Skip to content

Instantly share code, notes, and snippets.

@cyber-murmel
cyber-murmel / hamming.c
Last active July 5, 2023 06:06
Hamming 63 57 in C
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h> // compile with -lm
#define MASK(LEN) ((1<<LEN)-1)
#define GET_BITS(VAR, POS, NUM) ((VAR>>POS) & MASK(NUM))
#define GET_BIT(VAR, POS) GET_BITS(VAR, POS, 1)
@cyber-murmel
cyber-murmel / openwrt-espressobin_ultra.md
Last active January 28, 2024 05:43
OpenWRT on ESPRESSObin Ultra

OpenWRT supports the ESPRESSObin Ultra since 2020. Official builds are available.

In thins gist I want to explain how to install the image onto the board via a USB thumb drive.

All you need

  • ESPRESSObin Ultra
  • 12V 2A DC or PoE power supply
  • USB A to USB Micro-B cable
  • wired internet connection
@cyber-murmel
cyber-murmel / satisfactory.nix
Last active December 1, 2024 20:52
Dedicated Satisfactory 5 Server on NixOS
{config, pkgs, lib, ...}: {
users.users.satisfactory = {
home = "/var/lib/satisfactory";
createHome = true;
};
nixpkgs.config.allowUnfree = true;
systemd.services.satisfactory = {
wantedBy = [ "multi-user.target" ];
@cyber-murmel
cyber-murmel / bmp_rts_dtr.patch
Created January 28, 2022 20:26
Patch to add RTS on PB8 and DTR on PB9 to the Black Magic Probe UART
diff --git a/src/platforms/common/cdcacm.c b/src/platforms/common/cdcacm.c
index 399dd3d..d56d10e 100644
--- a/src/platforms/common/cdcacm.c
+++ b/src/platforms/common/cdcacm.c
@@ -451,12 +451,17 @@ static enum usbd_request_return_codes cdcacm_control_request(usbd_device *dev,
case USB_CDC_REQ_SET_CONTROL_LINE_STATE:
cdcacm_set_modem_state(dev, req->wIndex, true, true);
/* Ignore if not for GDB interface */
- if(req->wIndex != GDB_IF_NO)
+ switch(req->wIndex) {
@cyber-murmel
cyber-murmel / NixOS_on_Hetzner_Cloud.md
Last active April 16, 2025 13:21
NixOS on Hetzner Cloud

This is the gist of how to setup a NixOS server on a Hetzner Cloud instance with an admin user, ssh access and configuration management via git.

  1. Create a Hetzner Cloud instance and click to enter it.
  2. Stop the instance (top right corner icon).
  3. Go to ISO Images.
  4. Search for "nixos" and click mount. ISO Images tab of a Hetzner Cloud instance with the NixOS image already mounted
  5. Start the instance again (top right corner icon).
  6. Open the console (top right corner icon).
  7. Get the IP address by executing ip --brief --color address. The address can also be optained from the Hetzner Cloud web interface.

This gist shows you how to install Minecraft Forge on a NixOS server. It is based on my NixOS on Hetzner Cloud gist.

  1. Add ./minecraft.nix to the imports in ~/repos/configuration/default.nix.
  2. Paste the following in ~/repos/configuration/minecraft.nix.
{ config, pkgs, ... }:

{
  users = {
@cyber-murmel
cyber-murmel / hardware-configration-infinitybook-pro-14.nix
Last active February 28, 2024 21:23
Nixos Hardware Config fo TUXEDO InfinityBook Pro 14 - Gen7 (MK1)
{ config, pkgs, lib, ... }:
let
nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" ''
export __NV_PRIME_RENDER_OFFLOAD=1
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __VK_LAYER_NV_optimus=NVIDIA_only
exec "$@"
'';
@cyber-murmel
cyber-murmel / IceSL.nix
Last active April 23, 2024 15:27
Nix expression to build @shapeforge IceSL modeler and slicer https://icesl.loria.fr/
# build with `nix-build IceSL.nix`
{ pkgs ? import
(builtins.fetchGit {
name = "nixos-22.11-2023_01_01";
url = "https://github.com/nixos/nixpkgs/";
ref = "refs/heads/nixos-22.11";
rev = "913a47cd064cc06440ea84e5e0452039a85781f0";
})
{ }
size = 1;
dx = 25;
dy = 25;
module striped_square(size = 1, length = 1, num_stripes = 2) {
color("teal")
for(stripe = [1:num_stripes]) {
if((stripe % 2) == 1) {
polygon([[stripe-1, 0], [stripe,0], [0, stripe], [0,stripe-1]]*size/num_stripes);
}
@cyber-murmel
cyber-murmel / picoprobe-dev-env-shell.nix
Last active April 4, 2023 15:25
picoprobe development environment
{
pkgs ?
import (builtins.fetchGit {
name = "nixos-22.11-2023_01_14";
url = "https://github.com/nixos/nixpkgs/";
ref = "refs/heads/nixos-22.11";
rev = "e285dd0ca97c264003867c7329f0d1f4f028739c";
}) {}
}: