Skip to content

Instantly share code, notes, and snippets.

View normanlolx's full-sized avatar
✍️
git reset --soft HEAD~1

Norman normanlolx

✍️
git reset --soft HEAD~1
View GitHub Profile
@normanlolx
normanlolx / drush.sh
Created May 19, 2021 13:15
Drush generate field formatter
drush generate plugin-field-formatter
@normanlolx
normanlolx / my-drupal-scaffold.json
Last active January 28, 2020 10:08
Drupal Composer prevent .htaccess or development.services.yml from being overwritten using drupal/core-composer-scaffold
"drupal-scaffold": {
"locations": {
"web-root": "web/"
},
"file-mapping": {
"[web-root]/.htaccess": false,
"[web-root]/sites/development.services.yml": false
}
},
@normanlolx
normanlolx / ddev.md
Last active November 3, 2021 12:26
@normanlolx
normanlolx / SiteLogoBlock.php
Created October 18, 2019 07:33
Drupal 8 file upload block
<?php
namespace Drupal\mymodule\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\file\Entity\File;
use Drupal\file\FileUsage\FileUsageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@normanlolx
normanlolx / gulpfile.js
Last active December 7, 2022 10:57
Gulp 4 Sass BrowserSync Kickstart Example
// Requires Gulp v4.
// $ npm uninstall --global gulp gulp-cli
// $ rm /usr/local/share/man/man1/gulp.1
// $ npm install --global gulp-cli
// $ npm install
const { src, dest, watch, series, parallel } = require('gulp');
const browsersync = require('browser-sync').create();
const sass = require('gulp-sass');
const autoprefixer = require('gulp-autoprefixer');
const sourcemaps = require('gulp-sourcemaps');
@normanlolx
normanlolx / d7-add-entity-view-mode.md
Created October 22, 2018 08:16 — forked from swichers/d7-add-entity-view-mode.md
Drupal 7 - Programmatically add view mode to entity

In a module file:

This will enable an additional view mode for use on the specified entity type(s). Many examples will show the custom settings here being set to TRUE. If TRUE is used then that view mode is added to all entities of the specified type regardless of if it should be on the bundle or not.

/**
 * Implements hook_entity_info_alter().
 */
function HOOK_entity_info_alter(&$entity_info) {
@normanlolx
normanlolx / DownloadSlidesFormatter.php
Last active August 2, 2018 15:42
Field formatter snippet for the fully working sample module on https://github.com/leymannx/mffe
<?php
namespace Drupal\mffe\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\media\Entity\Media;
use Drupal\file\Entity\File;
use Drupal\Core\Url;
@normanlolx
normanlolx / iterm2-oh-my-fish.md
Last active May 5, 2024 13:53
iTerm2 Solarized Dark theme + Fish shell + oh-my-fish /// macOS High Sierra
version: '2'
services:
web:
image: php:7.0-apache
volumes:
- /var/www/myapp
bg-sync: