Skip to content

Instantly share code, notes, and snippets.

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
@barseghyanartur
barseghyanartur / trigger_sentry_exception.md
Created Aug 19, 2020
Manually trigger Sentry exception
View trigger_sentry_exception.md

Set logging to verbose:

import logging
logging.basicConfig()
logging.getLogger().setLevel(logging.DEBUG)
req_log = logging.getLogger('urllib3')
req_log.setLevel(logging.DEBUG)
req_log.propagate = True
@barseghyanartur
barseghyanartur / es_podman.md
Created Jul 22, 2020
Run Elastic with Podman
View es_podman.md
podman run --ulimit=host -p "9200:9200" elasticsearch:7.5.1
@barseghyanartur
barseghyanartur / intr.md
Created Jul 20, 2020
Show line numbers in nano
View intr.md

Open the nanorc file:

nano ~/.nanorc

Turn on line-numbers feature by pasting the following into the nanorc:

set linenumbers
View reset_mysql_query_cache.md

In SQL terminal:

RESET QUERY CACHE;
FLUSH QUERY CACHE;

In Python/Django:

You can’t perform that action at this time.