Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / gist:53e3ad5c26d16f4f6be3220b078b19c9
Last active March 9, 2024 11:43
Include hidden files in tar archive
When you create a tar archive of a directory tree the hidden files are normally not included. Here’s how to include the hidden files.
Say you have a web directory called “/var/www/html/mysite/” that contains the following tree:
.htaccess
index.php
logo.jpg
style.css
admin_dir/.htaccess
admin_dir/includes.php
@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))