Skip to content

Instantly share code, notes, and snippets.

@marcan
marcan / linux.sh
Last active December 1, 2023 15:18
Linux kernel initialization, translated to bash
#!/boot/bzImage
# Linux kernel userspace initialization code, translated to bash
# (Minus floppy disk handling, because seriously, it's 2017.)
# Not 100% accurate, but gives you a good idea of how kernel init works
# GPLv2, Copyright 2017 Hector Martin <marcan@marcan.st>
# Based on Linux 4.10-rc2.
# Note: pretend chroot is a builtin and affects the current process
# Note: kernel actually uses major/minor device numbers instead of device name
@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 %}
@GreenSkunk
GreenSkunk / fix-drupal8-permissions.sh
Last active December 14, 2022 12:43
Drupal - Bash shell script to fix Drupal 8 permissions where the PHP Handler is FastCGI.
#!/bin/bash
path=${1%/}
user=${2}
group=${2}
help="\nHelp: This script is used to fix permissions of a Drupal 8 installation in which the PHP Handler is FastCGI\nYou need to provide the following arguments:\n\t 1) Path to your drupal installation\n\t 2) Username of the user that you want to give files/directories ownership\n\nNote: This script assumes that the group is the same as the username if your PHP is compiled to run as FastCGI. If this is different you need to modify it manually by editing this script or checking out forks on GitHub.\nUsage: bash ${0##*/} drupal_path user_name\n"
echo "Refer to https://www.Drupal.org/node/244924"
@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
]);
@mortenson
mortenson / composer.json
Last active August 20, 2023 10:39
Example composer.json file for File Browser
{
"name": "mortenson/example",
"minimum-stability": "dev",
"authors": [
{
"name": "Samuel Mortenson",
"email": "samuel.mortenson@acquia.com"
}
],
"repositories": [
@rwitchell
rwitchell / FacebookConnectController.php
Created May 23, 2016 14:28
oauth2-client-bundle install example
<?php
namespace Comp\AppBundle\Controller;
use Comp\AppBundle\Entity\User;
use Comp\AppBundle\Form\FacebookRegistrationType;
use League\OAuth2\Client\Provider\FacebookUser;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
@chris-hall-hu
chris-hall-hu / sql.sql
Created January 2, 2016 08:45
Example sql migration for late Beta Drupal 8 to 8.01
-- Commands run whilst in the new database, the original datbase is call 'old'
-- NOTE this is an example original table etc. will need to be investigate with describe etc.
INSERT INTO taxonomy_index SELECT * FROM old.taxonomy_index;
INSERT INTO taxonomy_term_data SELECT * FROM old.taxonomy_term_data;
INSERT INTO taxonomy_term_field_data SELECT * FROM old.taxonomy_term_field_data;
INSERT INTO taxonomy_term_hierarchy SELECT * FROM old.taxonomy_term_hierarchy;
INSERT INTO node SELECT nid, vid, type, uuid, 'en' FROM old.node;
INSERT INTO node__body SELECT * FROM old.node__body;
@keopx
keopx / Vagrant_nfs_debian8.sh
Last active December 10, 2015 16:00
Vagrant NFS in Debian 8
sudo su
modprobe nfsd
# https://bugzilla.mozilla.org/show_bug.cgi?id=1056049#c8
systemctl stop nfs-kernel-server.service
systemctl disable nfs-kernel-server.service
systemctl enable nfs-kernel-server.service
systemctl start nfs-kernel-server.service
@bojanz
bojanz / extension-patterns.md
Last active January 14, 2023 16:59
Extension patterns: events, tagged services, plugins

This documentation is destined for drupal.org. Created first as a gist to make initial comments easier. Rewrites and clarifications welcome. Code samples are simplified for clarity. Perhaps a bit too much?

When talking about extensibility, there are several distinct use cases:

  1. Reacting to an action that has already happened.

The reaction can be anything; outputting a message, sending an email, modifying a related object, etc. Examples:

  • "A node has been saved"
  • "A product has been added to the cart".
@facine
facine / __INDEX.txt
Last active August 6, 2023 15:33
Drupal 8 - Examples
# Taxonomy terms:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_taxonomy_term-php
# Menu links:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_menu_link-php
# File items:
- https://gist.github.com/facine/35bb291811c146b6fc9e#file-create_file-php
# Nodes: