This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from proj.celery import app | |
from celery.app import control | |
# remove pending tasks | |
app.control.purge() | |
# remove active tasks | |
i = app.control.inspect() | |
jobs = i.active() | |
for hostname in jobs: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Installing/updating helm on Ubuntu | |
# Usage: ./update_helm.sh v2.16.9 | |
VERSION=$1 | |
echo "Installing Helm ${VERSION}" | |
rm helm-*-linux-amd64.tar.gz | |
rm -r linux-amd64 | |
echo "Download will start" | |
wget https://get.helm.sh/helm-${VERSION}-linux-amd64.tar.gz | |
tar -zxvf helm-${VERSION}-linux-amd64.tar.gz | |
mv linux-amd64/helm /usr/local/bin/helm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello world; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create temporary table cputime (dt Date, ts Int8, cpu Int8, user_id Int8); | |
insert into cputime values | |
('2019-01-01', 1, 0, 1), ('2019-01-01', 2, 1, 1), ('2019-01-01', 3, 1, 1), | |
('2019-01-01', 4, 0, 1), ('2019-01-01', 5, 2, 1), ('2019-01-01', 6, 3, 1), | |
('2019-01-01', 1, 0, 2), ('2019-01-01', 2, 4, 2), ('2019-01-01', 3, 5, 2), | |
('2019-01-01', 4, 0, 2), ('2019-01-01', 5, 8, 2), ('2019-01-01', 6, 15, 2), | |
('2019-01-01', 7, 5, 2), ('2019-01-01', 8, 8, 2), ('2019-01-01', 9, 8, 2); | |
select |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kubectl get pods | grep enter_your_mask_here | while read line ; do echo "$line" | awk '{print $1}' | sort | while read line2; do kubectl delete pod "$line2" ; done; done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Coding styles test. | |
You need to install flake8 and isort via pip. | |
pip install flake8 | |
pip install isort | |
Add this test to any of your django apps tests. | |
""" | |
import subprocess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this removes <none> docker images | |
docker rmi -f $(docker images -f "dangling=true" -q) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
accept = 'ours' # ours for 'HEAD' #theirs for other's - choose strategy here for all conflicts | |
filename = 'enter your filename here' | |
fresult = '{}.{}'.format(filename, 'merged') # result will be near your file with name `original_filename.ext.merged` | |
with open(filename) as f: | |
content = f.readlines() | |
res = open(fresult, 'w') | |
to_write = True | |
merging = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.core.management.base import BaseCommand, CommandError | |
from django.db import DEFAULT_DB_ALIAS, connections | |
from django.db.migrations.loader import MigrationLoader | |
# code from command showmigrations is used and adopted as a function | |
def get_migrations(connection, app_names=None): | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.contrib import admin | |
from django.apps import apps | |
from django.contrib.admin.sites import AlreadyRegistered | |
def register_all_models(models): | |
for m in models: | |
m_admin_name = m.__module__.replace(".","") + m.__name__ + 'Admin' | |
ModelAdminClass = type(m_admin_name, (admin.ModelAdmin,), {'set_x': lambda x,y: x.y}) | |
ModelAdminClass.model = m |