Skip to content

Instantly share code, notes, and snippets.

View yelizariev's full-sized avatar
Hello World!

Ivan Kropotkin yelizariev

Hello World!
View GitHub Profile
@yelizariev
yelizariev / 001-psql.sql
Last active March 6, 2018 10:16
Postgresql
--- connection count
SELECT sum(numbackends) FROM pg_stat_database;
--- long running queries
SELECT
pid,
now() - pg_stat_activity.query_start AS duration,
query,
state
FROM pg_stat_activity
@yelizariev
yelizariev / 1-instruction.rst
Last active April 11, 2018 12:21
Emulate odoo pos BOX

hw_escpos

  • apply patch
  • install hw_escpos on odoo
  • run odoo with -d DB_WITH_HW_ESCPOS --db-filter=DB_WITH_HW_ESCPOS
  • in new terminal run
@yelizariev
yelizariev / 1-lxd.sh
Last active August 6, 2018 18:33
LXD+dockers+nginx. Remote development for several developer on a single server. LATEST VERSION is here: https://odoo-development.readthedocs.io/en/latest/remote-dev/lxd/lxd.html
# For understanding LXC see https://wiki.debian.org/LXC
# Based on:
# lxd + docker: https://stgraber.org/2016/04/13/lxd-2-0-docker-in-lxd-712/
# lxd network (static ip): https://stgraber.org/2016/10/27/network-management-with-lxd-2-3/
LXD_NETWORK="dev-network2"
# install lxd 2.3+
apt-get install software-properties-common
@yelizariev
yelizariev / print-pdf-on-ticket-printer.md
Last active November 13, 2018 19:09
How-to print pdf on a ticket printer.

Instruction provided by @invitu

1- Install Cups on the posbox:

  • The posbox is a read-only system, you have to chroot it to install cups
  • Run a posbox on a raspberry-pi and plug a pen drive containing another posbox image
  • chroot the posbox in the pen drive
  • install cups with apt-get
  • plug the epson on the posbox
  • setup a Raw queue using usb://EPSON/TM-T20II in cups and share it (remove the "?serial=xxxxxxx" part if you want to use the image with another printer
  • there is no driver for epson printer for raspbian, that's the reason we must use raw queue
@yelizariev
yelizariev / disk-arhive.sh
Last active February 14, 2019 02:06
backup disk
# https://help.ubuntu.com/community/BackupYourSystem/TAR
# Archive
tar -cvpzf backup.tar.gz --one-file-system /
# Restore
sudo tar -xvpzf /path/to/backup.tar.gz -C /media/whatever --numeric-owner
@yelizariev
yelizariev / monotoring.sh
Last active February 16, 2019 22:32
monitoring tools
sudo apt install lolcat cowsay
while true; do export PINGHOST=8.8.8.8 && RESULT=$(ping -q -n -c 4 $PINGHOST | awk '/packet loss/ {if ($6 != "0%") print $6, "packet loss"}') && echo "Done:" && if [[ -z $RESULT ]]; then cowsay "No package lost!" | lolcat --seed=45; else cowsay $RESULT | lolcat --seed=17; fi; date; echo -n "sleeping... "; sleep 5; echo -n "pinging... "; done
@yelizariev
yelizariev / rotate.sh
Created February 18, 2019 15:07
Simple file rotating (e.g. for backups)
# based on https://serverfault.com/a/196847
# It will keep only latest 12 files
ls -1t /path/to/dir/* | tail -n +13 | xargs rm > /dev/null 2>&1
### instruction to run via docker
# install docker ( https://docs.docker.com/engine/installation/ubuntulinux/ )
apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
echo "deb https://apt.dockerproject.org/repo ubuntu-trusty main" > /etc/apt/sources.list.d/docker.list # ubuntu 14.04
apt-get update
apt-get purge lxc-docker
apt-cache policy docker-engine
apt-get install linux-image-extra-$(uname -r) # ubuntu 14.04
apt-get install docker-engine
@yelizariev
yelizariev / 1-Ubuntu-odoo-development.sh
Last active September 6, 2019 10:09
Ubuntu configuration for odoo development
sudo apt-get update
sudo apt-get install git python-pip htop moreutils tree nginx gimp wmctrl postgresql-server-dev-all
sudo apt-get upgrade
################### Github
# configure ssh keys: https://help.github.com/articles/generating-ssh-keys/
################### Odoo
# download odoo from git:
cd /some/dir/
@yelizariev
yelizariev / docker-cleanup-resources.md
Last active February 6, 2020 06:28 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

docker volume rm $(docker volume ls -qf dangling=true)

docker volume ls -qf dangling=true | xargs -r docker volume rm