Skip to content

Instantly share code, notes, and snippets.

View jrearick's full-sized avatar

John Rearick jrearick

View GitHub Profile
@jrearick
jrearick / gitInfo.php
Created October 26, 2020 14:11
A PHP function that will get the branch or tag name and hash from a Git repository. It looks at the files in the .git directory and does not use exec().
<?php
$info = gitInfo();
echo "Branch/Tag: " . $info['branch'] . "<br />";
echo "Hash: " . $info['hash'] . "<br />";
/**
* Extracts the branch or tag name from a Git repository given the locaiton of
* a .git directory.
@jrearick
jrearick / ConfigEventsSubscriber.php
Created August 24, 2020 13:01
Config Change Event Subscriber Drupal 8
<?php
namespace Drupal\config_logger\EventSubscriber;
use Drupal\Core\Config\ConfigCrudEvent;
use Drupal\Core\Config\ConfigEvents;
use Drupal\Core\Session\AccountInterface;
use Psr\Log\LoggerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@jrearick
jrearick / xdebug.sh
Created January 4, 2019 21:11
A script that will enable and disable xdeubg on my system
#!/bin/bash
# xdebug.sh will toggle Xdebug between enabled and disabled if given no arguments.
# You may optionally provide a 1 or a 0 as an argument to enable it if it is off or
# disabled it if it is on. If Xdebug is enabled or disabled by this script it will restart
# apache. If you provide status as an arguemnt it will echo either "true" if Xdebug
# appears enabled, "false" if it isn't.
#
# Example: Turn off Xdebug if it's on
# xdebug.sh 0
@jrearick
jrearick / composer.json
Created December 14, 2018 19:17
Example Drupal composer.json from CIDUG Presentation https://groups.drupal.org/node/534613
{
"name": "drupal-composer/drupal-project",
"description": "Project template for Drupal 8 projects with composer",
"type": "project",
"license": "GPL-2.0-or-later",
"authors": [
{
"name": "",
"role": ""
}
@jrearick
jrearick / make_drupal_patches.sh
Created November 13, 2018 20:51
Script that will make patch files between Drupal 7 versions
#!/bin/bash
# Example: make_drupal_patches.sh 7.44 7.50
# Creates patches between the versions given for both git sourced Drupal and manually
# downloaded Drupal. Patch files are placed in ~/drupal_patches/
#
# Assumes Drupal 7.
set -e
# drush pm-list | grep features
Features Features (features) Module Enabled 7.x-2.10
# drush fra -y
Command fra needs the following module(s) enabled to run: features. [error]
The drush command 'fra' could not be executed.
# (ノಠ益ಠ)ノ
# drush cc drush
# drush fra -y
The following modules will be reverted:...
...
@jrearick
jrearick / watch_http_code.sh
Created April 20, 2016 14:22
This is a bash script of Mac OS X that will watch for a change in http status code and notify you via system bells, and the say command. I find this useful when waiting for someone to publish content on a website.
#!/bin/bash
set -e
[ -z "$1" ] && echo -e "Example:\n$0 http://www.example.com" && exit 1;
# Number of seconds between checks.
durationSleep=60;
original=$(curl -s -I $1 |grep "HTTP/");
@jrearick
jrearick / watch_dns.sh
Created April 20, 2016 14:17
This is a bash script for Mac OS X that will watch for a DNS record change and notify you via e-mail, system bells, and the say command. I find this useful when I'm waiting for someone else to make a DNS change or for DNS to propagate.
#!/bin/bash
set -e
[ -z "$1" ] && echo -e "Example:\n$0 www.example.com" && exit 1;
# Number of seconds between DNS queries.
durationSleep=60;
# Email address to send a notification to, if you have mail configured properly.