Skip to content

Instantly share code, notes, and snippets.

@pcambra
pcambra / feeds_file_field_collection.php
Last active November 20, 2015 11:00
File field feeds - field collection https://www.drupal.org/node/1063434
/**
* Implements hook_feeds_processor_targets_alter().
*
* Overrides the file.inc mapping to correctly set the allowed extensions for
* files inside field collections.
*/
function {my_module}_feeds_processor_targets_alter(array &$targets, $entity_type, $bundle) {
if ($bundle == 'field_files_collection') {
foreach ($targets as $target_id => &$target) {
@pcambra
pcambra / hr_contacts.drush.inc
Created December 28, 2015 10:02
Get contacts present on Hrinfo but not on HID export files
<?php
/**
* @file
* hr_contacts module drush integration.
*/
/**
* Implements hook_drush_command().
*
function hr_decommissioner_drush_command() {
$items['hr-decommissioner-list-hr-contacts-panes'] = array(
'description' => "List the contact panes from all spaces",
'drupal dependencies' => array(),
'aliases' => array(),
);
return $items;
}
#!/bin/sh
NOW=$(date +"%F")
LOGFILE="followers-$NOW.log"
t followers -s > /tmp/unfollows.log
cat /tmp/unfollows.log | wc -l > $LOGFILE
cat /tmp/unfollows.log >> $LOGFILE
# Print results for the last update.
echo "Diff since last time";
@pcambra
pcambra / gist:f39c61210b62a39677f7c03f507b1a58
Created June 7, 2016 12:47
Add a class to an anchor?
function my_module_entity_view(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
if ($entity instanceof FieldableEntityInterface && $entity->hasField('field_name')) {
foreach (Element::children($build['field_name']) as $item) {
$build['field_name'][$item]['#attributes'] = ['class' => 'my-class'];
}
}
}
@pcambra
pcambra / Drupal8UITestsPermissionError.md
Created August 29, 2016 01:56
Drupal 8: Workaround for permission errors when running tests from the UI
alias gimmepass="openssl rand -base64 12 |md5 |head -c12;echo"
# While the issues with php7-memcached are solved...
RUN echo "http://dl-4.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories && \
echo "http://dl-4.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories && \
apk update && \
apk --update add libmemcached-dev \
autoconf \
build-base \
libtool \
php7-pear \
php7-dev \
// application.hbs
<div class="container">
{{partial 'navbar'}}
{{leaflet-map}}
{{outlet}}
</div>
// leaflet-map.hbs
@pcambra
pcambra / wildcard.conf
Last active November 18, 2016 00:59
Generate self signed cert
# —------------ 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 ]