Skip to content

Instantly share code, notes, and snippets.

View hawkeyetwolf's full-sized avatar

Hawkeye Tenderwolf hawkeyetwolf

View GitHub Profile
@hawkeyetwolf
hawkeyetwolf / bash script to create plist
Last active August 29, 2015 14:07
Increase OS X Open Files Limit
#!/bin/bash
echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>Increase open files limit</string>
<key>ProgramArguments</key>
<array>
@hawkeyetwolf
hawkeyetwolf / fix-permissions.sh
Created December 22, 2015 16:24
Restore secure file and directory permissions to Drupal site
#!/bin/bash
if [ $(id -u) != 0 ]; then
printf "This script must be run as root.\n"
exit 1
fi
drupal_path=${1%/}
drupal_user=${2}
httpd_group="${3:-www-data}"
# Help menu
@hawkeyetwolf
hawkeyetwolf / install-pre-commit-hook.php
Created December 22, 2015 16:26
Install useful git pre-commit hooks
<?php
echo "Creating hooks directory.\n";
mkdir('.git/hooks', 0775, true);
echo "Downloading pre-commit hook.\n";
$fp = fopen('.git/hooks/pre-commit', 'w');
$precommit = file_get_contents('http://gitscripts.s3.amazonaws.com/pre-commit');
fwrite($fp, $precommit);
fclose($fp);
@hawkeyetwolf
hawkeyetwolf / increase-open-files-limit.sh
Last active December 22, 2015 16:47
Increase OS X Open Files Limit (bash script)
#!/bin/bash
echo '<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>Increase open files limit</string>
<key>ProgramArguments</key>
<array>
@hawkeyetwolf
hawkeyetwolf / watchdog-krumo.php
Last active December 22, 2015 16:49
Watchdog with Krumo
<?php
$path = '/' . drupal_get_path('module', 'devel');
$js = $path . '/krumo/krumo.js';
$css = $path . '/krumo/skins/orange/skin.css';
$vars = array(
'!script' => "<script type='text/javascript' src='$js'></script>",
'!link' => "<link rel='stylesheet' type='text/css' href='$css'></link>",
);
watchdog('debug', kprint_r($_GET, TRUE) . '!script !link', $vars, WATCHDOG_DEBUG);
@hawkeyetwolf
hawkeyetwolf / panels-403-page.php
Last active December 22, 2015 16:50
Drupal Panels Page 403 Export Code
<?php
$page = new stdClass();
$page->disabled = FALSE; /* Edit this to true to make a default page disabled initially */
$page->api_version = 1;
$page->name = 'access_denied';
$page->task = 'page';
$page->admin_title = 'Access Denied (403)';
$page->admin_description = '';
$page->path = 'access-denied';
@hawkeyetwolf
hawkeyetwolf / review.sh
Last active December 22, 2015 16:51
Drush coder review with args
#!/bin/sh
drush coder-review --comment --no-empty --i18n --minor --sql --style --sniffer --security --release
@hawkeyetwolf
hawkeyetwolf / drush-alias-remote-host-check.php
Last active April 4, 2016 22:16
Drush aliases: scrub "remote host" key for cross-environment use
<?php
/**
* @file
* Example drush alias file for multihost use.
*/
// Alias settings common to all.
$aliases['base'] = array(
'root' => '/var/www/docroot',
@hawkeyetwolf
hawkeyetwolf / USAGE.md
Created April 12, 2016 15:21
Securing file permissions and ownership in Drupal

Securing file permissions and ownership in Drupal

@see https://www.drupal.org/node/244924

Copy the code above to a file, name it fix-permissions.sh and run it as follows:

sudo bash fix-permissions.sh --drupal_path=your/drupal/path --drupal_user=your_user_name

Note: The server group name is assumed www-data, if it differs use the --httpd_group=GROUP argument.

@hawkeyetwolf
hawkeyetwolf / gist:073ffbd5bdc60018099c738b8ec9e880
Last active November 18, 2016 02:24
Upload SSH public key to authorized_keys
# Thanks to Chris Hales for giving me this little snippet back in the day.
# Replace "__SERVER__" with "user@hostname".
cat ~/.ssh/id_rsa.pub | ssh __SERVER__ 'cat >> ~/.ssh/authorized_keys'
# Make sure permissions are correctly set on the file and its parent directory.
ssh __SERVER__ 'chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys'