Skip to content

Instantly share code, notes, and snippets.

function array_merge_recursive_ex(array & $array1, array & $array2)
{
$merged = $array1;
foreach ($array2 as $key => & $value)
{
if (is_array($value) && isset($merged[$key]) && is_array($merged[$key]))
{
$merged[$key] = array_merge_recursive_ex($merged[$key], $value);
} else if (is_numeric($key))
@DavMorr
DavMorr / gen-d8-salt.sh
Created July 25, 2017 22:44 — forked from pfaocle/gen-d8-salt.sh
Generate Drupal 8 hash salt
drush eval "var_dump(Drupal\Component\Utility\Crypt::randomBytesBase64(55))"
@DavMorr
DavMorr / gist:5b435050faea108f76b7e1ac845c27e0
Last active September 8, 2017 11:51
Set all directories to 755, and all files to 644
If you need a quick way to reset your public_html data to 755 for directories and 644 for files, then you can use something like this:
cd /path/to/sites/site/docroot
find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;
additionally, if you know php runs as the user and not as "apache", then you can set php files to 600, for an extra level of security, eg:
find . -type f -name '*.php' -exec chmod 600 {} \;
Compiled from gist thread: https://gist.github.com/evanscottgray/8571828
##CONTAINERS
stop all containers:
docker stop $(docker ps -a -q)
--prefereable
docker kill $(docker ps -q)
--brute force
remove all containers
@DavMorr
DavMorr / Linux - display version of OS running.md
Last active February 18, 2018 22:05
Displays the current version of Linux OS running on machine, useful for quickly checking VM or Docker image.

Get Linux make, version and other info (same as cat /etc/os-release but with broader scope):

$ cat /etc/*release*
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
@DavMorr
DavMorr / PHP Code Tools - Install on OS X.md
Last active February 23, 2018 20:40
Installation instructions for some command line code review tools on Mac

CodeSniffer

via Composer (Drupal specific):

composer global require drupal/coder
composer global show -P  # should be equivalent to ~/.composer/vendor/drupal/coder
# Register Coder Standards: Drupal and DrupalPractice
composer global require drupal/coder:^8.2.12
composer global require dealerdirect/phpcodesniffer-composer-installer
# Review standards
@DavMorr
DavMorr / behat.yml
Created March 7, 2018 18:58
Composer does not create the top level behat.yml file when installing behat on OS X. This is out of the box for behat ~3.0 for drupal 8.
default:
suites:
default:
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\MessageContext
- Drupal\DrupalExtension\Context\DrushContext
extensions:
@DavMorr
DavMorr / behat_3.0_oob_commanands list
Created March 7, 2018 18:59
behat ~3.0 out of the box commands list
# $ vendor/bin/behat -dl
default | Given I am an anonymous user
default | Given I am not logged in
default | Given I am logged in as a user with the :role role(s)
default | Given I am logged in as a/an :role
default | Given I am logged in as a user with the :role role(s) and I have the following fields:
default | Given I am logged in as :name
default | Given I am logged in as a user with the :permissions permission(s)
default | Then I should see (the text ):text in the :rowText row
@DavMorr
DavMorr / git_branch_and_track__notes.md
Last active March 10, 2018 17:20
git checkout --track [remotename]/[branch] // shorthand for 'git checkout -b [branch] [remotename]/[branch]'

You need to create a local branch that tracks a remote branch. The following command will create a local branch named daves_branch, tracking the remote branch origin/daves_branch. When you push your changes the remote branch will be updated.

For most versions of git:

git checkout --track origin/daves_branch --track is shorthand for git checkout -b [branch] [remotename]/[branch] where [remotename] is origin in this case and [branch] is twice the same, daves_branch in this case.

For git 1.5.6.5 you needed this:

git checkout --track -b daves_branch origin/daves_branch

@DavMorr
DavMorr / XdebugOnMac-w-PHP7-n-AcquiaDevDesktop-support.md
Last active March 14, 2018 21:08
Install xdebug on Mac and add Acquia DevDesktop support

Download and extract the xdebug source code (I used xdebug-2.5.5).

$ cd xdebug-2.5.5
$ /Applications/DevDesktop/php7_0/bin/phpize

and now the step that was the one that caused most grief figuring out...

$ ./configure --with-php-config=/Applications/DevDesktop/php7_0/bin/php-config CC="gcc -arch i386" CXX="g++ -arch i386"
$ make
$ cp modules/xdebug.so /Applications/DevDesktop/php7_0/ext/