Skip to content

Instantly share code, notes, and snippets.

View evasilev's full-sized avatar
🐧

Jenia evasilev

🐧
View GitHub Profile
@evasilev
evasilev / db1-db2-only-tables-diff.sh
Created June 5, 2023 13:18 — forked from molotovbliss/db1-db2-only-tables-diff.sh
Easily compare with diff, mysqldump two DB tables only (no data)
# Easily compare with diff, mysqldump two DB table schemas ignoring /* SET Comments etc... */ with grep
# Used originaly to locate missing custom tables from Magento 1.x to Magento 2.x after data migration
# dump both databases with as little details as possible (DONT run these in production without table locking disabled!)
# Use grep to remove /* SET ... */ like comments from dump and save to > dbX.sql
mysqldump --skip-set-charset --skip-triggers --skip-opt -K --skip-comments --skip-extended-insert -d --no-data -u root -p db1 | grep -v '^\/\*![0-9]\{5\}.*\/;$' > db1.sql;
mysqldump --skip-set-charset --skip-triggers --skip-opt -K --skip-comments --skip-extended-insert -d --no-data -u root -p db2 | grep -v '^\/\*![0-9]\{5\}.*\/;$' > db2.sql;
# compare both db dumps and grep for only CREATE TABLE lines
diff db1.sql db2.sql | grep -iP '^\<.CREATE.TABLE.\`.+\`'
@evasilev
evasilev / docker-prune.sh
Created February 10, 2022 21:20 — forked from sethbergman/docker-prune.sh
Prune stale Docker containers, images & volumes (Bash) (versions < 1.13.0)
#!/usr/bin/env bash
stale_images=`docker images --no-trunc --quiet --filter "dangling=true"`
stale_containers=`docker ps --no-trunc --quiet --filter "status=exited"`
stale_volumes=`docker volume ls --quiet --filter "dangling=true"`
stale_images_count=`echo "$stale_images" | sed '/^\s*$/d' | wc -l | xargs`
stale_containers_count=`echo "$stale_containers" | sed '/^\s*$/d' | wc -l | xargs`
stale_volumes_count=`echo "$stale_volumes" | sed '/^\s*$/d' | wc -l | xargs`
echo "Removing stale containers..."
@evasilev
evasilev / vim_cheatsheet.md
Created February 9, 2022 23:32 — forked from awidegreen/vim_cheatsheet.md
Vim shortcuts

Introduction

  • C-a == Ctrl-a
  • M-a == Alt-a

General

:q        close
:w        write/saves
:wa[!]    write/save all windows [force]
:wq       write/save and close
@evasilev
evasilev / rclone.conf
Created January 25, 2022 15:27 — forked from csereno/rclone.conf
~/.config/rclone/rclone.conf file demonstrating configurations for Wasabi, Google, and AWS S3
# For more details see https://rclone.org/s3/
[wasabi]
type = s3
provider = Wasabi
access_key_id = xxxxx
secret_access_key = xxx
region = us-east-1
endpoint = s3.wasabisys.com
@evasilev
evasilev / screen-docker-for-mac.sh
Created October 19, 2021 08:17 — forked from joacim-boive/screen-docker-for-mac.sh
Screen Commands for Docker for Mac (prevent garbled text on reconnect)
# connect to tty on Docker for Mac VM
screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
# disconnect that session but leave it open in background
Ctrl-a d
# list that session that's still running in background
screen -ls
# reconnect to that session (don't open a new one, that won't work and 2nd tty will give you garbled screen)
log_format json '{'
'"http":{'
'"method":"$request_method",'
'"request_id":"$request_id",'
'"status_code":$status,'
'"content_type":"$content_type",'
'"url":"$request_uri",'
'"url_details":{'
'"path":"$uri",'
'"scheme":"$scheme",'
@evasilev
evasilev / gist:c3ea5c7b7816f28640dfa7a2b4a7fb80
Created August 16, 2021 22:28 — forked from mikhailov/gist:9639593
Nginx S3 Proxy with caching
events {
worker_connections 1024;
}
http {
default_type text/html;
access_log /dev/stdout;
sendfile on;
keepalive_timeout 65;
@evasilev
evasilev / haproxy.cfg
Created August 16, 2021 22:22 — forked from T0MM0R/haproxy.cfg
Let's Encrypt Auto-Renewal script for HAProxy
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
maxconn 2048
@evasilev
evasilev / remove_apt_cache
Created July 20, 2021 13:48 — forked from marvell/remove_apt_cache
Remove APT cache (for Dockerfile)
apt-get clean autoclean
apt-get autoremove --yes
rm -rf /var/lib/{apt,dpkg,cache,log}/
@evasilev
evasilev / Dockerfile
Created July 8, 2021 07:31 — forked from evansims/Dockerfile
Dockerfile: php-fpm 7.4-fpm alpine w/ gd bz2 intl mbstring redis mongodb xdebug opcache
FROM php:7.4-fpm-alpine
WORKDIR "/application"
# Install essential build tools
RUN apk add --no-cache \
git \
yarn \
autoconf \
g++ \
make \