Skip to content

Instantly share code, notes, and snippets.

View zobayer1's full-sized avatar
🚧
What should I do next?

Zobayer Hasan zobayer1

🚧
What should I do next?
View GitHub Profile
@zobayer1
zobayer1 / postgres_pgadmin.compose.yaml
Created February 22, 2024 16:16
Run postgres12 and pgadmin4 with docker compose
version: "3"
services:
postgres:
image: postgres:12-alpine
restart: always
ports:
- "5432:5432"
environment:
@zobayer1
zobayer1 / compile-openssl_102.sh
Created March 14, 2023 11:41 — forked from meanevo/compile-openssl_102.sh
Compile OpenSSL 1.0.2* from source on CentOS 7
# Make sure you have these installed
yum install -y make gcc perl pcre-devel zlib-devel
# Download/Extract source
wget -O /tmp/openssl.tgz https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz
tar -zxf /tmp/openssl.tgz -C /tmp
cd /tmp/openssl-*
# Optional: Patch chacha20
# https://github.com/cloudflare/sslconfig/tree/master/patches
wget https://raw.githubusercontent.com/cloudflare/sslconfig/master/patches/openssl__chacha20_poly1305_draft_and_rfc_ossl102j.patch
patch -p1 < openssl__chacha20_poly1305_draft_and_rfc_ossl102j.patch
@zobayer1
zobayer1 / psycopg_connect.py
Created September 8, 2021 23:59
A simple python snippet for connecting to PostgreSQL database using psycopg2 library.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""PostgreSQL Connect
A simple python snippet for connecting to PostgreSQL database using psycopg2 library.
Installl psycopg2:
sudo dnf install python3-devel postgresql-devel
pip install psycopg2
"""
@zobayer1
zobayer1 / send_mail.py
Last active November 1, 2023 07:23
Send Emails from GMail using Python SMTP library
# -*- coding: utf-8 -*-
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import formataddr
from typing import List
class SendMail(object):
@zobayer1
zobayer1 / gist_blur.md
Last active November 2, 2022 06:08 — forked from AbuAbir/Good practice.md
Good practice to showcase achievement

GIST and BLUR

*collected from "Zobayer Hasan", Solution Architect, TigerIT Bangladesh

Works that you can show are always lot more impressive than works that you can only talk about. So yes, your projects on GitHub should carry a good amount of weight, or consideration in a recruitment phase, granted that they are relevant to the position or field you are trying to get in, and you are able to explain / answer relevant questions. When it comes to group projects, it is a bit sketchy. But these are great for showing how honest you are. Because, trust me, interviewers are usually good enough to catch you if you try to fool them (if they can't, they're probably from a bad company, and you don't want to get in there anyway).

@zobayer1
zobayer1 / loader.py
Last active December 1, 2023 16:01
Parsing environment variables in an YAML file using PyYAML library
"""A simple yaml loader
Load the content of an yaml file into a python dict. Environment variable can be specified with ${VAR_NAME}. A
default string value can be specified with ${VAR_NAME:DEFAULT}. Able to process multiple occurrences.
requirement: PyYAML
run: python loader.py
"""
import os
@zobayer1
zobayer1 / htpasswd.md
Created January 25, 2021 21:17
Bcrypt password generator for htpasswd with Python

Generator:

# file: gen.py

import bcrypt

def encrypt_password(username, password):
    bcrypted = bcrypt.hashpw(password.encode("utf-8"), bcrypt.gensalt(rounds=12)).decode("utf-8")
 return f"{username}:{bcrypted}"
@zobayer1
zobayer1 / paho_mqtt.py
Created January 18, 2021 14:48
Wrapper class for Python Paho MQTT client with callbacks and auto reconnect.
# -*- coding: utf-8 -*-
import click
from paho.mqtt.client import Client
class MQTTClient(object):
"""Manages Paho MQTT client lifecycle and callbacks"""
def __init__(self, config: dict, message_processor=None):
self.config = config
@zobayer1
zobayer1 / cron_job_checklist.md
Created November 22, 2020 15:43
WTF! My cron job doesn't run?!$#%

WTF??? My cron job doesn't run?!$#%

Source: This SO Answer

Here's a checklist guide to debug not running cronjobs:

  • Is the Cron daemon running?
    • Run ps ax | grep cron and look for cron.
  • Debian: service cron status, if not running, service cron start or service cron restart
@zobayer1
zobayer1 / Elasticsearch Bulk Indexing
Last active June 28, 2022 23:43
Elasticsearch bulk API usage example
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import json
import requests
class ElasticBulk(object):
"""Class for indexing documents in bulk"""