Skip to content

Instantly share code, notes, and snippets.

View kmpm's full-sized avatar

Peter Magnusson kmpm

View GitHub Profile
@kmpm
kmpm / adding-pixel-to-raspbian-lite.md
Last active March 23, 2024 19:31
Adding PIXEL to Raspbian Lite

Adding PIXEL/GUI to Raspbian Lite

These 'notes' were primarily intended for my own consumption but since there have been surprisingly many comments to it over the years I wanted to do some updates and clarifications. Thanks for all comments.

These instructions will require you to have connection to internet from your pi, WiFi, Ethernet or by some other means like a 3G USB dongle or something.

Preparations

@kmpm
kmpm / Git-and-SCM-in-Swedish.md
Last active March 4, 2024 15:09
Git och kodhantering på svensk-engelska

Git och kodhantering på svensk-engelska

Det har funnints många försök att översätta terminologin som man använder i git och kodhantering, a´la github, gitlab och gitea, till svenska utan att man enligt mitt tycke träffat rätt. Nu kommer det här bli ytterligare ett inlägg i historien som inte heller träffar rätt men jag gör ett försök ändå.

Min huvudtanke är att behålla engelskan i ganska lång utsträckning vad det gäller själva programmet gitdå man annars kommer ifrån det som kommandon, hjälptexter och google-sökningar faktiskt använder som terminiologi och detta tycker jag är olyckligt.

@kmpm
kmpm / incus.py
Created February 18, 2024 18:02
Incus inventory for ansible
#!/usr/bin/env python3
import json
import httpx
target_host = "localhost"
socket_path = "/var/lib/incus/unix.socket"
transport = httpx.HTTPTransport(uds=socket_path)
@kmpm
kmpm / lock.go
Created March 29, 2023 14:24
Using NATS KV for creating locks.
package lock
import (
"context"
"errors"
"strings"
"sync"
"time"
"testapp/logger"
@kmpm
kmpm / install-weasyproxy.sh
Last active March 23, 2023 00:21
Small file that installes ad uses weasyprint instead of wkhtmltopdf on linuxserver bookstack containers..
#!/bin/bash
# SPDX-FileCopyrightText: 2022 Peter Magnusson <me@kmpm.se>
#
# SPDX-License-Identifier: CC0-1.0
#
# This file installs weasyprint and creates a script that
# tries to proxy calls from bookstack to what it believe is
# wkhtmltopdf.
#
# put this file in /custom-cont-init.d and restart the container
@kmpm
kmpm / nats-setup-win.ps1
Last active March 20, 2023 19:17
A skeleton of a PowerShell Script that install the lates nats.io tools on windows
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[String]$Destination,
[Parameter(ValueFromPipelineByPropertyName)]
[Switch]$WithServer,
[Switch]$WithNsc
)
$ErrorActionPreference = 'Stop'
@kmpm
kmpm / nats-setup-linux.sh
Last active March 10, 2023 15:19
install various nats.io tools on linux
#!/bin/bash
# curl -fsSL https://gist.githubusercontent.com/kmpm/a83912c95009561ff6c6dcc9a2373751/raw/nats-setup-linux.sh | bash
export DEBIAN_FRONTEND=noninteractive
apt-get install -y unzip curl
echo "Downloading nsc install script"
curl -fsSL https://raw.githubusercontent.com/nats-io/nsc/master/install.sh -o /tmp/nsc-install.sh
echo "Running nsc install script"
@kmpm
kmpm / lowrance_sl2.hexpat
Last active February 17, 2023 15:12
imhex pattern file for parsing lowrance .sl2 files
#include <std/mem.pat>
#include <std/io.pat>
#include <std/math.pat>
#pragma endian little
#define MAX_RECORDS 1024
#define POLAR_EARTH_RADIUS 6356752.3142
@kmpm
kmpm / main.go
Last active July 27, 2022 05:31
bun-check for has-many relations with composite keys
package main
import (
"context"
"database/sql"
"fmt"
"os"
_ "github.com/denisenkom/go-mssqldb"
"github.com/uptrace/bun"
@kmpm
kmpm / norminv.js
Last active March 17, 2022 16:00
Compute the quantile function for the normal distribution. - like Excel NORMINV
/// Original C++ implementation found at http://www.wilmott.com/messageview.cfm?catid=10&threadid=38771
/// C# implementation found at http://weblogs.asp.net/esanchez/archive/2010/07/29/a-quick-and-dirty-implementation-of-excel-norminv-function-in-c.aspx
/*
* Compute the quantile function for the normal distribution.
*
* For small to moderate probabilities, algorithm referenced
* below is used to obtain an initial approximation which is
* polished with a final Newton step.
*
* For very large arguments, an algorithm of Wichura is used.