Skip to content

Instantly share code, notes, and snippets.

View krasnuydyx's full-sized avatar

Andrii Danyliuk krasnuydyx

View GitHub Profile
awk -vDate=`date -d'now-2 hours' +[%Y-%m-%dT%H:%M:%S` '$4 > Date {print $1}' access.log | sort | uniq -c | sort -n | tail
@krasnuydyx
krasnuydyx / certbot-cloudfront.sh
Created April 30, 2019 18:15
certbot-cloudfront.sh
#!/usr/bin/env bash
AWS_ACCESS_KEY_ID="ARICICnfC3274R522L6F" \
AWS_SECRET_ACCESS_KEY="qLwaE0s7m/LrfP+" \
certbot --agree-tos -a certbot-s3front:auth \
--certbot-s3front:auth-s3-bucket sdfnowier \
--certbot-s3front:auth-s3-region us-east-2 \
-i certbot-s3front:installer \
--certbot-s3front:installer-cf-distribution-id EFGQREDSAF \
-d site.com -d www.site.com
@krasnuydyx
krasnuydyx / backup.sh
Created March 29, 2019 16:35
Simple backup script
#!/bin/bash
## Configuration
SRC_CODE="/var/jenkins_home"
BACKUP_DIR="/home/ec2-user/"
PROJECT_NAME="jenkins-vfqa"
DST_HOST="user@host"
REMOTE_DST_DIR="/root/backup"
EXCLUDES="-x '*/workspace/*' '*/jobs/*/builds/*' '*/jobs/*/lastStable/*' '*/jobs/*/lastSuccessful/*'"
BACKUP_DAILY=true # if set to false backup will not work
@krasnuydyx
krasnuydyx / sync.sh
Last active December 29, 2020 13:50
Environment sync (Magento Cloud)
#!/usr/bin/env bash
PROD_ENV="[email protected]"
STAGE_ENV="[email protected]"
INT_ENV="tx3iahfl3v2uk-integration-5ojmyuq--mymagento@ssh.us-3.magento.cloud"
TIMEFORMAT=%R
db_data_reg="cat app/etc/env.php | grep -A 10 \"'db'\""
try() {
"$@" || { echo "command failed, with exit code $?"; exit 1; }
#You can pull this off using mysqldump. Here the catch: You cannot ship the data because there may be a cost associated with shipping the data.
#For this example, let's says you want to rename mydb to ourdb
#STEP 01 : Create the new database
mysql> CREATE DATABASE ourdb;
#STEP 02 : Get schema without the triggers
mysqldump -hrdshost -uuser -ppassword -d -t -R --skip-triggers mydb > /tmp/schema.sql
#STEP 03 : Get the triggers
@krasnuydyx
krasnuydyx / mysql_size.sh
Last active August 19, 2020 23:25
List sizes of MySQL databases
# Database size
SELECT
table_schema AS "Database name",
SUM(data_length + index_length) / 1024 / 1024 AS "Size (MB)"
FROM information_schema.TABLES
GROUP BY table_schema;
# Database and index sizes
SELECT SUM(Data_length)/1024/1024/1024,SUM(Index_length)/1024/1024/1024 FROM information_schema.tables;
# WHERE table_schema = '';
@krasnuydyx
krasnuydyx / sysctl.conf
Created December 26, 2017 14:53
System optimization for 1-10G networks, tested on AWS
net.core.rmem_max = 11960320
net.core.wmem_max = 11960320
net.ipv4.tcp_rmem = 4096 524288 11960320
net.ipv4.tcp_wmem = 4096 524288 11960320
net.core.netdev_max_backlog = 30000
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.tcp_congestion_control = cubic
net.ipv4.tcp_window_scaling =1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_sack = 1
@krasnuydyx
krasnuydyx / vfc.vcl
Created December 7, 2017 13:43
Varnish block ip
acl forbidden {
"10.10.10.10";
}
sub vcl_recv {
if (client.ip ~ forbidden) {
error 403 "Forbidden";
}
}
@krasnuydyx
krasnuydyx / httpd.conf
Last active November 22, 2017 13:58
apache-magento
Header set Set-Cookie HttpOnly;Secure
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
Header always set X-XSS-Protection "1; mode=block"
#Header always append X-Frame-Options SAMEORIGIN
Header always set X-Content-Type-Options: nosniff
#Header set Pragma "no-cache"
#Header set Expires 0
<IfModule mpm_worker_module>
ServerLimit 24
@krasnuydyx
krasnuydyx / nginx.conf
Last active November 22, 2017 13:59
Nginx.conf optimized for magento
user nginx nginx;
worker_processes auto;
worker_rlimit_nofile 8192;
events {
worker_connections 8000;
}
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
http {