Skip to content

Instantly share code, notes, and snippets.

View coder4web's full-sized avatar

Aleksey Deryagin coder4web

View GitHub Profile
@coder4web
coder4web / setup_rbenv_per_user.sh
Last active January 24, 2020 14:34
Debian rbenv per-user install
#-------------------------------
# Debian 10
# https://linux4one.com/how-to-install-ruby-on-debian-10/
#-------------------------------
sudo apt update
sudo apt install git libreadline-dev zlib1g-dev libreadline-dev libncurses5-dev autoconf bison libssl-dev build-essential libyaml-dev libffi-dev libssl-dev libreadline-dev zlib1g-dev libgdbm-dev
cd
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
@coder4web
coder4web / postgrespro.sh
Last active November 10, 2019 21:29
Postgres Pro install, setup and maintenance
# @see https://postgrespro.ru/docs/postgrespro/11/binary-installation-on-linux.html
#-------------------------------
# Debian 8/9/10:
#-------------------------------
sudo apt-get install lsb-release
sudo sh -c 'echo "deb http://repo.postgrespro.ru/pgpro-11/debian $(lsb_release -cs) main" > /etc/apt/sources.list.d/postgrespro.list'
wget --quiet -O - http://repo.postgrespro.ru/pgpro-11/keys/GPG-KEY-POSTGRESPRO | sudo apt-key add -
sudo apt-get update
@coder4web
coder4web / mysql_monit.sql
Last active May 13, 2019 08:39
MySQL monitoring
-- all databases sizes
SELECT table_schema AS "Database",
ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)"
FROM information_schema.TABLES
GROUP BY table_schema;
-- sizes of all of the tables in a specific database
SELECT table_name AS "Table",
ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)"
FROM information_schema.TABLES
@coder4web
coder4web / zabbix_setup.sh
Last active March 23, 2019 17:04
Zabbix setup (CentOS. RHEL)
# ------------------------
# agent
# ------------------------
sudo rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
sudo yum list zabbix-agent
sudo yum install zabbix-agent
sudo firewall-cmd --zone=public --add-port=10050/tcp
sudo firewall-cmd --zone=public --add-port=10050/tcp --permanent
sudo semanage permissive -a zabbix_agent_t
sudo systemctl enable zabbix-agent.service
@coder4web
coder4web / php7_memcached_src.sh
Last active December 18, 2018 09:31
PHP 7 with Memcached from source
# -------------------------------------------------------
# STEP 1: install requirements
# -------------------------------------------------------
# CentOS / RHEL / Amazon EC2 AMI:
# @see https://webtatic.com/packages/php70/
sudo yum install php70w php70w-devel
sudo yum groupinstall "Development Tools"
sudo yum install libmemcached libmemcached-devel zlib zlib-devel
# -------------------------------------------------------
# Debian
@coder4web
coder4web / ubuntu_dualboot.sh
Last active August 31, 2018 14:35
Ubuntu dual-boot HOW-TO
# boot - How can I reinstall GRUB to the EFI partition? - Ask Ubuntu
# https://askubuntu.com/a/831241/19938
# Note : sdX = disk | sdXX = efi partition | sdXXX = system partition
sudo mount /dev/sdXXX /mnt
sudo mount /dev/sdXX /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install /dev/sdX
update-grub
@coder4web
coder4web / postgresql_roles.sql
Last active July 17, 2018 13:24
PostgreSQL roles
\z
-- Full access
GRANT ALL privileges ON DATABASE db TO admin_user;
GRANT ALL ON schema public TO admin_user;
GRANT ALL ON ALL TABLES IN SCHEMA public TO admin_user;
GRANT USAGE, SELECT ON ALL SEQUENCES IN SCHEMA public TO admin_user;
-- Read-only access
CREATE ROLE readonly;
@coder4web
coder4web / vertica_monit.sql
Last active April 3, 2018 14:43
Vertica management and monitoring
-- List of schemas
\dn
-- list all tables
\dt
-- list only tables with "public" schema
\dt public.*
-- database size
@coder4web
coder4web / aws_mercurial_install.sh
Last active February 27, 2018 10:05
How To Install Mercurial SCM on Amazon AMI
# https://www.mercurial-scm.org/
# https://www.mercurial-scm.org/wiki/UnixInstall#System-wide_installation
# rooted version :)
sudo -i
yum list mercurial
#Loaded plugins: priorities, update-motd, upgrade-helper
#Error: No matching Packages to list
yum groupinstall "Development Tools"
@coder4web
coder4web / redis_install_centos.txt
Last active September 10, 2017 01:45
Redis install on CentOS 6.4
BTW yum has last Redis too, remi repository at least.
$ sudo -i
$ yum list redis
$ redis.x86_64 2.6.13-1.el6.remi remi
But today we want compile redis from source (see http://redis.io/download)
$ yum install make gcc tcl
$ cd /usr/local/src