Skip to content

Instantly share code, notes, and snippets.

@aboritskiy
aboritskiy / SyncURLsCommand.php
Last active July 1, 2021 15:15
Magento2 EE Cloud tips and tricks
<?php
namespace Sitewards\SyncURLs\Console\Command;
use \Symfony\Component\Console\Command\Command;
use \Symfony\Component\Console\Input\InputInterface;
use \Symfony\Component\Console\Output\OutputInterface;
use \Magento\Framework\App\Config\ConfigResource\ConfigInterface;
use \Magento\Store\Model\StoreManagerInterface;
@aboritskiy
aboritskiy / keybase.md.
Created April 12, 2017 08:53
keybase.md.
### Keybase proof
I hereby claim:
* I am aboritskiy on github.
* I am aboritskiy (https://keybase.io/aboritskiy) on keybase.
* I have a public key ASA1HtFaV9H65HO0wuDSigZpBchwDzkQAecJV0FRA0AHvQo
To claim this, I am signing this object:
@aboritskiy
aboritskiy / README.md
Last active May 9, 2018 09:44
Magento 1 attribute usage statistic

Magento 1 attribute usage statistic

The idea here is super simple - check how much is current attribute used and decide which can be removed from the shop to increase the performance and/or reduce database load. Script might be quite heavy to run at once, thus consider splitting it in two by commenting out some left joins and corresponding count selects.

@aboritskiy
aboritskiy / README.me
Created June 12, 2018 21:50
MySQL Upgrade Amazon Linux
mysql -u root -p --execute="SET GLOBAL innodb_fast_shutdown=0"
mysqladmin -u root -p shutdown
sudo yum remove mysql55\*
sudo yum install mysql56-server
sudo service mysqld start
sudo mysql_upgrade -u root -p
@aboritskiy
aboritskiy / .htaccess
Created October 12, 2018 20:50
Apache2.4 block Magento1 guts
RewriteRule ^/\. - [L,R=403]
RewriteRule ^/app/ - [L,R=403]
RewriteRule ^/dev/ - [L,R=403]
RewriteRule ^/downloader/ - [L,R=403]
RewriteRule ^/includes/ - [L,R=403]
RewriteRule ^/lib/ - [L,R=403]
RewriteRule ^/shell/ - [L,R=403]
RewriteRule ^/pkginfo/ - [L,R=403]
RewriteRule ^/var/ - [L,R=403]
RewriteRule ^/rss/ - [L,R=403]
@aboritskiy
aboritskiy / provision.sh
Created October 15, 2018 07:03
AWS Autoscaling little demo
#!/bin/bash
yum update -y
yum install -y httpd
echo "<VirtualHost *:80>
ServerName default
ServerAdmin anton.boritskiy@gmail.com
DocumentRoot /var/www/html/
<Directory '/var/www/html/'>
Options FollowSymLinks Includes ExecCGI
AllowOverride All
@aboritskiy
aboritskiy / get-db-size
Created October 17, 2018 10:43
Database Tips and Tricks
SELECT table_schema as `Database`, table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
WHERE table_schema = "PUT-YOUR-DB-NAME-HERE"
ORDER BY (data_length + index_length) DESC;
@aboritskiy
aboritskiy / remove-submodules.sh
Created March 27, 2020 19:36
Interactively removes all project submodules, saving each remove in a separate commit and stopping before each.
#!/bin/bash
SUBMODULES_LIST=$(git submodule status | awk '{print $2}');
echo "Status before:"
echo
git submodule status
echo
for SUBMODULE_PATH in $SUBMODULES_LIST
@aboritskiy
aboritskiy / aws-snapshots-cleanup.sh
Created March 27, 2020 21:36
Interactively removes AWS snapshots that were created by CreateImage but AMI was removed.
#!/bin/bash
set -eu
AWS_ACCOUNT_ID=657433956652
echo "Snapshots exist for following images: "
aws ec2 describe-snapshots --filters Name=description,Values="Created by CreateImage*" --owner-id=$AWS_ACCOUNT_ID --output=text | grep "^SNAPSHOTS" | sed 's/.*\(ami-[0-9a-z]\+\).*/\1/' | sort | uniq | sort > /tmp/snapshot-cleanup-existing-snapshots
@aboritskiy
aboritskiy / archive-slack-channels.sh
Created April 1, 2020 08:50
archives dead slack channels
TOKEN=""
curl "https://slack.com/api/channels.list?token=$TOKEN&exclude_archived=true&pretty=1" > /tmp/channels.list
IDS=$(cat /tmp/channels.list | jq '.channels[] | select(.num_members == 0) | .id' | sed -e 's/"//g')
for ID in $IDS; do
CHANNEL_DATA=$(cat /tmp/channels.list | jq ".channels[] | select(.id == \"$ID\") | \"\(.id) \(.name) \(.num_members)\"")
echo "$CHANNEL_DATA"
read -p " proceed? " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo " archiving..."