Skip to content

Instantly share code, notes, and snippets.

View toke's full-sized avatar

Thomas Kerpe toke

View GitHub Profile
@toke
toke / mqtt2influx.sh
Last active June 9, 2016 11:40
Mqtt2Influx Demo
mosquitto_sub -h mqtt.toke.de -t sensors/hugin/285fe62050017/temp |xargs -I % curl -X POST -d '[{"name":"bs5","columns":["outside_temp"],"points":[[%]]}]' 'http://localhost:49157/db/demo/series?u=root&p=root'
FROM debian:wheezy
# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r postgres && useradd -r -g postgres postgres
RUN apt-get update && apt-get install -y curl
RUN echo 'deb http://apt.postgresql.org/pub/repos/apt/ wheezy-pgdg main' > /etc/apt/sources.list.d/pgdg.list
RUN curl -sSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

docker-sybase

How to run Sybase ASE on Docker.

This will allow you to create a Docker Image with Sybase on it (in this case Syabse ASE 15.7) This demo uses Redhat but most of the steps are generic.

1) Install docker

See : http://docs.docker.io/installation/rhel/

@toke
toke / derive_mac.c
Last active August 29, 2015 14:05
Derive MAC adress from 1wire sensor address.
uint8_t mac[] = { 0x02, 0xAD, 0x3A, 0x6E, 0xFE, 0xE1 }; // DEFAULT MAC
//...
if (sensors.count > 0) {
// Derive MAC address from OneWire Address
derive_mac(sensors.sensor[0].address, mac);
}
Ethernet.begin((uint8_t*)mac, ip);
/*
* Copyright (c) 2014 Thomas Kerpe <toke@toke.de>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
@toke
toke / README.md
Last active July 3, 2020 00:36
K.R.A.U.S. in C

K.R.A.U.S. in pure C

Abstract

This is a C fork of the famous K.R.A.U.S. (floor of the day) application by @jautz written in perl. The acronym K.R.A.U.S. stands for the German phrase "Kaffee-Runde auf unterschiedlichen Stockwerken". It's origin lies far in the beginning of civilisation and was once called Tempus clausum.

Since being independent of a single implementation is cruical for live threatening services this fork has been established.

@toke
toke / mebus-433sensor.md
Last active August 29, 2015 14:06
Being sick at home on a saturday afternoon and some time to spare? Lets make sense out of bleeps....

Analyzing the Mebus Wireless Sensor

I have a Mebus Weather station from a discounter in my kitchen and an wireless sensor outside the kitchen window. It operates at 433.92MHz and it's blips and bits are not yet analyzed (at least by me). So lets try to read it.

I will use my crappy rtl2832 DVB Dongle (Rafael Micro R820T) for that. I'd buyed it some time ago for 1€. I'ts a little bit whiny about everything. Touch it – määää. Use it without an Powered HUB wäääää. But even that crappy thing is useful ;-)

I have some clue what to expect, so I don't start at zero. I assume the data is modulated as OOK. (On Off Keying) and I have an progam rtl_443 which can help me decode it.

@toke
toke / route.txt
Last active August 29, 2015 14:07
Routing via se?
Tracing route to toke.de [2a01:4f8:100:14a5::3]
over a maximum of 30 hops:
1 1 ms <1 ms <1 ms 2002:5b59:128c:fc:xxxx:xxxx:xxxx:xxxx
2 1 ms <1 ms <1 ms 2002:5b59:128c:0:xxxx:xxxx:xxxx:xxxx
3 * * * Request timed out.
4 58 ms * 67 ms gi8-47.se.sto.dch.dr1.port80.se [2001:16d8:1:6240::1]
5 45 ms 51 ms 43 ms ae1-u1301.se.sto.dch.cr1.port80.se [2001:16d8:1:1354::95]
6 * 56 ms 53 ms Tengi4-2.se.mlm.wtc.cr0.port80.se [2001:16d8:1:1371::1]
7 64 ms 47 ms * decix-gw.hetzner.de [2001:7f8::616c:0:1]
@toke
toke / advisory_locks_example.sql
Last active January 18, 2022 21:32
Example for advisory locks in postgresql
do $$
DECLARE
ADV_LOCK BOOLEAN DEFAULT FALSE;
LOCK_ID INTEGER DEFAULT 50;
BEGIN
-- EARLY LOCK
-- LOCK_ID := 'tablename'::regclass::integer;
SELECT pg_try_advisory_lock(LOCK_ID) into ADV_LOCK;
RAISE NOTICE 'LOCK_ID: %', LOCK_ID;
IF ADV_LOCK THEN
@toke
toke / short-git-rev.md
Last active August 29, 2015 14:16
Print short git rev

Short Git-REV:

REV=$(git rev-parse HEAD)
echo ${REV::7}

or the correct way ;-) :