Skip to content

Instantly share code, notes, and snippets.

View revant's full-sized avatar

Revant Nandgaonkar revant

View GitHub Profile
@revant
revant / digital_signature.py
Created October 11, 2024 05:54
Frappe Framework and PyHanko digital signatures
# License: MIT
# Store signatures in "Digital Signature"
# it uploads signatures on S3 for secure storage.
# Code snippet to fetch signature and sign document
import io
import os
import ntpath
import boto3
import botocore.exceptions
@revant
revant / mqtt.js
Last active June 20, 2024 13:36
MQTT Sub nodejs
const mqtt = require("mqtt");
const client = mqtt.connect("mqtt://event-bus:1883", {
clientId: require('crypto').randomUUID(),
clean: true,
connectTimeout: 4000,
username: 'emqx',
password: 'public',
reconnectPeriod: 1000,
});
client.on('connect', () => {
@revant
revant / smtp.py
Last active November 3, 2023 14:18
Python SMTPServer
# https://github.com/frappe/frappe/blob/develop/frappe/email/smtp.py
import smtplib
class SMTPServer:
def __init__(
self,
server,
login=None,
password=None,
def terminal_websocket(name: str, namespace: str, command: list[str], container: str = None):
load_config()
core_v1_api = client.CoreV1Api()
resp = stream(
core_v1_api.connect_get_namespaced_pod_exec,
name=name,
namespace=namespace,
container=container,
command=command,
stderr=True,
@revant
revant / README.md
Last active December 14, 2022 17:23
gcloud in container

Start Container:

docker run --rm -it \
  -v $PWD/data/gcloud:/root \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -e "TERM=xterm-256color" google/cloud-sdk:alpine sh

Prepare Container:

@revant
revant / README.md
Last active November 27, 2022 07:33
Frappe/ERPNext version 14 on RHEL 8

Download and install offline

# for centos:8 docker container refer https://stackoverflow.com/a/70930049
# yumdownloader --assumeyes --destdir=$HOME/downloads/rpms --resolve {package-name}
sudo yum install -y --cacheonly --disablerepo=* $HOME/downloads/rpms/*.rpm
# Following command needs Python 3.10 installed. Refer Section below
sudo pip3.10 install --no-index --find-links file:$HOME/downloads/pip frappe-bench 
@revant
revant / pwd.yml
Last active January 7, 2023 14:30
ERPNext version-14 Play With Docker
version: "3"
services:
backend:
image: frappe/erpnext:v14.12.0
deploy:
restart_policy:
condition: on-failure
volumes:
- sites:/home/frappe/frappe-bench/sites
@revant
revant / backup.sh
Created April 20, 2022 08:46
MariaDB Backup + Restic
# Video: https://youtu.be/b-KFj8GfvzE
# Full Backup
mariadb-backup --backup \
--user=$DB_ROOT_USER \
--password=$DB_ROOT_PASSWORD \
--target-dir=$BACKUP_BASE_DIR
# Incremental Backup
mariadb-backup --backup \
--user=$DB_ROOT_USER \
@revant
revant / README.md
Last active July 20, 2024 15:32
ERPNext on Docker Swarm
@revant
revant / backup-with-restic-and-s3.md
Last active September 6, 2023 14:46
backup with restic and S3

For local example, start MinIO

docker run \
  -p 9000:9000 \
  -p 9001:9001 \
  --name localminio \
  -v ~/minio/data:/data \
  -e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \
  -e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \