Skip to content

Instantly share code, notes, and snippets.

@NikolasK-source
NikolasK-source / vz.md
Last active June 1, 2020 19:22 — forked from adlerweb/vz.md
Grafana MySQL query to visualize Volkszähler-Data

Using Channel-IDs (that's not UUID)

SELECT
  timestamp * 0.001 as time_sec, 
  data.value as value, 
  properties.value as metric
FROM data
  LEFT JOIN properties ON (properties.entity_id = data.channel_id)
  LEFT JOIN entities ON (entities.id = data.channel_id)
@NikolasK-source
NikolasK-source / senec_home_v2_1_li_data_request.sh
Last active February 16, 2024 11:44
Senec Home V2.1 1ph / Lithium json request
#!/bin/bash
#
# Copyright (C) 2022 Nikolas Koesling <nikolas@koesling.info>.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
@NikolasK-source
NikolasK-source / RandomString.hpp
Last active December 28, 2020 12:21
C++ "random" string
#pragma once
#include <random>
#include <string>
#include <ctime>
namespace RandomString {
static constexpr const char* DEFAULT_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
static std::default_random_engine random{static_cast<unsigned>(time(0))};
@NikolasK-source
NikolasK-source / endian.hpp
Last active July 7, 2024 07:53
C++ header to handle endianness (C++17)
/*
* Copyright (C) 2022 Nikolas Koesling <nikolas@koesling.info>.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
@NikolasK-source
NikolasK-source / dump-shm
Last active October 23, 2023 06:56
network.koesling.shm-modbus launcher scripts
#!/bin/bash
trap "" INT TERM QUIT
flatpak run network.koesling.shm-modbus dump-shm $@
ret=$?
if [ $ret -gt 128 ]; then
exit 0
fi
exit $ret
@NikolasK-source
NikolasK-source / dshm
Last active October 23, 2023 06:57
network.koesling.shm-modbus launcher scripts (shorter commands)
#!/bin/bash
trap "" INT TERM QUIT
flatpak run network.koesling.shm-modbus dump-shm $@
ret=$?
if [ $ret -gt 128 ]; then
exit 0
fi
exit $ret
@NikolasK-source
NikolasK-source / shm-modbus-signal-generator.py
Created June 28, 2023 08:19
System time based signal generator for stdin-to-modbus-shm
#!/usr/bin/python3
# MIT License
#
# Copyright (c) 2023 Nikolas Koesling <nikolas@koesling.info>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@NikolasK-source
NikolasK-source / rpgrep.py
Created September 1, 2023 06:29
Wrapper to simplify recursive grep with a pearl regex expression in the current working directory
#!/usr/bin/python
#
# Wrapper to simplify a recursive grep with a pearl compatible regular expression
#
# MIT License
#
# Copyright (c) 2023 Nikolas Koesling <nikolas@koesling.info>
#
alias dshm="dump-shm"
alias mbsig="shm-modbus-signal-gen"
alias mbtcp="modbus-tcp-client-shm"
alias mbrtu="modbus-rtu-client-shm"
alias shmrnd="shared-mem-random"
alias stdin2mb="stdin-to-modbus-shm"
alias wagomb="wago-modbus-coupler-shm"
alias wshm="write-shm"
@NikolasK-source
NikolasK-source / split_string.hpp
Last active November 22, 2023 19:13
C++ split string
/*
* MIT License
*
* Copyright (c) 2023 Nikolas Koesling <nikolas@koesling.info>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is