Skip to content

Instantly share code, notes, and snippets.

@fubhy
fubhy / .gitconfig
Last active September 20, 2016 02:51
My personal .gitconfig (mostly stolen from others) :-)
[user]
# Credentials.
name = Foo Bar
email = foo@bar.com
drupal = $(whoami)
[credential]
# Save passwords in ~/.git-credentials.
helper = store
@liberatr
liberatr / create_file.php
Last active September 20, 2016 05:48
Programmatically save a file to Drupal from your local file system.
/**
* Saves a file on your local file system you want to copy to Drupal default files directory.
* This assumes you have bootstrapped Drupal.
* Originally written to be invoked within a Behat context.
*/
use Drupal\file\Entity\File;
$file = File::create([
'uid' => 1
]);
@lewisnyman
lewisnyman / field.html.twig
Last active December 21, 2016 14:49
minimal field.html.twig — Drupal 8
{% for item in items %}
{{ item.content }}
{% endfor %}
@chx
chx / gist:3958575
Created October 26, 2012 12:46
Making a Debian squeeze server into running Drupal 8 tests
apt-get update
aptitude install -y apache2 libonig2 libqdbm14 libxml2 apache2-mpm-prefork ucf libicu44 mysql-server libjpeg62 libpng12-0 libt1-5 libxpm4 git-core autoconf automake libssl-dev libtool shtool make
service mysql stop
sed -i 's/\/var\/lib\/mysql/\/dev\/shm\/mysql/g' /etc/mysql/my.cnf
sed -i '/en_US/a skip_innodb' /etc/mysql/my.cnf
mysql_install_db
service mysql start
echo ServerName localhost > /etc/apache2/httpd.conf
cd /etc/apache2/mods-enabled
ln -s ../mods-available/rewrite.load
<?php
namespace Drupal\waiting_queue\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Command\Command;
use Drupal\Console\Core\Command\Shared\ContainerAwareCommandTrait;
use Drupal\Console\Core\Style\DrupalStyle;
use Drupal\Console\Annotations\DrupalCommand;
@tonnguyen
tonnguyen / cache.middleware.js
Created February 13, 2018 21:44
A cache middleware for redux
const cache = store => next => action => {
// handle FETCH action only
if (action.type !== 'FETCH') {
return next(action);
}
// check if cache is available
const data = window['__data'];
if (!data) {
// forward the call to live middleware
@cweagans
cweagans / Vagrantfile
Last active June 8, 2018 20:46
Vagrantfile
# Up to date version can always be found at https://gist.github.com/cweagans/4e879a72985905e145df
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.synced_folder ".", "/srv", type: "nfs"
config.vm.network "private_network", ip: "192.168.205.142"
config.vm.network "forwarded_port", guest: 80, host: 8085
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "1024"]
@jackbravo
jackbravo / MediaLibraryController.php
Created November 28, 2018 22:19
Example to launch media library with a custom input
<?php
namespace Drupal\layout_manager\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Url;
/**
* Controller to render basic html for client side application.
@timplunkett
timplunkett / setupd8
Last active January 7, 2019 21:02
Reinstall D8
#!/bin/bash
PROFILE="standard"
DB="d8"
UI=false
NO_DEV=false
OPTS=`getopt -o h --longoptions db:,profile:,ui,no-dev -- "$@"`
eval set -- "$OPTS"
while true; do
@jhedstrom
jhedstrom / FeatureContext.php
Last active April 5, 2019 10:25
Step-definition for complex node structure (field collection + entity reference).
<?php
/**
* @Given /^I am viewing a product with the following related products:$/
*/
public function assertRelatedProducts(TableNode $relatedProducts) {
// First, create a product.
$product = (object) array(
'title' => 'Parent Product',
'type' => 'product',
'uid' => 1,