Skip to content

Instantly share code, notes, and snippets.

View thomasvnl's full-sized avatar

Thomas V. thomasvnl

  • Dordrecht, The Netherlands
View GitHub Profile
@thomasvnl
thomasvnl / free_ports.sh
Created January 11, 2022 22:24 — forked from hjbotha/free_ports.sh
Free ports 80 and 443 on Synology NAS
#! /bin/bash
# NEWLY ADDED BACKUP FUNCTIONALITY IS NOT FULLY TESTED YET, USE WITH CARE, ESPECIALLY DELETION
# Developed for DSM 6 - 7.0.1. Not tested on other versions.
# Steps to install
# Save this script in one of your shares
# Edit it according to your requirements
# Backup /usr/syno/share/nginx/ as follows:
# # cd /usr/syno/share/
# # tar cvf ~/nginx.tar nginx
@thomasvnl
thomasvnl / Dockerfile
Last active September 26, 2021 13:10
Dockerfile for NodeRED with dialout group permission so it can access COM/(USB)tty devices on the host (like the ConBee USB stick, or RFLink)
FROM nodered/node-red
USER root
RUN addgroup node-red dialout
USER node-red
@thomasvnl
thomasvnl / ducky.md
Created March 3, 2021 08:00 — forked from schmich/ducky.md
Programming media keys on the Ducky One 2 Skyline

Programming Media Keys on the Ducky One 2 Skyline

To use media keys on the Ducky One 2 Skyline, you must record a macro to bind the media function to a hotkey combination, i.e. Fn plus some key.

Example

Important: In the instructions below, "Press X+Y+Z" means press and hold key X, press and hold key Y, press and hold key Z in that order, and then release all three.

As an example, to bind Fn+PgUp to the play/pause media function:

@thomasvnl
thomasvnl / keybase.md
Created October 25, 2016 14:01
Keybase validation

Keybase proof

I hereby claim:

  • I am thomasvnl on github.
  • I am thomasvnl (https://keybase.io/thomasvnl) on keybase.
  • I have a public key whose fingerprint is 58C1 81A5 989C D93A CCEA 1334 10CB 0951 C795 F443

To claim this, I am signing this object:

@thomasvnl
thomasvnl / get_set_value_by_multilevel_key.py
Created October 4, 2016 12:57
Get and set values by passing in a multilevel key, a data dictionary, and in case of setting also a value
def get_value_by_multilevel_key(key, data):
"""
returns a value by a multilevel key reference e.g. 'object.foo.bar' as key returns the value 10
(see below)
{
object: {
foo:
bar: 10
}
}
@thomasvnl
thomasvnl / promote_item_to_first_position.py
Created October 4, 2016 12:56
Promote an item in a list to the first position
def promote_item_to_first_position(enumerator, key, value):
"""
Promotes an item to the first index of the list if it isn't already there. It moves the item from it's current
position and resets the list's indexes. Be careful to not use this on a giant list, because the operation could
be quite heavy. With small lists the impact is not noticeable.
:param enumerator:
:param key:
:param value:
:return:
"""
@thomasvnl
thomasvnl / get_item_from_dict_list_by_key_value.py
Last active October 4, 2016 12:55
Return an item from a list of dictionaries by comparing key:value combination
def get_item_from_dict_list_by_key_value(list, key, value):
"""
Return an item from a list by key:value combination if possible
:param list list:
:param str key:
:param * value:
:return dict|None:
"""
for item in list:
if item[key] == value:
@thomasvnl
thomasvnl / logging2.json
Created September 7, 2016 06:26 — forked from pmav99/config2.json
Python 3 logging configuration using JSON
{
"logging": {
"version": 1,
"disable_existing_loggers": true,
"formatters": {
"brief": {
"class": "logging.Formatter",
"datefmt": "%I:%M:%S",
"format": "%(levelname)-8s; %(name)-15s; %(message)s"
},
/*
IoT Manager mqtt device client https://play.google.com/store/apps/details?id=ru.esp8266.iotmanager
Based on Basic MQTT example with Authentication
PubSubClient library v 1.91.1 https://github.com/Imroy/pubsubclient
- connects to an MQTT server, providing userdescr and password
- subscribes to the topic "/IoTmanager" (waiting "HELLO" messages from mobile device)
- publishes config to the topic "/IoTmanager/config/deviceID/"
Tested with Arduino IDE 1.6.7 + ESP8266 Community Edition v 2.1.0-rc2
PubSubClient library v 1.91.1 https://github.com/Imroy/pubsubclient
# mdadm --create /dev/md0 --level=1 --raid-devices=(int multiple of 2) /dev/sd* /dev/sd** ...