Skip to content

Instantly share code, notes, and snippets.

View zeppelinen's full-sized avatar
🖖

Alexander Naydenko zeppelinen

🖖
View GitHub Profile
@zeppelinen
zeppelinen / labels_to_prometheus_metrics.go
Created May 31, 2023 10:41
Go script that exposes information about statefulsets and deployments in Kubernetes cluster as Prometheus metrics
package main
import (
"log"
"net/http"
"os"
"strings"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
@zeppelinen
zeppelinen / Dockerfile
Created December 14, 2022 11:05 — forked from vbankov/Dockerfile
[su-exec - Install in Debian/Ubuntu Container] Quick-install su-exec in Debian based docker container #su-exec #debian #ubuntu #docker
# Install latest su-exec
RUN set -ex; \
\
curl -o /usr/local/bin/su-exec.c https://raw.githubusercontent.com/ncopa/su-exec/master/su-exec.c; \
\
fetch_deps='gcc libc-dev'; \
apt-get update; \
apt-get install -y --no-install-recommends $fetch_deps; \
rm -rf /var/lib/apt/lists/*; \
gcc -Wall \
@zeppelinen
zeppelinen / mongodump_mongorestore_pipe.sh
Created June 11, 2021 14:59
Pipe output from mongodump to mongorestore
#!/usr/bin/env bash
mongodump --host HOST:PORT --db SOURCE_DB --username USERNAME --password PASSWORD --archive \
| mongorestore --host HOST:PORT --nsFrom 'SOURCE_DB.*' --nsTo 'TARGET_DB.*' --username USERNAME --password PASSWORD --archive --drop
@zeppelinen
zeppelinen / django_mysql_server_has_gone_away.py
Created September 17, 2020 09:11
A snippet to handle Django mysql server has gone away error
from django.db import connection, connections
if connection.connection and not connection.is_usable():
del connections._connections.default
@zeppelinen
zeppelinen / truncate_docker_logs.sh
Last active September 10, 2020 12:34
Script to truncate logs of all the docker containers
#!/usr/bin/env bash
for container in $(docker ps -q --all);
do
log_file=$(docker inspect --format='{{.LogPath}}' ${container})
echo "Truncate file ${log_file}"
echo "" > "${log_file}"
done
@zeppelinen
zeppelinen / images.xml
Created December 18, 2019 13:51 — forked from kitwalker12/images.xml
Amazon MWS Beauty Product Feed XML Sample
<?xml version="1.0" encoding="utf-8"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
<Header>
<DocumentVersion>1.01</DocumentVersion>
<MerchantIdentifier>AXXXXXXXXXX</MerchantIdentifier>
</Header>
<MessageType>ProductImage</MessageType>
<Message>
<MessageID>1</MessageID>
<OperationType>Update</OperationType>
@zeppelinen
zeppelinen / markdown-to-email
Created November 26, 2019 22:12 — forked from cleverdevil/markdown-to-email
markdown-to-email A simple script to send beautifully formatted emails that you write in Markdown. The email will have an HTML payload and a plain-text alternative, so you'll make everyone happy, including yourself.
#!/usr/bin/env python
'''
Send an multipart email with HTML and plain text alternatives. The message
should be constructed as a plain-text file of the following format:
From: Your Name <your@email.com>
To: Recipient One <recipient@to.com>
Subject: Your subject line
---
@zeppelinen
zeppelinen / clone-all-twitter-github-repos.sh
Last active December 18, 2019 06:26 — forked from caniszczyk/clone-all-twitter-github-repos.sh
Clone all repos from a GitHub organization
curl -s https://api.github.com/orgs/twitter/repos?per_page=200 | ruby -rrubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
@zeppelinen
zeppelinen / db_size.sql
Created April 10, 2019 09:23
Show table sizes of PostgreSQL database
SELECT
relname as "Table",
pg_size_pretty(pg_total_relation_size(relid)) As "Size",
pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as "External Size"
FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC;
@zeppelinen
zeppelinen / Training.ipynb
Last active February 3, 2019 22:25
Setup kubeflow on AWS. Copy-pastable
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.