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 / magento2.custom.logger.php
Last active May 12, 2019 11:27
magento2 custom logger
<?php
class Example
{
/**
* @return \Psr\Log\LoggerInterface
*/
public static function getLogger()
{
static $logger;
if (!$logger) {
<?php
/**
Extension url: https://github.com/runkit7/runkit7
*/
runkit_function_copy('curl_exec', 'curl_exec_orig');
function curl_exec_redefined($ch) {
if (!is_resource($ch)) {
@sergeycherepanov
sergeycherepanov / script.sh
Created March 13, 2019 18:29
shallow update not allowed
Here's what I ended up doing - it worked perfectly. Note that I was moving from my old host (Bitbucket) to my new one (Gitlab). My comments are above the commands:
# First, shallow-clone the old repo to the depth we want to keep
git clone --depth=50 https://[email protected]/....git
# Go into the directory of the clone
cd clonedrepo
# Once in the clone's repo directory, remove the old origin
git remote remove origin
@sergeycherepanov
sergeycherepanov / magento1_fastdump.sh
Created January 3, 2019 14:55
magento1_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 'sales\_%';" ${dbname} >> /tmp/${dbname}_tables.txt
@sergeycherepanov
sergeycherepanov / php56brew.patch
Last active December 27, 2018 14:15
php56brew.patch
diff --git a/acinclude.m4 b/acinclude.m4
index 168c465f8d..6c087d152f 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -441,7 +441,11 @@ dnl
dnl Adds a path to linkpath/runpath (LDFLAGS)
dnl
AC_DEFUN([PHP_ADD_LIBPATH],[
- if test "$1" != "/usr/$PHP_LIBDIR" && test "$1" != "/usr/lib"; then
+ case "$1" in
@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