Skip to content

Instantly share code, notes, and snippets.

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

Denys Gaidukov pydevd

🏠
Working from home
  • Ukraine
View GitHub Profile
@pydevd
pydevd / drop_all_doc_types.py
Created June 14, 2019 12:57
Remove all records of specified _type from ElasticSearch
def drop_all_doc_types(es: Elasticsearch, type_=ES_DOC_TYPE):
while es.count()["count"] > 0:
r = es.search(
index=ES_INDEX,
doc_type=type_,
filter_path=["hits.hits._id"],
body={"query": {"match_all": {}}},
size=10000,
)
ids = [x["_id"] for x in r["hits"]["hits"]] if r else []
kubectl -n <namespace> scale deployment <depl-name> --replicas=0 && kubectl -n <namespace> scale deployment <depl-name> --replicas=1
@pydevd
pydevd / socket.py
Created June 13, 2017 15:04
Pill from [Errno 98] Address already in use
# pill from [Errno 98] Address already in use
socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
socket.setsockopt(socket.SOL_SOCKET, socket.SO_LINGER, struct.pack('ii', 1, 0))
#!/usr/bin/env bash
sudo mkdir -p /var/lib/mysql
sudo mkdir -p /var/lib/postgresql/data
sudo mkdir -p /var/lib/mongodb/data
sudo mkdir -p /var/lib/edgedb/data
sudo docker run \
--detach \
--name=edgedb-server \
@pydevd
pydevd / docker-rm-all.sh
Created December 7, 2016 15:37
Remove all containers and images
sudo docker rm -v $(sudo docker ps -a -q) && sudo docker rmi $(sudo docker images -q)
@pydevd
pydevd / databases and tables sizes.sql
Last active December 26, 2016 12:37
This code displays approx size of all databases and tables
-- selects approx size of all databases
SELECT
table_schema AS "Database",
SUM( data_length + index_length )/1024/1024 AS "Size, MB"
FROM information_schema.TABLES
GROUP BY table_schema;
SELECT
CONCAT(table_schema, '.', table_name) AS "Table",
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Total size, MB",
#!/usr/bin/env bash
# 1. Configure two monitors mode, set xfce panel to be displayed on the primary monitor
# 2. Instal required packages and remove unused
sudo apt update
sudo apt upgrade
sudo apt install terminator htop python3-setuptools python3-pip python3-dev python3-venv python2.7-dev vim git docker.io mysql-client