Skip to content

Instantly share code, notes, and snippets.

@megclaypool
megclaypool / The fix.md
Last active February 12, 2025 08:51
["Unable to unlink, Permission denied" Error] Solution for: ``` $ git pull error: unable to unlink old 'sites/default/default.settings.php': Permission denied ```

In this case, the specific error was:

$ git pull
error: unable to unlink old 'sites/default/default.settings.php': Permission denied

I opened the sites directory and saw the following:

$ lll
  rwxr-xr-x  noxlady  staff  160 B    Tue Sep  4 13:34:39 2018  M?    all/
 r-xr-xr-x noxlady staff 192 B Tue Sep 4 13:40:49 2018 ✓  default/
@nelson-ph
nelson-ph / filefield_paths_media_thumbnail_error.patch
Created May 18, 2018 14:07
Drupal 8 - Prevent Call to undefined method Drupal\\Core\\Field\\BaseFieldDefinition::getThirdPartySettings
Index: ./filefield_paths.module
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- ./filefield_paths.module (date 1517934386000)
+++ ./filefield_paths.module (date 1517934386000)
@@ -344,13 +344,15 @@
if ($field instanceof FileFieldItemList) {
/** @var FieldConfig $definition */
@bdlangton
bdlangton / Blocks.md
Last active October 12, 2023 08:40
Drupal 8 programmatic solutions

Render custom blocks

$bid = 'myblock';
$block = \Drupal\block_content\Entity\BlockContent::load($bid);
$render = \Drupal::entityTypeManager()->getViewBuilder('block_content')->view($block);

Render plugin blocks

$block_manager = \Drupal::service('plugin.manager.block');
@brooke-heaton
brooke-heaton / Drupal8_views_query_alter.php
Created August 11, 2017 22:13
Alters a Drupal 8 view by adding a Left Join and Where condition
<?php
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\query\QueryPluginBase;
/**
* Implementation of hook_views_query_alter
* @param type $view
* @param type $query
name: Modal Form Example
type: module
description: 'Modal Form Example module'
package: Example
version: VERSION
core: 8.x
@illepic
illepic / file_rel_path_d8.php
Last active August 23, 2023 09:40
Get relative path for fid in Drupal 8
<?php
use Drupal\file\Entity\File;
// public://images/blah.jpg
$drupal_file_uri = File::load($fid)->getFileUri();
// /sites/default/files/images/blah.jpg
$image_path = file_url_transform_relative(file_create_url($drupal_file_uri));
@FlYos
FlYos / --Readme.md
Last active July 22, 2016 13:03
Load Magento CMS page in popin with Ajax request

Description

This module allows you to change the template pages cms backoffice defined by a particular template when we load the page through an ajax request

How to us

Create this directory structure in local pool : Webaki

  • etc -- config.xml
  • Model -- Observer.php
@FlYos
FlYos / 1-Readme.md
Last active April 14, 2023 21:22
Redirection user by roles after login/logout in symfony2

Description of this Gist

This is the how to for redirection implementation by roles after login or logout in Symfony2

Step

  1. Copy AfterLoginRedirection.php and AfterLogoutRedirection.php to your bundle under the "Redirection" directory
  2. Edit your services.yml file in your bundle and copy/paste the content of services.yml
  3. Edit your security.yml file...
  4. ... add success_handler: redirect.after.login in form_login: section
  5. ... add success_handler: redirect.after.logout in logout: section
@sheikhwaqas
sheikhwaqas / setup-mysql.sh
Last active September 6, 2023 15:59
Install MySQL Server on Ubuntu (Non-Interactive Installation)
# Download and Install the Latest Updates for the OS
apt-get update && apt-get upgrade -y
# Set the Server Timezone to CST
echo "America/Chicago" > /etc/timezone
dpkg-reconfigure -f noninteractive tzdata
# Enable Ubuntu Firewall and allow SSH & MySQL Ports
ufw enable
ufw allow 22
@hjortureh
hjortureh / gist:3948611
Created October 24, 2012 20:21
Responsive scaling background images
.element-with-background {
background-repeat: no-repeat;
background-position: center center;
-webkit-background-size:cover;
-moz-background-size:cover;
-o-background-size:cover;
background-size:cover;
}