Skip to content

Instantly share code, notes, and snippets.

View martinrusev's full-sized avatar
🌱
01010110

Martin Rusev martinrusev

🌱
01010110
  • Berlin, Germany
View GitHub Profile
@martinrusev
martinrusev / gist:1169184
Last active May 3, 2020 12:04
Build and upload a python app to Pypi
pip install twine setuptools
python setup.py sdist build
twine upload dist/*
@martinrusev
martinrusev / gist:1262935
Created October 4, 2011 21:50
Unix - get number of processors
cat /proc/cpuinfo | grep processor | wc -l
@martinrusev
martinrusev / gist:1671074
Created January 24, 2012 16:50
Find print statements in the code
grep -rn print .
@martinrusev
martinrusev / gist:3926494
Created October 21, 2012 09:35
PostgreSQL 9.1 slow queries logging
sudo apt-get install postgresql-contrib
# in /etc/postgresql/9.1/main/postgresql.conf
shared_preload_libraries = 'pg_stat_statements'
custom_variable_classes = 'pg_stat_statements'
pg_stat_statements.max = 100
pg_stat_statements.track = top
pg_stat_statements.save = off
@martinrusev
martinrusev / pip-update
Created October 31, 2012 10:35
Pip Update all packages
import pip
from subprocess import call
for dist in pip.get_installed_distributions():
call("pip install --upgrade " + dist.project_name, shell=True)
@martinrusev
martinrusev / imap-search
Last active November 4, 2024 12:46
IMAP Search criteria
@martinrusev
martinrusev / kill_port
Created October 16, 2013 14:19
Kill process on port
sudo kill -9 `sudo fuser -n tcp 8000 2> /dev/null`
@martinrusev
martinrusev / docker_examples.sh
Last active December 29, 2015 12:49
Docker examples
# List all images
docker images
docker run -i -t <image:tag> <command>
# Lists all changes
docker ps -l
# Commits the last change
docker commit <image_id> <image:tag>
@martinrusev
martinrusev / amonplugin.py
Last active August 29, 2015 13:57
Custom Amon Plugin
from amonagent.plugin import AmonPlugin
class MyCustomPlugin(AmonPlugin):
def collect(self):
"""
The agent collects and sends all the metrics defined in this function
"""
@martinrusev
martinrusev / etc.amonagent
Last active August 29, 2015 13:57
Plugin directory structure
├── amonagent
│   ├── plugins
│   │   ├── apache
│   │   │   ├── apache.conf.example
│   │   │   ├── apache.py
│   │   │   ├── README.md
│   │   │   └── requirements.txt
│   └── plugins-enabled
│   └── apache.conf