Skip to content

Instantly share code, notes, and snippets.

View linux4life798's full-sized avatar

Craig Hesling linux4life798

View GitHub Profile
@linux4life798
linux4life798 / golang_debian_control
Last active May 5, 2024 03:59
Build simple Golang binary package without packaging all dependencies
# You need the following entry in the control file:
XS-Go-Import-Path: github.com/linux4life798/cmpconflash

Manually Fix WIFI 6E Issue

sudo dpkg-divert --rename --add /usr/lib/firmware/mediatek/WIFI_MT7922_patch_mcu_1_1_hdr.bin
sudo dpkg-divert --rename --add /usr/lib/firmware/mediatek/WIFI_RAM_CODE_MT7922_1.bin
dpkg-divert --list
#pushd ~/src/linux-firmware/mediatek
@linux4life798
linux4life798 / sedutil-experimentation.bash
Created April 7, 2024 05:46
Demonstate how the sedutil-cli command works and how that works with a SED SSD.
ssd_show_data() {
sudo dd if=/dev/nvme0n1 bs=1 count=9000 status=none | hd
}
# ssd_write_data <data_message> [location]
#
# location is the offset in bytes.
ssd_write_data() {
local data="$1"
local location="${2:-0}" # In bytes
@linux4life798
linux4life798 / ddclient.conf
Last active December 9, 2023 04:15
Setup ddclient config for Google Nest router and Cloudflare using https://github.com/linuxserver/docker-ddclient
# This is an example ddclient configuration that uses fetch-nest-wan-ipv4.sh
# and Cloudflare.
# The fetch-nest-wan-ipv4.sh script must be in whatever working directory ddclient
# is run from, or change the below path to the command to be absolute.
######################################################################
##
## Define default global variables with lines like:
## var=value [, var=value]*
## These values will be used for each following host unless overridden
@linux4life798
linux4life798 / Dockerfile
Last active October 10, 2023 17:46
Docker setup local user/group
FROM debian:latest
ENV USER me
RUN useradd --create-home --user-group "${USER}"
# HOME will be set already within the container, after setting user, but we
# set it here to be usable from within this Dockerfile.
ENV HOME "/home/${USER}"
WORKDIR "${HOME}"
RUN pwd
@linux4life798
linux4life798 / find-change.bash
Created August 2, 2023 02:10
Find a text change that might have been seen by Git's dangling blob/commit history
#!/bin/bash
# Craig Hesling
#
# Find a change in Git's vast dangling blob/commmit archive.
#
# Usage: find-change.bash <grep-pattern1> [<grep-patter2> [grep-patterns...]]
mapfile -t LOST < <(git fsck --lost-found)
PATTERNS=( "$@" )
@linux4life798
linux4life798 / context-switch-vs-spin-wait.cc
Last active March 7, 2023 21:01
This self contained example shows the performance difference between using a classic context-switching semaphore vs. a spin waiting alternative.
#include <atomic>
#include <chrono>
#include <iostream>
#include <semaphore>
#include <thread>
/*
* g++ -std=c++20 context-switch-vs-spin-wait.cc && ./a.out
*/
@linux4life798
linux4life798 / ddclient.conf
Last active December 26, 2022 22:39
Fetch the external IP address from Google Nest WiFi router for ddclient
# This is an example ddclient configuration that uses fetch-nest-wan-ipv4.sh
# and Cloudflare.
# The fetch-nest-wan-ipv4.sh script must be in whatever working directory ddclient
# is run from, or change the below path to the command to be absolute.
######################################################################
##
## Define default global variables with lines like:
## var=value [, var=value]*
## These values will be used for each following host unless overridden
@linux4life798
linux4life798 / sample_noise_old.c
Created September 12, 2018 00:17
The somewhat broken CC2650 drivelib ADC with GPTimer
/*
* sample_noise.c
*
* Created on: Sep 10, 2018
* Author: Craig Hesling
*/
#include <xdc/runtime/System.h>
#include <ti/sysbios/BIOS.h> // BIOS_WAIT_FOREVER
#include <ti/sysbios/knl/Event.h>
@linux4life798
linux4life798 / generate_mqtt_client_id.go
Created July 10, 2018 18:08
Function to generate a random MQTT client ID with a common prefix
import CRAND "crypto/rand"
// GenMQTTClientID generates a random client id for mqtt
func GenMQTTClientID(prefix string) (string, error) {
r, err := CRAND.Int(CRAND.Reader, new(big.Int).SetInt64(100000))
if err != nil {
return "", fmt.Errorf("Failed to generate MQTT client ID: %v", err)
}
return prefix + r.String(), nil
}