Skip to content

Instantly share code, notes, and snippets.

Avatar

Oliver Davies opdavies

View GitHub Profile
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 {
@opdavies
opdavies / example.local.settings.php
Last active Jan 24, 2017
A base settings.php for Drupal 7.
View example.local.settings.php
<?php
$databases['default']['default'] = [
'driver' => $_ENV['DB_CONNECTION'],
'host' => $_ENV['DB_HOST'],
'port' => $_ENV['DB_PORT'],
'database' => $_ENV['DB_NAME'],
'username' => $_ENV['DB_USER'],
'password' => $_ENV['DB_PASS'],
];
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'
@opdavies
opdavies / with-options.sh
Last active May 14, 2016
Use the Drupal VM Generator
View with-options.sh
drupalvm config:generate \
--hostname=example.com \
--machine-name=example \
--ip-address=192.168.88.88 \
--cpus=1 \
--memory=512 \
--webserver=nginx \
--path=../site \
--destination=/var/www/site \
--docroot=/var/www/site/drupal \
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
View Preferences.sublime-settings
{
"color_scheme": "Packages/Color Scheme - Default/Monokai.tmTheme",
"default_line_ending": "unix",
"ensure_newline_at_eof_on_save": true,
"fallback_encoding": "UTF-8",
"folder_exclude_patterns":
[
".idea",
".git",
".github",