Skip to content

Instantly share code, notes, and snippets.

{
"condition": "event == 'update' AND data.status = 'published'",
"query": "query { type, id, text }",
"url": "http://example.com/hooks/update"
}
@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');
@robvolk
robvolk / es6_fetch_example.js
Last active October 17, 2019 16:46
AJAX requests in ES6 using fetch()
// ES6 Fetch docs
// https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
fetch('https://some.url.com')
.then(response => {
if (response.ok) {
return Promise.resolve(response);
}
else {
return Promise.reject(new Error('Failed to load'));
npm install --save react react-dom && npm install --save-dev html-webpack-plugin webpack webpack-dev-server babel-{core,loader} babel-preset-{react,es2015,stage-0} style-loader css-loader
@AlexSkrypnyk
AlexSkrypnyk / mymodule.css
Last active April 17, 2024 08:37
Drupal 'add more' and 'remove single' AJAX buttons on multi value custom field using FormAPI
input.form-submit.button-small {
padding: 4px 8px;
font-weight: bold;
}
.container-inline input.form-submit.button-small + .ajax-progress.ajax-progress-throbber .throbber {
position: absolute;
left: 19px;
margin-top: 7px;
}
@fastlinemedia
fastlinemedia / functions.php
Last active August 11, 2020 10:44
Import WordPress Customizer settings when a theme is activated.
/**
* This function assumes you have a Customizer export file in your theme directory
* at 'data/customizer.dat'. That file must be created using the Customizer Export/Import
* plugin found here... https://wordpress.org/plugins/customizer-export-import/
*/
function import_customizer_settings()
{
// Check to see if the settings have already been imported.
$template = get_template();
$imported = get_option( $template . '_customizer_import', false );
@crittermike
crittermike / gist:618e57a41286e555dea8
Last active November 24, 2020 21:30
A list of Whens, Thens, and Givens for Drupal Behat testing
Given /^(?:|I )am on "(?P<page>[^"]+)"$/
Given /^(?:|I )am on (?:|the )homepage$/
Given :type content:
Given :vocabulary terms:
Given I am an anonymous user
Given I am at :path
Given I am logged in as :name
Given I am logged in as a user with the :permissions permission(s)
Given I am logged in as a user with the :role role(s)
Given I am logged in as a user with the :role role(s) and I have the following fields:
@anton-liubushkin
anton-liubushkin / makeSelection.jsx
Created June 29, 2015 15:05
Makes a rectangular selection — Photoshop script
// x, y, width, height
// x & y position from top left corner of document
// width & height of selection
//
// makeSelection(10,50,200,100);
function makeSelection(x,y,sw,sh){
app.activeDocument.selection.select([ [x,y], [x,y+sh], [x+sw,y+sh], [x+sw,y] ]);
}
@urraka
urraka / -usage-.php
Last active July 5, 2021 13:40
Twig extension for correct indentation of the output.
<?php
require_once 'vendor/autoload.php'; // or however you load Twig
require_once 'Lexer.php';
require_once 'Indent.php';
$twig = new Twig_Environment(new Twig_Loader_Filesystem('templates'));
$twig->addExtension(new Indent_Twig_Extension());
$twig->setLexer(new Indent_Twig_Lexer($twig));
@kujohn
kujohn / portforwarding.md
Last active April 27, 2024 20:16
Port forwarding in Mavericks

Port Forwarding in Mavericks


Since Mavericks stopped using the deprecated ipfw (as of Mountain Lion), we'll be using pf to allow port forwarding.

####1. anchor file Create an anchor file under /etc/pf.anchors/<anchor file> with your redirection rule like: