Skip to content

Instantly share code, notes, and snippets.

@RaD
RaD / TheRetainFlag.md
Created May 29, 2022 19:44 — forked from Paraphraser/TheRetainFlag.md
MQTT and the retain flag

Tutorial: MQTT and the retain flag

Assumptions and setup

This tutorial assumes:

  • a single computer (like a Raspberry Pi)
  • MQTT broker (like Mosquitto) running
  • the mosquitto_pub and mosquitto_sub commands are available.
@RaD
RaD / script.sh
Created May 29, 2022 10:19 — forked from vielhuber/script.sh
PostgreSQL: Backup and restore export import pg_dump with password on command line #sql
# best practice: linux
nano ~/.pgpass
*:5432:*:username:password
chmod 0600 ~/.pgpass
# best practice: windows
edit %APPDATA%\postgresql\pgpass.conf
*:5432:*:username:password
# linux
pyenv local 3.7.5
pyenv exec python -m pipenv sync -d
pyenv local 3.7.5
pyenv exec python -m pipenv sync -d
@RaD
RaD / json-dumps.py
Created March 16, 2020 08:04
Пример, как выгрузить JSON с форматированием и русскими строками
with open('expected_data.json', 'w', encoding='utf8') as json_file:
json.dump(EXPECTED_DATA, json_file, ensure_ascii=False, indent=4, sort_keys=True)
@RaD
RaD / nginx-ssl.yml
Created December 6, 2019 08:02
SSL for services
# Конфигурация для запуска nginx в качестве SSL прокси для других контейнеров.
# Не забудьте создать сеть перед запуском этой конфигурации:
# docker network create nginx-proxy
# и добавить следующую строку к проксируемым контейнерам '--network nginx-proxy'.
version: '2'
services:
nginx:
image: nginx
import json
path_src = './references/migrations/0004_speciality.json'
path_dst = './references/migrations/0004_speciality.json'
src = open(path_src, 'r')
dst = open(path_dst, 'w')
payload = json.loads(src.read())
result = []
index = 0
for i in payload:
@RaD
RaD / Dockerfile
Created November 2, 2018 08:30
How to build Docker image in the Docker container
FROM alpine:3.8
MAINTAINER Ruslan Popov <[email protected]>
ARG SOURCE_VERSION=UNSPECIFIED
ARG SOURCE_COMMIT=UNSPECIFIED
ENV \
SOURCE_VERSION=${SOURCE_VERSION} \
SOURCE_COMMIT=${SOURCE_COMMIT} \
@RaD
RaD / isincos.py
Last active February 5, 2017 16:34
#!/usr/bin/env python
import math
OUTBITS = 16
BITS_PER_CYCLE = 16
BITS_PER_QUARTER = BITS_PER_CYCLE - 2
BITS = 8
ONE = 1 << BITS
HALF = ONE / 2
C = 70710 * ONE / 100000
@RaD
RaD / lintrunner.py
Created December 30, 2016 07:30
Flake8 integration
#!/usr/bin/env python
"""
Install packages:
wajig install pylint pyflakes pep8 pychecker
pip install flake8
"""
import os