Skip to content

Instantly share code, notes, and snippets.

View ichux's full-sized avatar
🏠
Working from home

Chukwudi Nwachukwu ichux

🏠
Working from home
View GitHub Profile
#!/bin/bash
# Remove existing key and certificate files
rm -f *.key *.crt
# Set the file names and parameters
CA_KEY="ca.key"
CA_CERT="ca.crt"
CA_SERIAL="ca.srl"
SERVER_KEY="default_4430.key"
#!/bin/bash
download_install(){
python3 << END
from vive import get_message
print(get_message())
END
}
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""nginx config file formatter/beautifier with no additional dependencies.
Originally published under https://github.com/1connect/nginx-config-formatter,
then moved to https://github.com/slomkowski/nginx-config-formatter.
"""
import argparse
@ichux
ichux / md-pdf.sh
Last active November 7, 2024 04:40
#!/bin/bash
# sudo apt install -y pandoc texlive-latex-base texlive-xetex
# Script: md_to_pdf.sh
# Description: Convert Markdown files to PDF using pandoc.
# Function to display usage
usage() {
echo "Usage: $0 [-o output_directory] file1.md [file2.md ...]"
exit 1
#!/bin/bash
echo "- lazydocker installation"
LAZYDOCKER_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazydocker/releases/latest" | grep -Po '"tag_name": "v\K[0-9.]+')
curl -Lo lazydocker.tar.gz "https://github.com/jesseduffield/lazydocker/releases/latest/download/lazydocker_${LAZYDOCKER_VERSION}_Linux_x86_64.tar.gz"
tar -xvzf lazydocker.tar.gz> /dev/null 2>&1 && rm lazydocker.tar.gz
mv lazydocker /usr/local/bin/lazydocker && chmod a+x /usr/local/bin/lazydocker
echo "+ lazydocker installation"
import os
from redis import ConnectionPool, Redis
# Setup Redis connection pool
POOL = ConnectionPool(
host=os.getenv("REDIS_HOST"),
port=os.getenv("REDIS_PORT"),
db=os.getenv("REDIS_DB"),
password=os.getenv("REDISCLI_AUTH"),
import itsdangerous
import jwt
def start_encoding(salt, secret_key, **kwargs):
sz = itsdangerous.Serializer(salt=salt, secret_key=secret_key)
return jwt.encode({"enc": sz.dumps(kwargs)}, secret_key, algorithm="HS256")
def end_decoding(salt, secret_key, response):
import crypt
# TO run:
# PYTHONWARNINGS=ignore::DeprecationWarning python3 hash_password.py
password = "your_password_here"
salt = crypt.mksalt(crypt.METHOD_SHA512)
hashed_password = crypt.crypt(password, salt)
print(f"Hashed Password: {hashed_password}")
@ichux
ichux / time_as_seen.py
Last active June 26, 2024 05:02
describe_time
from datetime import datetime
import pytz
UTC = pytz.UTC
WAT = pytz.timezone("Africa/Lagos")
def current_time():
return datetime.now(pytz.utc).strftime("%Y-%m-%d %H:%M:%S %Z%z")
from datetime import datetime
import pytz
data = {
"sub": [
["a1", "2024-07-01 07:39:41 UTC+0000"],
["a3", "2024-07-01 07:39:41 UTC+0000"],
["j5", "2024-07-01 07:39:41 UTC+0000"],
]