Skip to content

Instantly share code, notes, and snippets.

View sergeycherepanov's full-sized avatar
:bowtie:
Focusing

S.Cherepanov sergeycherepanov

:bowtie:
Focusing
View GitHub Profile
@sergeycherepanov
sergeycherepanov / akeneo_fastdump.sh
Last active September 21, 2018 19:56
akeneo_fastdump.sh
#!/bin/bash
host=$1
user=$2
password=$3
dbname=$4
[[ -f /tmp/${dbname}_tables.txt ]] && rm /tmp/${dbname}_tables.txt
mysql -N "-h${host}" -u${user} -p${password} -e "show tables like 'pim_versioning_version';" ${dbname} >> /tmp/${dbname}_tables.txt
@sergeycherepanov
sergeycherepanov / mage1login.php
Last active February 27, 2019 05:33
Loging in under any customer by using the customer_id only
<?php
if (version_compare(phpversion(), '5.2.0', '<')) {
echo 'It looks like you have an invalid PHP version. Magento supports PHP 5.2.0 or newer';
exit;
}
$magentoRootDir = getcwd();
$bootstrapFilename = $magentoRootDir . '/app/bootstrap.php';
$mageFilename = $magentoRootDir . '/app/Mage.php';
sudo strace -p {PID} -s 512 2>&1 | awk '{ print strftime("[\%Y-\%m-\%d \%H:\%M:\%S]"), " --> ", $0 }' | tee -a ~/strace.log
@sergeycherepanov
sergeycherepanov / crontab.sh
Last active June 20, 2018 07:08
magento2 crontab здорового человека
*/5 * * * * /usr/bin/flock -w 10 -x /tmp/magento.cron.lock /bin/bash -c "nice -n 19 ionice -c2 -n7 /usr/bin/php7.0 /var/www/current/bin/magento cron:run 2>&1 | awk '{ print strftime(\"[\%Y-\%m-\%d \%H:\%M:\%S]\"), \$0 }' | tee -a /var/www/current/var/log/magento.cron.log; echo 'Complete' | awk '{ print strftime(\"[\%Y-\%m-\%d \%H:\%M:\%S]\"), \$0 }' | tee -a /var/www/current/var/log/magento.cron.log"
@sergeycherepanov
sergeycherepanov / magento2_fastdump.sh
Last active August 3, 2018 19:53
Dumping the magento 2 database without data of heavy tables
#!/bin/bash
host=$1
user=$2
password=$3
dbname=$4
[[ -f /tmp/${dbname}_tables.txt ]] && rm /tmp/${dbname}_tables.txt
mysql -N "-h${host}" -u${user} -p${password} -e "show tables like 'ewave_ai_logs%';" ${dbname} >> /tmp/${dbname}_tables.txt
map $_project_name $project_name {
default undefined;
}
map $_pool $pool {
default undefined;
}
map $_php_version $php_version {
default undefined;
@sergeycherepanov
sergeycherepanov / queues.json
Created January 23, 2018 15:22
RabbitMQ metrics
{
"arguments": {
"x-max-priority": 4
},
"auto_delete": false,
"backing_queue_status": {
"avg_ack_egress_rate": 0.0,
"avg_ack_ingress_rate": 0.0,
"avg_egress_rate": 0.0,
"avg_ingress_rate": 0.0,

fluentd.conf

<source>
  @type tail
  path /tmp/log-test.log #...or where you placed your Apache access log
  pos_file /tmp/log-test.log.pos # This is where you record file position
  tag foobar.json #fluentd tag!
  format json # one JSON per line
  time_key time_field # optional; default = time
@sergeycherepanov
sergeycherepanov / sshd_config
Last active October 11, 2017 17:17
Server does not support diffie-hellman-group14-sha1 for keyexchange
Ciphers 3des-cbc,blowfish-cbc,cast128-cbc,arcfour,arcfour128,arcfour256,aes128-cbc,aes192-cbc,aes256-cbc,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com,chacha20-poly1305@openssh.com
KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
PRIVATE_IFACE=$(ip -4 link show | grep 'ens[0-9]' -o | head -1)
PUBLIC_IFACE=$(ip -4 link show | grep 'ens[0-9]' -o | tail -1)
PRIVATE_SUBNET=$(ip -4 addr show ens4 | grep inet | grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\/[0-9]\+' -o | awk -F\. '{print $1 "." $2 "." $3 ".0"}')
echo "${PRIVATE_SUBNET}" | grep '^172\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.0$' || {
echo "Invalid private network '${PRIVATE_SUBNET}' must be 172.x.x.x"
exit 1
}
sysctl -w net.ipv4.ip_forward=1
iptables -A FORWARD --src ${PRIVATE_SUBNET}/24 -i ${PRIVATE_IFACE} -j ACCEPT
iptables -A FORWARD -j DROP