Skip to content

Instantly share code, notes, and snippets.

Avatar

Oliver Davies opdavies

View GitHub Profile
@opdavies
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
<?php
declare(strict_types=1);
namespace Drupal\custom\Entity;
use Drupal\node\Entity\Node as CoreNode;
use Drupal\paragraphs\ParagraphInterface;
use Illuminate\Support\Collection;
View rename-post-files.php
<?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 */
View TodoistFilters.md

Dashboard: overdue, today, #inbox, @waiting

Focus: overdue, (p1 & today)

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

Morning:

View drupal_path_test.php
<?php
/**
* Tests Simple Smartling's path functionality.
*/
class SimpleSmartlingPathTest extends DrupalWebTestCase {
/**
* Implements getInfo().
*/
View totals-with-collections.php
<?php
// https://twitter.com/codebyjeff/status/1057057070460022784
$array1 = ['col1' => 2, 'col2' => 5];
$array2 = ['col1' => 4, 'col2' => 1];
$array_total = collect($array1)->zip($array2)
->map->sum();
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
<?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
<?php
require __DIR__ . '/vendor/autoload.php';
use Opdavies\GmailFilterBuilder\Builder;
use Opdavies\GmailFilterBuilder\Filter;
$filters[] = Filter::create()
->has('from:foo@example.com')
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'
View generate-drupalvm-phar.sh
#!/bin/bash
rm -rf drupalvm.phar drupalvm.phar.version
box build
shasum drupalvm.phar | awk '{print $1}' > drupalvm.phar.version