Skip to content

Instantly share code, notes, and snippets.

View coderbyheart's full-sized avatar
🌩️
building serverless IoT solutions

Markus Tacker coderbyheart

🌩️
building serverless IoT solutions
View GitHub Profile
@coderbyheart
coderbyheart / headline-fixer.mjs
Created December 16, 2020 14:24
Fixes RST headline lenghts
import glob from "glob";
import { promises as fs } from "fs";
let changed = false;
Promise.all(
glob.sync("./**/*.rst").map((s) =>
fs.readFile(s, "utf-8").then((rst) => {
const lines = rst.split("\n");
lines.forEach((line, n) => {
@coderbyheart
coderbyheart / device-ci.txt
Last active September 28, 2020 12:51
device ci job result
{
"job": {
"id": "5c5f3ef3-2bf4-4017-80ef-ff84dab19a3b",
"document": {
"fw": "https://github.com/bifravst/firmware/releases/download/v3.0.0/cat-tracker-Thingy91-ltem-debug-v3.0.0.hex"
},
"status": {
"status": "SUCCEEDED",
"statusDetails": {
"status": "success"
@coderbyheart
coderbyheart / heads.js
Last active September 22, 2020 11:09
heads.js
const dirs = ["UP", "DOWN", "LEFT", "RIGHT"];
const max = 20;
const interval = 2500;
let i = 0;
console.time("heads");
const r = setInterval(() => {
const n = Math.floor(Math.random() * dirs.length);
console.timeLog("heads", ++i, dirs[n]);
@coderbyheart
coderbyheart / espruino.js
Created August 29, 2020 10:31
espruino temperature controlled fan on Thingy:52
const threshold = 26.5;
const interval = 10;
let currentTemp;
let isOff;
function setLEDS(l1,l2,l3) {
digitalWrite(LED1, l1);
digitalWrite(LED2, l2);
digitalWrite(LED3, l3);
}
@coderbyheart
coderbyheart / espruino-temp-relay.js
Created August 28, 2020 15:59
espruino temperature controlled relay
var dht = require("DHT22").connect(A1);
const threshold = 25;
const interval = 10;
let currentTemp = 0;
// LEDs off
LED1.write(false);
LED2.write(false);
@coderbyheart
coderbyheart / regex.txt
Created August 21, 2020 08:07
Clean font properties from Inkscape SVG
(-inkscape|font|word|text|letter|writing)-[^:]+:[^;]+;
#!/bin/bash
ffmpeg -y -i $1 -vf palettegen palette.png
ffmpeg -y -i $1 -i palette.png -filter_complex paletteuse -r 10 $1.gif
@coderbyheart
coderbyheart / refill.mjs
Created March 12, 2020 12:44
copy DynamoDB items to another table
import AWS from 'aws-sdk'
const db = new AWS.DynamoDB();
const oldTable = 'bifravst-cellGeolocationdeviceCellGeoLocations9F25FBED-1VK9FPSS5GX3G'
const newTable = 'bifravst-cellGeolocationdeviceCellGeoLocation757F8D27-1K6Z9IBMWMV2K'
const refill = (ExclusiveStartKey) => db.scan({
TableName: oldTable,
Limit: 100,
@coderbyheart
coderbyheart / unresolved.json
Last active March 10, 2020 13:20
Unresolved Cells during Embedded World 20
[
{
"cellID": 1805149,
"mccmnc": 24412,
"areaCode": 50222,
"locations": [
{
"date": "2020-02-26T06:08:32.914Z",
"lat": 61.49116083333333,
"lng": 23.771811333333332,
@coderbyheart
coderbyheart / downloader.js
Last active March 10, 2020 06:29
nrfcloud message downloader
import fetch from 'node-fetch'
import * as querystring from 'querystring'
const f = (pageNextToken, messages = []) => fetch(`https://api.nrfcloud.com/v1/messages?${querystring.stringify({
inclusiveStart: '2019-01-01T00:00:00Z',
exclusiveEnd: new Date().toISOString(),
pageSort: 'desc',
pageLimit: 100,
...(pageNextToken ? { pageNextToken } : {}),
})}`, {