Skip to content

Instantly share code, notes, and snippets.

View richardbporter's full-sized avatar

Richard B. Porter richardbporter

  • North Liberty, IA
View GitHub Profile
@crittermike
crittermike / import.php
Last active June 6, 2025 11:21
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');
@rocketeerbkw
rocketeerbkw / example.php
Last active June 23, 2023 18:42
How to migrate multi-value link field in Drupal 8
<?php
class Example extends SourcePluginBase {
public function prepareRow(Row $row) {
parent::prepareRow($row);
// I do some data manipulation to end up with an array that looks like this,
// which I want to import into multi-value link field.
$links = [
@ikennaokpala
ikennaokpala / nfs-vagrant-error.md
Last active January 13, 2025 13:03
Vagrant error :NFS is reporting that your exports file is invalid

Vagrant error :NFS is reporting that your exports file is invalid

==> default: Exporting NFS shared folders...
NFS is reporting that your exports file is invalid. Vagrant does
this check before making any changes to the file. Please correct
the issues below and execute "vagrant reload":

exports:2: path contains non-directory or non-existent components: /Users/<username>/path/to/vagrant
exports:2: no usable directories in export entry
exports:2: using fallback (marked offline): /
@jamsinclair
jamsinclair / shrug.md
Last active September 14, 2024 18:56
Markdown Escaped Shrug

¯\_(ツ)_/¯

@krystianbuczak
krystianbuczak / Pimp My Log: Drupal syslog regex configuration
Created November 18, 2015 16:47
Drupal syslog regex configuration for Pimp My Log php log viewer
// paste it in your config.user.php configuration file in section files: {}
"syslog": {
"display" : "Drupal",
"path" : "\/var\/log\/drupal.log", //set your Drupal syslog file path
"refresh" : 5,
"max" : 10,
"notify" : true,
"order" : -1,//set order you want
"sort" : "Date",
"thinit" : [ "Date", "Site", "Type", "Request", "Referer", "UID", "Message" ],
@stefansundin
stefansundin / install-pre-commit.sh
Last active December 6, 2025 05:41
Git pre-commit check to stop accidental commits to master/main/develop branches.
#!/bin/bash
# This gist contains pre-commit hooks to prevent you from commiting bad code or to the wrong branch.
# There are six variants that I have built:
# - pre-commit: stops commits to master/main/develop branches.
# - pre-commit-2: also includes a core.whitespace check.
# - pre-commit-3: the core.whitespace check and an EOF-newline-check.
# - pre-commit-4: only the core.whitespace check.
# - pre-commit-5: elixir formatting check.
# - pre-commit-6: prettier formatting check.
# Set the desired version like this before proceeding:
@delphian
delphian / drush-flush-memcache.sh
Created September 16, 2013 17:12
Manually flush memcache from the drush command prompt
# Copy this into your command prompt to manually flush memcache.
# Replace localhost.com with the domain name of the drupal site.
drush ev "dmemcache_flush()" --uri="localhost.com"
@nvk
nvk / gspace.sh
Last active December 16, 2015 08:09
Compress git repos (git gc) recursively
# Compress git repos (git gc) recursively
# Use as at will, by @nvk
gspace(){
for gitdir in `find ./ -name .git`;
do
workdir=${gitdir%/*};
hrline 44; # see http://gist.github.com/nvk/5340820
echo $workdir;
git --git-dir=$gitdir --work-tree=$workdir gc --aggressive;
@jxson
jxson / README.md
Created February 10, 2012 00:18
README.md template

Synopsis

At the top of the file there should be a short introduction and/ or overview that explains what the project is. This description should match descriptions added for package managers (Gemspec, package.json, etc.)

Code Example

Show what the library does as concisely as possible, developers should be able to figure out how your project solves their problem by looking at the code example. Make sure the API you are showing off is obvious, and that your code is short and concise.

Motivation