Skip to content

Instantly share code, notes, and snippets.

View grimzy's full-sized avatar
🕶️
if not true then false

Joseph Estefane grimzy

🕶️
if not true then false
View GitHub Profile
@grimzy
grimzy / phpx.bash
Last active May 29, 2019 17:49
Debugging Remote CLI with Phpstorm
#!/usr/bin/env bash
XDEBUG_CONFIG="idekey=PHPSTORM" PHP_IDE_CONFIG="serverName=$(hostname)" php -dxdebug.remote_host=`echo $SSH_CLIENT | awk '{print $1}'` "$@"
@grimzy
grimzy / composer.nodebug
Last active November 23, 2016 05:35
Composer without xdebug
#!/usr/bin/env bash
# Adapted from From http://stackoverflow.com/a/36723363/2657607
function php_no_xdebug {
local temporaryPath="$(mktemp -t php.XXXX).ini"
# Using awk to ensure that files ending without newlines do not lead to configuration error
php -i | grep "\.ini" | grep -o -e '\(/[a-z0-9._-]\+\)\+\.ini' | grep -v xdebug | xargs awk 'FNR==1{print ""}1' > "$temporaryPath"
@grimzy
grimzy / gitexec.cli
Created November 22, 2016 02:32
Executable file in Git
chmod u+x <filename>
git update-index --chmod=+x <filename>
git commit -am "<filename> is now executable."
@grimzy
grimzy / rm-img-dangling
Created November 25, 2016 18:14
Docker commands
docker images -qf dangling=true | xargs docker rmi
@grimzy
grimzy / tcp_socket binding
Created December 5, 2016 02:30
Intellij Docker Binding
socat -d TCP-LISTEN:2376,range=127.0.0.1/32,reuseaddr,fork UNIX:/var/run/docker.sock
@grimzy
grimzy / install-docker-bash-completion
Last active October 27, 2019 02:00
Install Docker completions on Mac
#!/usr/bin/env bash
brew install bash-completion
brew tap homebrew/completions
cat >> ~/.bash_profile <<EOL
if [ -f $(brew --prefix)/etc/bash_completion ]; then
. $(brew --prefix)/etc/bash_completion
fi
EOL
@grimzy
grimzy / names.sh
Created June 12, 2017 14:42
List Git authors
#!/usr/bin/env bash
#git log --format='%aN' | sort -u
#OR
git shortlog -s | cut -c8-
@grimzy
grimzy / config.php
Last active November 19, 2018 22:35
CI Dynamic base_url
$config['base_url'] = (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] == 443 ? 'https' : 'http') . "://" . (isset($_SERVER['SERVER_NAME']) ? $_SERVER['SERVER_NAME'] : 'localhost/') . str_replace(basename($_SERVER['SCRIPT_NAME']),"",$_SERVER['SCRIPT_NAME']);
// OR
$server_port = (isset($_SERVER['SERVER_PORT']) && !empty($_SERVER['SERVER_PORT'])) ? $_SERVER['SERVER_PORT'] : 80;
$server_name = (isset($_SERVER['SERVER_NAME']) && !empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : 'localhost/';
$script_name = str_replace(basename($_SERVER['SCRIPT_NAME']), "", $_SERVER['SCRIPT_NAME']);
$config['base_url'] = ($server_port == 443 ? 'https' : 'http') . "://" . $server_name . $script_name;
@grimzy
grimzy / MySQL
Created July 12, 2017 13:34
Copy database
mysqldump -h <source_host> -u <source_user> <source_db> | mysql -h <destination_host> -u <destination_user> <destination_db>
@grimzy
grimzy / get_sql_mode
Last active August 2, 2017 15:57
MySQL sql_mode
select @@sql_mode;