Skip to content

Instantly share code, notes, and snippets.

@barseghyanartur
barseghyanartur / example.md
Last active Feb 3, 2021
Docker/Podman agnostic shell scripts
View example.md

Script example

#!/bin/bash
if ! command -v podman &> /dev/null
then
    echo "podman could not be found. Falling back to docker"
    shopt -s expand_aliases
    alias podman='docker'
    alias podman-compose='docker-compose'
@barseghyanartur
barseghyanartur / venv_on_python39.md
Created Feb 2, 2021
Install virtualenv on Python 3.9
View venv_on_python39.md

Install virtualenv on Python 3.9

Add dead-snakes repository:

sudo add-apt-repository ppa:deadsnakes/ppa

Install Python 3.9, development package and the specific venv:

@barseghyanartur
barseghyanartur / alias.md
Created Feb 2, 2021
Useful additional commands for Docker
View alias.md

Useful additional commands for Docker

Stop all running containers**

Make an alias

alias docker-stop-all='docker stop $(docker ps -a -q)'

Usage example

View zero_downtime_reindexing.py
from datetime import datetime
from elasticsearch_dsl import (
DocType,
String,
Integer,
Float
)
def _suffix():
View memory_hints.md

Memory hints

Show free memory using vmstat

vmstat -s -S M | head -n 5 | tail -n 1

Show top 1 memory consumers using smem

@barseghyanartur
barseghyanartur / list_table_size.md
Created Dec 1, 2020
List All Table Sizes From ALL Databases
View list_table_size.md

List All Table Sizes From ALL Databases

In Mb

SELECT
  TABLE_SCHEMA AS `Database`,
  TABLE_NAME AS `Table`,
  ROUND((DATA_LENGTH + INDEX_LENGTH) / 1024 / 1024) AS `Size (MB)`
FROM
@barseghyanartur
barseghyanartur / check_ssl_cert_expiry_date.md
Created Aug 20, 2020
Check expiry date of SSL certificate
View check_ssl_cert_expiry_date.md

Command:

cat /path/to/certs/my_cert.crt | openssl x509 -noout -enddate

Sample output:

notAfter=Apr  6 14:23:50 2024 GMT