Skip to content

Instantly share code, notes, and snippets.

View jez500's full-sized avatar

Jeremy Graham jez500

View GitHub Profile
@jez500
jez500 / pingtest.sh
Last active May 10, 2023 11:42
Check for internet on router or router host (eg proxmox) and reboot if cannot ping hosts
#!/bin/sh
#=====================================================================
# pingtest.sh
# -----------
# Inspiration: https://forum.netgate.com/topic/64563/pfsense-auto-reboot-script-when-google-is-unreachable/9
#
# Prep
# mkdir -p /var/log/pingtest
#
@jez500
jez500 / mysite.site.yml
Last active June 13, 2019 04:39
Drush 9 alias example with php binary specified
production:
options: { }
root: '/home/mysite/www/docroot'
uri: 'mysite.example.com'
host: mysite.example.com
user: mysite
ssh:
options: '-p 22' # Change SSH Port
paths:
drush-script: /home/mysite/www/vendor/drush/drush/drush.php
@jez500
jez500 / package.json
Created December 26, 2018 11:32
Simple Webpack 4 Compile SCSS to CSS config with autoprefix and minify
{
"name": "my-project",
"version": "1.0.0",
"description": "Simple SCSS complie with autoprefix and minify",
"scripts": {
"build": "webpack"
},
"devDependencies": {
"autoprefixer": "^9.0.0",
"breakpoint-sass": "^2.7.1",
@jez500
jez500 / .htaccess
Created April 9, 2018 00:39
Remove basic auth (httpauth) with htaccess
# Disable httpauth set previously (at a higher, less specific level)
Satisfy Any
Order Allow,Deny
Allow from all
@jez500
jez500 / MyForm.php
Created January 8, 2018 01:06
Drupal 8 Basic form example
<?php
namespace Drupal\my_module\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Class TestAjaxFormSelect.
*/
class MyForm extends FormBase {
@jez500
jez500 / TestAjaxFormSelect.php
Created January 8, 2018 00:53
Drupal 8 Ajax form example when select box changed
<?php
namespace Drupal\my_module\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Class TestAjaxFormSelect.
*/
@jez500
jez500 / sync-d8-to-local
Created August 15, 2017 03:01
Sync remote DB to local with backup, run composer, run compass, ready for new feature
# Sync a D8 database and enable dev modules.
# Usage: sync_d8 [site folder] [site alias] [alias env to get db from]
# Example: sync_d8 boral boral dev
function sync_d8() {
local site="$1"
local alias="@$2"
local env="$3"
local site_dir=~/sites/"$site"
local backup_dir=~/sites/db_backups/"$site"
@jez500
jez500 / d8-views-exp-form-alter.php
Last active October 12, 2023 12:20
Drupal 8 - Hook form alter views exposed form
<?php
/**
* Implements hook_form_alter().
*/
function MYMODULE_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
$view_names = array('my_view_name');
$view = $form_state->getStorage('view');
if ($form_id == 'views_exposed_form' && in_array($view['view']->id(), $view_names)) {
// Do some shilzzle.