Skip to content

Instantly share code, notes, and snippets.


Oliver Davies opdavies

View GitHub Profile
opdavies / Node.php
Last active May 11, 2020
Automatically updating the created date for talk nodes, to match the date of the latest event for that talk.
View Node.php
namespace Drupal\custom\Entity;
use Drupal\node\Entity\Node as CoreNode;
use Drupal\paragraphs\ParagraphInterface;
use Illuminate\Support\Collection;
View rename-post-files.php
use Symfony\Component\Finder\Finder;
require_once __DIR__.'/vendor/autoload.php';
$finder = new Finder();
$files = $finder->in(__DIR__.'/source/_posts')->files();
/** @var \Symfony\Component\Finder\SplFileInfo $file */

Dashboard: overdue, today, #inbox, @waiting

Focus: overdue, (p1 & today)

Morning Routines: (overdue|today) & ##Routines & p2


View drupal_path_test.php
* Tests Simple Smartling's path functionality.
class SimpleSmartlingPathTest extends DrupalWebTestCase {
* Implements getInfo().
View totals-with-collections.php
$array1 = ['col1' => 2, 'col2' => 5];
$array2 = ['col1' => 4, 'col2' => 1];
$array_total = collect($array1)->zip($array2)
View sass-map-each-loop.scss
$icons: (
camera: 'factsheet_bg.png',
ebook: 'library_bg.png',
newsletter: 'newsletter_bg.png',
pages: 'project_results_bg.png',
publications: 'publications_bg.png',
youtube: 'youtube_bg.png',
@each $class, $filename in $icons {
View use-posts-on-existing-posts.php
require 'vendor/autoload.php';
use Symfony\Component\Finder\Finder;
// Find all posts.
$files = Finder::create()->files()->in('../source/_posts')->name('*.md');
foreach ($files as $file) {
View filters.php
require __DIR__ . '/vendor/autoload.php';
use Opdavies\GmailFilterBuilder\Builder;
use Opdavies\GmailFilterBuilder\Filter;
$filters[] = Filter::create()
View Brewfile
tap 'caskroom/cask'
tap 'caskroom/fonts'
tap 'caskroom/versions'
tap 'homebrew/dupes'
tap 'homebrew/php'
tap 'homebrew/services'
brew 'cairo'
brew 'composer'
brew 'direnv'
rm -rf drupalvm.phar drupalvm.phar.version
box build
shasum drupalvm.phar | awk '{print $1}' > drupalvm.phar.version