Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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"
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 / 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 {} \;
@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))"
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))