Skip to content

Instantly share code, notes, and snippets.

View radub's full-sized avatar
🎯
Focusing

Radu Barbu radub

🎯
Focusing
View GitHub Profile
# who is listening on port xxxx
listening() {
if [ $# -eq 0 ]; then
sudo lsof -iTCP -sTCP:LISTEN -n -P
elif [ $# -eq 1 ]; then
sudo lsof -iTCP -sTCP:LISTEN -n -P | grep -i --color $1
else
echo "Usage: listening [pattern]"
fi
}
@radub
radub / mysql_utils
Last active October 10, 2018 07:35
# enable logging to file
SET GLOBAL log_output = "FILE";
SET GLOBAL general_log_file = "/tmp/q_logfile.log";
SET GLOBAL general_log = 'ON';
# dump database
mysqldump --routines --single-transaction -q --add-drop-table --create-options --add-drop-database --disable-keys --extended-insert --set-charset {database_name} | gzip > {database_name}.sql.gz
# remove definer
perl -p -i.bak -e "s/DEFINER=[^ |\s]*//g" dbdumpfile.sql
# master reset cache, index and statics
sudo php ./bin/magento maintenance:enable && \
sudo php ./bin/magento setup:upgrade && \
sudo php ./bin/magento indexer:reindex && \
sudo php ./bin/magento setup:static-content:deploy -j 1 && \
sudo php ./bin/magento cache:clean && \
sudo php ./bin/magento setup:di:compile && \
sudo php ./bin/magento maintenance:disable
# reset admin pass
@radub
radub / magento1_cron_manually
Last active October 10, 2018 07:28
Run specific Magento 1.x cron manually
<?php
//Load Magento API
require_once 'app/Mage.php';
Mage::app();
//First we load the model
$model = Mage::getModel('module_identifier');
//Then execute the task
#!/usr/bin/env bash
VENDOR_LOCATION=''
for i in "$@"
do
case $i in
-l=*|--location=*)
VENDOR_LOCATION="${i#*=}"
shift
@radub
radub / xdebug.ini
Last active April 30, 2018 11:29
xDebug default cong
zend_extension=/usr/lib/php5/20121212/xdebug.so
xdebug.max_nesting_level="1000"
xdebug.remote_host=35.35.35.1
xdebug.remote_enable=1
xdebug.remote_port=9001
xdebug.remote_log="/tmp/xdebug.log"
@radub
radub / xdebug
Last active November 8, 2018 13:33
CLI xDebug phpunit
# xDebug
sudo apt-get install php-xdebug
# enable / disable
sudo phpdismod xdebug
sudo phpenmod xdebug
# xDebug CLI
# in PhpStorm set debugger port to 9001 if nginx
@radub
radub / git_utils
Last active October 10, 2018 07:30
show current git branch
# add to ~/.bashrc
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\[\033[01;32m\]\u@\h\[\033[01;36m\] \w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "
@radub
radub / .gitconfig
Last active August 29, 2015 14:13
.gitconfig
[user]
email = emailhere
name = namehere
[color]
ui = auto
interactive = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green