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
@RaD
RaD / .gitconfig
Last active September 27, 2021 09:26
Git Global Config
[gui]
encoding = utf-8
[alias]
#visual = gitk
last = log -1 HEAD
st = status
shorty = status --short --branch
# git unstage - убрать всё из индекса (чтобы например добавить/закоммитить сначала что-то другое)
unstage = reset HEAD --
up = !(git add . && git stash && git pull --rebase >&2) | grep -v \"No local changes to save\" && git stash pop
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 / proxy.py
Last active January 16, 2019 15:34
simple http proxy
# -*- coding: utf-8 -*-
import argparse
import re
import requests
from bs4 import BeautifulSoup, Comment
from flask import Flask
from flask import Response
@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 <ruslan.popov@gmail.com>
ARG SOURCE_VERSION=UNSPECIFIED
ARG SOURCE_COMMIT=UNSPECIFIED
ENV \
SOURCE_VERSION=${SOURCE_VERSION} \
SOURCE_COMMIT=${SOURCE_COMMIT} \