Skip to content

Instantly share code, notes, and snippets.

View crittermike's full-sized avatar

Mike Crittenden crittermike

View GitHub Profile
@crittermike
crittermike / wget.sh
Last active March 26, 2024 22:49
Download an entire website with wget, along with assets.
# 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.
@crittermike
crittermike / chmod.md
Last active March 2, 2024 22:50
How to chmod only directories

Use chmod +X (as opposed to +x) which will make only directories executable and leave files alone.

This is great for recursively fixing a Drupal files directory. For example:

chmod -R 664 sites/default/files && chmod -R a+X sites/default/files

That will make all your files writeable by you and the server, but not executable, but will also make directories executable (i.e., listable).

@crittermike
crittermike / import.php
Last active August 11, 2023 10:39
Importing Drupal 8 config programmatically
<?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');
@crittermike
crittermike / d8-drushless-revert.sh
Created September 15, 2016 13:20
Revert configuration in Drupal 8 with Drush (without using Features)
drush cim -y --partial --source=modules/path/to/module/config/install/
@crittermike
crittermike / jira_template.md
Last active November 15, 2022 17:54
JIRA ticket template in the 3 C's format (Card, Conversation, and Confirmation)

h2. Card

Also known as the User Story. Explain the requirement in a sentence or two. This should just enough text to identify the requirement, including any crucial information about site/environment.

As a [user role], I want [function], so that [value].

If this doesn't fit as a user story (e.g., a bug ticket), that's fine, just explain it as a concise sentence.

h2. Conversation

@crittermike
crittermike / App.js
Last active May 9, 2022 08:18
Using Google API (gapi) with React
/* global gapi */
const API_KEY = 'YOURAPIKEYHERE';
import React, { Component } from 'react';
class App extends Component {
loadYoutubeApi() {
const script = document.createElement("script");
@crittermike
crittermike / disable_aggregation.md
Last active February 14, 2022 12:17
Disabling CSS/JS aggregation via Drush in Drupal 7 and Drupal 8

Drupal 7

drush vset preprocess_css 0 --yes
drush vset preprocess_js 0 --yes

Drupal 8

@crittermike
crittermike / outline.md
Last active January 6, 2022 21:38
Difficult Conversations outline

Step 1: Prepare by Walking Through the Three Conversations

  1. Sort out What Happened.
  • Where does your story come from (information, past experiences, rules)? Theirs?
  • What impact has this situation had on you? What might their intentions have been?
  • What have you each contributed to the problem?
  1. Understand Emotions.
@crittermike
crittermike / new_gist_file
Created August 15, 2016 13:43
View the git log for a specific line or number of lines in a file
git log -L 1,1:some-file.txt
@crittermike
crittermike / gist:7b654d3d686a4e434eda
Created March 26, 2015 00:56
Run a single specific Drupal update hook using Drush
drush php-eval "module_load_install('MYMODULE'); MYMODULE_update_NUMBER();"