Skip to content

Instantly share code, notes, and snippets.

View larshei's full-sized avatar
🇺🇦

Lars Heinrichs larshei

🇺🇦
View GitHub Profile
# install docker in WSL
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
@larshei
larshei / LeafletMap.ex
Created September 19, 2023 19:58
Leaflet Map as Elixir Phoenix LiveView Component
defmodule Components.LeafletMap do
use Phoenix.Component
attr :class, :string, default: nil
def map(assigns) do
~H"""
<div style="overflow: hidden" phx-update="ignore" id="mapcontainer">
<div class={@class} phx-hook="Map" id="mapid"></div>
</div>
#!/bin/bash
# search pattern in linux/mac dictionary. Store findings to file.
word_endings=(
".*kee"
".*key"
".*ky"
".*que"
".*ki"
@larshei
larshei / fifo_buffer_test.c
Last active March 2, 2023 09:30
"test" and usage demonstration for fifo_buffer.c gist: https://gist.github.com/larshei/cec020e037b0ebd103ef6252977f8b12
/* ===========================================================================
* Lars Heinrichs, 2020
* Feel free to use this piece of code as desired. Provided as is, with no
* guarantees.
*
* "Tests" (in quotes!) for
* https://gist.github.com/larshei/cec020e037b0ebd103ef6252977f8b12
* Verifies basic behaviour.
*
* Use the gist above if you quickly need a ring buffer and do not care about
@larshei
larshei / fifo_buffer.c
Last active March 2, 2023 09:30
Tired of writing the same buffer functions all the time? not interested in setting up some fully blown buffer system? here you go. Quick and dirty fifo and ring buffer implementation in C as a single source file "include". Test and example usage at https://gist.github.com/larshei/444ecee2a90174757b49ac1fe85f604a
/* ============== FIFO BUFFER ============================================== */
/* After writing another small fifo buffers the 100th time, I created this gist.
* It is a QUICK AND DIRTY solution to get the standard functions of a fifo, namely
* - add and read elements
* - check if empty
* - reset
*
* ============== USAGE ======================================================
* 1. #define the FIFO_DATA_TYPE, FIFO_BUFFER_SIZE and FIFO_MEMORY.
* 2. Optionally: define FIFO_OVERWRITE_WHEN_FULL for ring buffer like behaviour
@larshei
larshei / compare_divide_multiply_pointer_index.c
Last active May 17, 2020 01:05
This is just to give you an idea of the times required to perform the same action in different ways.
// compare times rquired for multiply and divide as well as pointer and array index addressing.
// e.g. from a small port to an STM32F4:
// Required times to scale the 1000 values to max=1.0 for 8192 times:
// Multiply, pointers: 14400
// Multiply, index: 15938
// Divide , pointers: 21077
// Divide , index: 19530
// The difference is actually a lot smaller than I expected.
#include <time.h>
@larshei
larshei / .clang-format
Created May 13, 2020 07:26
My default config for .clang-format. Place this in e,g, the root folder of your project. May be used by e.g. Visual Code to autoformat code sections or whole files.
# =========== C / Cpp ==============
Language: Cpp
TabWidth: 4
IndentWidth: 4
UseTab: Never
AlignAfterOpenBracket: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
# AlignConsecutiveMacros: true # not working 'unknown key' error
AlignEscapedNewlines: Left
@larshei
larshei / ceedling.yaml
Last active March 2, 2023 09:28
Ceedling for Github Actions
name: Ceedling Unit Test
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]
jobs:
test: