Skip to content

Instantly share code, notes, and snippets.

View twfahey1's full-sized avatar

Tyler Fahey twfahey1

View GitHub Profile
Drupal.behaviors.mybehavior = {
attach: function (context, settings) {
$('#some_element', context).once('mybehavior', function () {
// Code here will only be applied to $('#some_element')
// a single time.
});
}
};
@twfahey1
twfahey1 / command.php
Created September 10, 2020 14:44
Custom clear cache WP CLI plugin example
<?php
/*
Plugin Name: Custom clear cache
Description: Clears out the custom cache code
Author: Tyler Fahey
Version: 1.0.0
Author URI: https://tylerfahey.com
*/
class CCC_CLI {
@twfahey1
twfahey1 / css-media-queries
Created August 26, 2020 03:19 — forked from bluehazetech/css-media-queries
CSS: SCSS Breakpoints, Mixins and Usage
/*------------------------------------*\
breakpoint vars
\*------------------------------------*/
$break-320: 20em;
$break-321: 20.0625em;
$break-480: 30em;
$break-600: 37.5em;
$break-768: 48em;
$break-980: 61.25em;
$break-1024: 64em;
@twfahey1
twfahey1 / README.md
Created August 13, 2020 13:59 — forked from jleehr/README.md
[Drupal 8] Alter route (permissions) for taxonomy vocabulary page

[Drupal 8] Alter route (permissions) for taxonomy vocabulary page

Needs the patch: https://www.drupal.org/node/1848686

Split "Administer vocabularies and terms" permission: Access the taxonomy overview page and Add terms in vocabulary name

File structure:

mymodule
|- src
@twfahey1
twfahey1 / gh action snippet
Created July 28, 2020 12:39
GitHub actions snippet to install apache
- name: Install Apache
run: |
pwd
sudo apt update
sudo apt install apache2
echo "GETTING ADMIN PERMS SETUP"
sudo adduser $(whoami) www-data
sudo adduser $(whoami) root
@twfahey1
twfahey1 / example-wp.sh
Last active August 4, 2022 11:04
Pantheon - run php-script (php eval alternative) via terminus against a site
cat hello.php | terminus remote:wp ${SITE}.${ENV} -- eval-file -
@twfahey1
twfahey1 / gist:1feba46ea46741a270de4709ab2155fd
Created July 16, 2020 14:41
Show tables with engine and size - MySQL
SELECT table_name AS "Tables", engine AS "Engine",
-> round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
-> FROM information_schema.TABLES
-> WHERE table_schema = "pantheon"
-> ORDER BY (data_length + index_length) DESC;
@twfahey1
twfahey1 / DropzoneJs.php
Created June 1, 2020 14:58
DropzoneJs fix for Pantheon multiple appserver environments
<?php
namespace Drupal\dropzonejs\Element;
use Drupal\Component\Utility\Bytes;
use Drupal\Component\Utility\Environment;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element\FormElement;
@twfahey1
twfahey1 / run-command.sh
Created May 13, 2020 15:59
Run php script with drush against Pantheon site with terminus
➜ echo "print_r( variable_get('mail_system'));" | terminus drush my-pantheon-site.dev -- php-script -
Array
(
[default-system] => DefaultMailSystem
[htmlmail] => HTMLMailSystem
)
[notice] Command: my-pantheon-site.dev -- drush php-script [Exit: 0]
@twfahey1
twfahey1 / settings.php
Created April 24, 2020 16:59
Block IP addresses in PHP
<?php
$deny = array("111.111.111", "222.222.222", "333.333.333");
if (in_array ($_SERVER['REMOTE_ADDR'], $deny)) {
header("location: https://example.com/");
exit();
}
?>