Skip to content

Instantly share code, notes, and snippets.

@AlcibiadesCleinias
AlcibiadesCleinias / walk_through_dir.py
Last active November 8, 2021 16:45
Walk through directory with filtering
base_path = '/Users/User/Documents'
files = [
os.path.join(dirpath, file) for (dirpath, subdirs, files) in os.walk(base_path) for file in files
if file.rsplit('.', 1)[-1].lower() in ['js']
]
@AlcibiadesCleinias
AlcibiadesCleinias / telegram-logging-module
Last active September 30, 2021 15:13
TelegramFormatter & TelegramHandler ready to be used with your LOGGING dict
"""Kinda repeat of https://github.com/sashgorokhov/python-telegram-handler/tree/master/telegram_handler
with feature:
- convert message into file if traceback is too long (todo).
"""
import logging
from datetime import datetime
from utils.telegram import send_telegram_message. # todo: prepare this method
#!/bin/bash
#####################
# Portainer Install #
#####################
# # Flow
# 1. Copy the file into portainer.sh that you may create via `vim` + `i` + `cntr+v` + `esc` + `!` + `wq` + `enter`
# 2. `chmod +x portainer.sh`
# 3. `./portainer.sh`
# 4. Go to localhost:9000 and generate credentials.
@AlcibiadesCleinias
AlcibiadesCleinias / settings.py
Last active October 17, 2021 13:48
Example of a settings.py file with validation & different context {dev, prod, test} | Pydantic settings.py
"""
In order to share and have easy access on to
how a settings.py file should be written.
Advantages:
- in a manner of Django project
- with validation
- with state-of-the-art validation
- even for several context, e.g. dev, prod
# I present how with vanilla bash you can connect an GitHub Action runner to a private network
# via an OpenVPN config file.
#
# ## Briefly
# The workflow uses github secretes: config, username and passwrod to connect via openvpn in daemon mode.
# To be sure that connection established I added bash script to ping during 30 seconds a desired host.
#
# ## Workflow
# 1. Put ovpn config into github secrets (remove special symbols like quotes): OPENVPN_FILE
# 2. Put you login and password into github secrets (mask special symbols with slash):
@AlcibiadesCleinias
AlcibiadesCleinias / 1-setup.md
Created July 9, 2021 08:15 — forked from troyfontaine/1-setup.md
Signing your Git Commits using GPG on MacOS Sierra/High Sierra

Methods of Signing with GPG

Last updated March 28, 2021

There are now two ways to approach this:

  1. Using gpg and generating keys
  2. Using Kryptonite by krypt.co

This Gist explains how to do this using gpg in a step-by-step fashion. Kryptonite is actually wickedly easy to use-but you will still need to follow the instructions

@AlcibiadesCleinias
AlcibiadesCleinias / prometheus_pushgateway_ready_to_use.py
Last active August 18, 2021 21:43
A simple use of python prometheus lib with PushGateWay
"""
# About
Essentially, in an app like Django, you can not simply make
'from prometheus_client import push_to_gateway' and go on as you may expect.
You will face with several issues, e.g. use only one CollectorRegistery
and basically, you don't want to deal with the ones when importing push_2_gateway.
So, the classes below give you a possibility (python overlay) you looking for:
import metric class and simply push a value to the metric.