Skip to content

Instantly share code, notes, and snippets.

Avatar

Mike Crittenden mikecrittenden

View GitHub Profile
@mikecrittenden
mikecrittenden / wget.sh
Last active Oct 19, 2021
Download an entire website with wget, along with assets.
View wget.sh
# One liner
wget --recursive --page-requisites --adjust-extension --span-hosts --convert-links --restrict-file-names=windows --domains yoursite.com --no-parent yoursite.com
# Explained
wget \
--recursive \ # Download the whole site.
--page-requisites \ # Get all assets/elements (CSS/JS/images).
--adjust-extension \ # Save files with .html on the end.
--span-hosts \ # Include necessary assets from offsite as well.
--convert-links \ # Update links to still work in the static version.
@mikecrittenden
mikecrittenden / new_gist_file
Created Aug 15, 2016
View the git log for a specific line or number of lines in a file
View new_gist_file
git log -L 1,1:some-file.txt
@mikecrittenden
mikecrittenden / import.php
Last active Sep 8, 2021
Importing Drupal 8 config programmatically
View import.php
<?php
// Import arbitrary config from a variable.
// Assumes $data has the data you want to import for this config.
$config = \Drupal::service('config.factory')->getEditable('filter.format.basic_html');
$config->setData($data)->save();
// Or, re-import the default config for a module or profile, etc.
\Drupal::service('config.installer')->installDefaultConfig('module', 'my_custom_module');
@mikecrittenden
mikecrittenden / gist:7b654d3d686a4e434eda
Created Mar 26, 2015
Run a single specific Drupal update hook using Drush
View gist:7b654d3d686a4e434eda
drush php-eval "module_load_install('MYMODULE'); MYMODULE_update_NUMBER();"
@mikecrittenden
mikecrittenden / parent.php
Created Apr 11, 2017
Find the parent of a taxonomy term in Drupal 8
View parent.php
<?php
$parents = \Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadParents($term_id);
$parent_term = reset($parents);
@mikecrittenden
mikecrittenden / .platform.app.yaml
Last active Aug 6, 2021
A sample .platform.app.yaml file for hosting Grav CMS on Platform.sh
View .platform.app.yaml
name: grav_app # Rename this to whatever you want.
type: php:7.1
disk: 1024
web:
locations:
"/":
root: "app" # Assuming Grav lives in an app/ directory.
passthru: /index.php
expires: 1h
mounts:
@mikecrittenden
mikecrittenden / d8-drushless-revert.sh
Created Sep 15, 2016
Revert configuration in Drupal 8 with Drush (without using Features)
View d8-drushless-revert.sh
drush cim -y --partial --source=modules/path/to/module/config/install/
@mikecrittenden
mikecrittenden / ExampleModuleController.php
Last active Jun 17, 2021
Example of overriding a route controller in Drupal 8
View ExampleModuleController.php
<?php
/**
* @file
* Contains \Drupal\example_module\Controller\ExampleModuleController.
*/
// THIS FILE BELONGS AT /example_module/src/Controller/ExampleModuleController.php
namespace Drupal\example_module\Controller;
@mikecrittenden
mikecrittenden / App.js
Last active May 4, 2021
Using Google API (gapi) with React
View App.js
/* global gapi */
const API_KEY = 'YOURAPIKEYHERE';
import React, { Component } from 'react';
class App extends Component {
loadYoutubeApi() {
const script = document.createElement("script");
View postmortem.md

YYYY-MM-DD Post Mortem

Property Information
Impact Describe the impact of this incident
Status Ongoing/Resolved
Date of Incident When did this incident occur
Time Window Start and end time for this incident
Total Time How long (hours/minutes) did this incident last
JIRA Issue(s) Ticket number for any related JIRA tickets