Skip to content

Instantly share code, notes, and snippets.

View Kuzmenko-Pavel's full-sized avatar

Pavel Kuzmenko Kuzmenko-Pavel

  • Prozorro Sale
  • Ukraine Kharkiv
  • 22:56 (UTC +02:00)
View GitHub Profile
@Kuzmenko-Pavel
Kuzmenko-Pavel / size.js
Created August 23, 2024 17:00
mongo add collection size
db.getMongo().getDBNames().forEach(function(dbName) {
if ("local" != dbName && "admin" != dbName && "system" != dbName) {
var subject = db.getSiblingDB(dbName);
subject.getCollectionNames().forEach(function (collectionName) {
var stats = subject.runCommand({ collStats: collectionName, scale: 1024 * 1024 });
print('Database: ' + dbName + ' - Collection: ' + collectionName +
' - Storage Size: ' + stats.storageSize + ' MB' +
' - Free Storage Size: ' + stats.freeStorageSize + ' MB' +
' - Total Index Size: ' + stats.totalIndexSize + ' MB' +
' - Document Count: ' + stats.count +
@Kuzmenko-Pavel
Kuzmenko-Pavel / compact.js
Created August 23, 2024 16:42
mongo compact all db and collection
// rs.slaveOk();
db.getMongo().getDBNames().forEach(function(dbName) {
if ("local" != dbName && "admin" != dbName && "system" != dbName) {
var subject = db.getSiblingDB(dbName);
subject.getCollectionNames().forEach(function (collectionName) {
print('Compacting: ' +dbName + " - " + collectionName);
subject.runCommand({ compact: collectionName });
});
}
});
# ## Шаг 1. Убедитесь, что у вас есть локальная копия всех «старых репозиториев»
# ## ветки и теги.
# Получить все удаленные ветки и теги:
git fetch origin
# Просмотр всех локальных и удаленных веток «старого репо»:
git branch -a
# Если некоторые из удаленных/веток не имеют локальной копии,
# checkout для создания локальной копии недостающих:
envSecrets=$(kubectl get pods -o jsonpath='{.items[*].spec.containers[*].env[*].valueFrom.secretKeyRef.name}' | xargs -n1)
envSecrets2=$(kubectl get pods -o jsonpath='{.items[*].spec.containers[*].envFrom[*].secretRef.name}' | xargs -n1)
volumeSecrets=$(kubectl get pods -o jsonpath='{.items[*].spec.volumes[*].secret.secretName}' | xargs -n1)
pullSecrets=$(kubectl get pods -o jsonpath='{.items[*].spec.imagePullSecrets[*].name}' | xargs -n1)
tlsSecrets=$(kubectl get ingress -o jsonpath='{.items[*].spec.tls[*].secretName}' | xargs -n1)
SASecrets=$(kubectl get secrets --field-selector=type=kubernetes.io/service-account-token -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' | xargs -n1)
diff \
<(echo "$envSecrets\n$envSecrets2\n$volumeSecrets\n$pullSecrets\n$tlsSecrets\n$SASecrets" | sort | uniq) \
@Kuzmenko-Pavel
Kuzmenko-Pavel / ReadingHelmResources.md
Last active May 10, 2024 08:29 — forked from DzeryCZ/ReadingHelmResources.md
Decoding Helm3 resources in secrets

Helm 3 is storing description of it's releases in secrets. You can simply find them via

$ kubectl get secrets
NAME                                                TYPE                                  DATA   AGE
sh.helm.release.v1.wordpress.v1                     helm.sh/release.v1                    1      1h

If you want to get more info about the secret, you can try to describe the secret

$ kubectl describe secret sh.helm.release.v1.wordpress.v1

Keybase proof

I hereby claim:

  • I am kuzmenko-pavel on github.
  • I am kuzmenko_pavel (https://keybase.io/kuzmenko_pavel) on keybase.
  • I have a public key ASAZ0EsF9BzhvdxXqv5SPn4beTPgl1EYk9pg5dVB7Zsj7go

To claim this, I am signing this object:

@Kuzmenko-Pavel
Kuzmenko-Pavel / move-var-part-ubuntu.md
Created January 27, 2024 15:09 — forked from iambryancs/move-var-part-ubuntu.md
Move /var to another partition in Ubuntu

Move /var to another partition in Ubuntu

Create partition with fdisk or gparted

fdisk /dev/sdb
...
...

Create fs

@Kuzmenko-Pavel
Kuzmenko-Pavel / index.html
Created November 9, 2022 19:05
web worker check connection
<!DOCTYPE html>
<html lang="en">
<head>
<title>Web Workers</title>
</head>
<body>
<script>
if (window.Worker) {
const myWorker = new Worker("worker.js");
myWorker.postMessage("https://auction-dev.prozorro.sale/")
@Kuzmenko-Pavel
Kuzmenko-Pavel / postgres_analyze.sql
Created October 26, 2022 13:14
набор джентельмена для мониторинга траблаков слона
-- Index usage
SELECT t.schemaname,
t.tablename,
c.reltuples::bigint AS num_rows, pg_size_pretty(pg_relation_size(c.oid)) AS table_size,
psai.indexrelname AS index_name,
pg_size_pretty(pg_relation_size(i.indexrelid)) AS index_size,
CASE WHEN i.indisunique THEN 'Y' ELSE 'N' END AS "unique",
psai.idx_scan AS number_of_scans,
psai.idx_tup_read AS tuples_read,
psai.idx_tup_fetch AS tuples_fetched
import operator
from functools import reduce
def find(data, element, default=...):
try:
return reduce(operator.getitem, element.split('.'), data)
except KeyError:
if default is not ...:
return default