Skip to content

Instantly share code, notes, and snippets.

View christopher-hopper's full-sized avatar
:octocat:
contributing

Christopher Hopper christopher-hopper

:octocat:
contributing
View GitHub Profile
@christopher-hopper
christopher-hopper / drush-site-alias-make.sh
Created August 6, 2015 00:26
Generate a drush site-alias record for the current Drupal site.
#!/bin/sh
drush --uri="http://$(hostname -f)" site-alias @self --alias-name="local" --show-passwords --with-db --with-optional
@christopher-hopper
christopher-hopper / gist:5368555
Created April 12, 2013 01:24
JetBrains PhpStorm Exeption in plugin Ini4Idea v 1.0.6
JetBrains PhpStorm Exeption in plugin Ini4Idea
PhpStorm version 6.0
Ini4Idea version 1.0.6
What was I doing when it occurred:
I have configured *.info to be treated as an INI file. I have a file named filename.info open for editing.
I don't know when the exception error message first appeared, but as soon as I noticed it I sent this debug information. As a result, I'm not sure what I was doing when the exception happened.
@christopher-hopper
christopher-hopper / gist:6052008
Last active December 20, 2015 01:49
Generate a `.gitattributes` file
#
# Find text files with this command
#
grep -r -m 1 "^" . \
| grep -v "^Binary file" \
| gawk 'BEGIN { FS=":" } { print $1 }' \
| sed -re 's:.+\.([^\.]+)$:*.\1 text eol=lf:g' -e '/\//d' \
| sort -u
@christopher-hopper
christopher-hopper / gist:6118414
Last active December 20, 2015 10:49
Kill the processes and back-up accounts before removing

Remove Linux user accounts

I killed the processes and backed-up old accounts on the Peregrine UAT server 10.3.28.44. You can find tarballs for the home folders of all removed accounts on Peregrine UAT at:

10.3.28.44:/root/bak/deleted/users

To remove accounts safely I did the following:

  1. Lock the account.
@christopher-hopper
christopher-hopper / usrgrp-reset.sh
Last active December 28, 2015 17:49
Reset the groups for all users matching "user.name" to be primary group "developers", supplementary group "user.name"
#!/bin/bash
function usage() {
echo -e "Usage: " 1>&2;
echo -e "\t${0} [-h|-f|-i]" 1>&2;
echo -e "Description: " 1>&2;
echo -e "\tReset all users to have \`developer' as their primary group" 1>&2;
}
while getopts ":hfi" FLAG; do
case "${FLAG}" in
@christopher-hopper
christopher-hopper / xdebug-enable.sh
Last active August 25, 2016 03:28
Enable PHP xdebug by moving the /etc/php.d/*.ini
#!/usr/bin/env bash
# vim:sw=3 ts=6 ft=sh
# Uses BASH3 Boilerplate
# More info:
# - https://github.com/kvz/bash3boilerplate
# - http://kvz.io/blog/2013/02/26/introducing-bash3boilerplate/
#
# Version 1.0.0
#
# Usage:
@christopher-hopper
christopher-hopper / persist-file-perms.md
Last active October 12, 2016 05:16
How to persist file system permissions for web applications.

Persist Filesystem Permissions

The writable files and folders for web applications often require specific user, group and permission masks to persist, even when new files and sub-folders are added by users or the application itself.

For example, permissions might need to be:

File mode

u:rw,g:rw
diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
index 87465ca06f..377d36f84e 100644
--- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
+++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
@@ -4,6 +4,7 @@
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableMetadata;
+use Drupal\Core\Entity\EntityInterface;
use Drupal\views\Plugin\views\PluginBase;

Keybase proof

I hereby claim:

  • I am christopher-hopper on github.
  • I am chop (https://keybase.io/chop) on keybase.
  • I have a public key ASBUM3iCrJK9V9U_hmodhM-GRmWCGilGwpyN2KpEOWyjnQo

To claim this, I am signing this object:

@christopher-hopper
christopher-hopper / find-windows-process-listening-on-port.md
Last active October 8, 2018 18:34
Find Windows processes listening on a port

Windows processes listening on a port

These examples assume you are using Windows 7 and have Cygwin installed with the awk package.

This single command will identify the process listening on port "2222" by feeding netstat output into tasklist using gawk.

netstat -aon | gawk ' $2~/:2222/ { system("tasklist /svc /FI \"PID eq " $5 "\"") } '