Skip to content

Instantly share code, notes, and snippets.

Avatar
🐢
🐢

Pedro pcambra

🐢
🐢
View GitHub Profile
View FieldViewsLabel.php
<?php
namespace Drupal\log\Plugin\views\field;
use Drupal\Core\Entity\EntityMalformedException;
use Drupal\Core\Entity\Exception\UndefinedLinkTemplateException;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
@pcambra
pcambra / queue.php
Created Oct 18, 2018
Drupal 8: Process a queue programmatically
View queue.php
$queue_factory = \Drupal::service('queue');
$queue_manager = \Drupal::service('plugin.manager.queue_worker');
$queue_worker = $queue_manager->createInstance('queue_name');
$queue = $queue_factory->get('queue_name');
$item = $queue->claimItem();
$queue_worker->processItem($item->data);
@pcambra
pcambra / gist:fefed7ebfa14c0a2602bc4cd7688928c
Created Oct 18, 2018
Reinstal module configuration for Drupal 8
View gist:fefed7ebfa14c0a2602bc4cd7688928c
drush php-eval "\Drupal::service('config.installer')->installDefaultConfig('module', 'module_name');"
View Restart dnsmasq
sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
dscacheutil -flushcache
brew services restart dnsmasq
@pcambra
pcambra / custom_pane_panelizer.php
Created May 10, 2018
How to add a pane to a node with panelizer programmatically
View custom_pane_panelizer.php
<?php
// This code can be used in a hook_update_n to add a custom pane to an existing display in panelizer.
// Example variables used in the code below.
$nid = 1;
$pane_machine_name = 'my_example_custom_pane';
$region = 'content';
$position = 0;
View gist:aad1f1af0a889d21cc3255d41dbde8bf
const { String: { underscore } } = Ember;
export default JSONAPISerializer.extend({
// Keep Drupal underscored keys.
keyForRelationship(key) {
return underscore(key);
},
keyForAttribute(key) {
return underscore(key);
},
View npm shrink
npm install
npm prune
npm dedupe
npm install
npm shrinkwrap --dev
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@pcambra
pcambra / wildcard.conf
Last active Nov 18, 2016
Generate self signed cert
View wildcard.conf
# —------------ BEGIN custom wildcard.conf —---
oid_section = new_oids
[ new_oids ]
[ req ]
default_days = 3650 # how long to certify for
distinguished_name = req_distinguished_name
encrypt_key = no
string_mask = nombstr
req_extensions = v3_req # Extensions to add to certificate request, needed for multiname
[ req_distinguished_name ]