Skip to content

Instantly share code, notes, and snippets.

View herrphon's full-sized avatar

Alexander von Renteln herrphon

View GitHub Profile
@herrphon
herrphon / MQTT_Node-Red_Influx.md
Created October 7, 2023 21:21 — forked from Paraphraser/MQTT_Node-Red_Influx.md
Efficient recipe for getting MQTT data into an InfluxDB database using Node-Red

Recipe: from MQTT to InfluxDB via Node-Red

Introduction

Getting data produced by IoT sensors into a database is practically a mandatory step before effective visualisation (eg dashboards).

This recipe shows you how to get an MQTT payload into an InfluxDB database using three Node-Red nodes. It makes the following assumptions:

  • A client device of some kind publishing data to a topic via the MQTT protocol;
  • Mosquitto (MQTT broker);
@herrphon
herrphon / web-servers.md
Created May 31, 2023 21:37 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
def hash_to_param(myMap) {
myMap.collect { k, v -> [$class: 'StringParameterValue', name: k, value: v] }
}
def map = [
Bob : 42,
Alice: 54,
def myMethod(a, b) {
println("a: " + a + " / b: " + b)
}
myMethod(1, 2)
println("---")
myMethod 1, 2
println("---")
@herrphon
herrphon / retry.sh
Created April 14, 2020 16:43 — forked from sj26/LICENSE.md
Bash retry function
# Retry a command up to a specific numer of times until it exits successfully,
# with exponential back off.
#
# $ retry 5 echo Hello
# Hello
#
# $ retry 5 false
# Retry 1/5 exited 1, retrying in 1 seconds...
# Retry 2/5 exited 1, retrying in 2 seconds...
# Retry 3/5 exited 1, retrying in 4 seconds...
@herrphon
herrphon / ruby-destructor-example.rb
Created March 5, 2019 11:51 — forked from iboard/ruby-destructor-example.rb
Ruby 'Destructor' example.
class Foo
attr_reader :bar
def initialize
@bar = 123
ObjectSpace.define_finalizer( self, self.class.finalize(bar) )
end
def self.finalize(bar)
proc { puts "DESTROY OBJECT #{bar}" }
end
@herrphon
herrphon / stream.cr
Created February 1, 2019 13:16 — forked from faustinoaq/stream.cr
Try kemal/crystal stream
require "kemal"
get "/stream" do |env|
env.response.print "START"
env.response.flush
sleep 3
env.response.print "MIDDLE"
env.response.flush
sleep 5
env.response.print "END"
<template>
<!-- Will add/remove .small if the width is less / greater -->
<div class="post__item" v-responsive="{ small: el => el.width <= 500 }">
<img class="post__image" :src="post.image" />
<div class="post__text">{{post.text}}</div>
</div>
</template>
<script>
import { ResponsiveDirective } from "vue-responsive-components"
@herrphon
herrphon / postgres_queries_and_commands.sql
Created March 16, 2018 11:17 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@herrphon
herrphon / gist:50c2f89c58c31260f7ceaad792b96eab
Created December 18, 2017 12:54
Get root shell with setuid executable
#include <unistd.h>
int main() {
const char *b = "/bin/bash";
setuid(0);
execl(b, b, 0);
}