Skip to content

Instantly share code, notes, and snippets.

View delta-9's full-sized avatar
🎯
Focusing

delta-9

🎯
Focusing
View GitHub Profile
@delta-9
delta-9 / replace-uri-encoded-entities-with-mysql-no-function.sql
Created October 27, 2020 03:13
REPLACE URI ENCODED ENTITIES WITH MYSQL - NO FUNCTION
SELECT REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(`field`, '%20',' '), '%22','"'), '%23','#'), '%24','$'), '%26','&'), '%27','\''), '%28','('), '%29',')'),'%2A','*'), '%2B','+'),'%2C',','),'%2D','-'),'%2E','.'),'%2F','/'),'%3A',':'),'%3B',';'),'%3C','
### Keybase proof
I hereby claim:
* I am delta-9 on github.
* I am neuviemedelta (https://keybase.io/neuviemedelta) on keybase.
* I have a public key ASBniD9q23aGgS_g-YZ7soVRTSRplD8GEyMqJFdjlVeK6wo
To claim this, I am signing this object:
<?php
/**
* Implements hook_tokens().
*/
function cake_tokens($type, $tokens, array $data = array(), array $options = array()) {
$sanitize = !empty($options ['sanitize']);
$replacements = array();
if ($type == 'cake' && !empty($data['cake'])) {
<?php
/**
* Implements hook_token_info_alter().
*/
function cake_token_info_alter(&$data) {
// Chained tokens for cake.
$data ['tokens']['cake']['author'] = array(
'name' => t('The cake author'),
'description' => t('User author of the cake'),
'type' => 'user',
<?php
/**
* @file
* Contains views_head_metadata.module.
*/
/**
* Implements hook_views_pre_render().
*/
function views_head_metadata_views_pre_render(\Drupal\views\ViewExecutable $view) {
<?php
/**
* @file
* Contains \Drupal\views_head_metadata\Plugin\views\display_extender\HeadMetadata.
*/
namespace Drupal\views_head_metadata\Plugin\views\display_extender;
use Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase;
<?php
/**
* Implements hook_install().
*/
function views_head_metadata_install() {
// Enable head_metadata plugin.
$config = \Drupal::service('config.factory')->getEditable('views.settings');
$display_extenders = $config->get('display_extenders') ?: array();
$display_extenders[] = 'head_metadata';
<?php
/**
* @file
* Provide views data for our custom module_name.
*/
/**
* Implements hook_views_data().
*/
function module_name_views_data() {
<?php
/**
* @file
* Contains \Drupal\module_name\Plugin\views\area\MyCustomSiteArea.
*/
namespace Drupal\module_name\Plugin\views\area;
use Drupal\Core\Form\FormStateInterface;
<?php
// Remember original language before this operation.
$original_language = \Drupal::configFactory()->getLanguage();
$language = language_load($account->getPreferredLangcode());
// Set the languag without saving, this is actually only for the current script execution:
\Drupal::configFactory()->setLanguage($language);
// Get the user.mail config object normally, but for the language we just set :)
$mail_config = \Drupal::config('user.mail');