Skip to content

Instantly share code, notes, and snippets.

@andyg5000
andyg5000 / DimensionalWeightSubscriber.php
Last active Mar 19, 2019
Commerce USPS Event Subcriber Example. Dimensional weights are automatically applied by the USPS Webtools API, but this file provides a solid example of how to manipluate the package array before a rate request is made. Make sure to register your event subscribers
View DimensionalWeightSubscriber.php
<?php
/**
* Be sure to register this in your MYMODULE.services.yml file.
*
* MYMODULE_dimensional_weigth.rate_subscriber:
* class: Drupal\MYMODULE\EventSubscriber\DimensionalWeightSubscriber
* tags:
* - { name: event_subscriber }
*/
View Member Bio Migration
<?php
$pids = [3,15,19,23,25,28,30,31,32,34,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,91,93,95,97,99,101];
foreach ($pids as $pid) {
$profile = \Drupal\profile\Entity\Profile::load($pid);
$uid = $profile->get('uid')->getValue()[0]['target_id'];
/** @var \Drupal\profile\Entity\ProfileInterface $main_profile */
$main_profile = \Drupal::entityTypeManager()->getStorage('profile')->loadByProperties(['uid' => $uid, 'type' => 'main_profile']);
View d8-SA-CORE-2018-004
diff --git a/core/lib/Drupal/Core/Security/RequestSanitizer.php b/core/lib/Drupal/Core/Security/RequestSanitizer.php
index 8ba17b9..44815f6 100644
--- a/core/lib/Drupal/Core/Security/RequestSanitizer.php
+++ b/core/lib/Drupal/Core/Security/RequestSanitizer.php
@@ -2,6 +2,8 @@
namespace Drupal\Core\Security;
+use Drupal\Component\Utility\UrlHelper;
+use Symfony\Component\HttpFoundation\ParameterBag;
View d7-SA-CORE-2018-004
diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc
index 06acf93..d5963a0 100644
--- a/includes/bootstrap.inc
+++ b/includes/bootstrap.inc
@@ -2778,6 +2778,11 @@ function _drupal_bootstrap_variables() {
unset($_GET['destination']);
unset($_REQUEST['destination']);
}
+ // Use the DrupalRequestSanitizer to ensure that the destination's query
+ // parameters are not dangerous.
View gist:36876acda13fea05cd23f1f4cc3d84a1
Verifying my Blockstack ID is secured with the address 1DCNP23vvZEQf6F9PBG6A3ji9rDua8NCcV https://explorer.blockstack.org/address/1DCNP23vvZEQf6F9PBG6A3ji9rDua8NCcV
View Blue Oak Site Audit Header
diff --git a/html/header.html b/html/header.html
index 0718ed5..007f6a5 100644
--- a/html/header.html
+++ b/html/header.html
@@ -1,23 +1,4305 @@
<!DOCTYPE html>
<html class="no-js">
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
View keybase.md

Keybase proof

I hereby claim:

  • I am andyg5000 on github.
  • I am andyg5000 (https://keybase.io/andyg5000) on keybase.
  • I have a public key ASDosjlDUg9mO5Gzptddk9O9xJd1vm2VibrdjbUuUncWgQo

To claim this, I am signing this object:

View drushrc.php
<?php
/**
* @file
* Provides drush overrides for Blue Oak Interactive.
*/
$skip_tables = array(
'__ACQUIA_MONITORING',
);
@andyg5000
andyg5000 / comerce-discount-percentage-description-label.php
Created Jan 27, 2016
Update commerce discount percentage field description
View comerce-discount-percentage-description-label.php
<?php
$instance = field_info_instance('commerce_discount_offer', 'commerce_percentage', 'percentage');
$instance['description'] = 'Enter the percentage discount as a whole number';
field_update_instance($instance);
@andyg5000
andyg5000 / usr.sbin.sshd
Created Jan 5, 2016
SSHD AppArmor profile
View usr.sbin.sshd
# ------------------------------------------------------------------
#
# Copyright (C) 2002-2005 Novell/SUSE
# Copyright (C) 2012 Canonical Ltd.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 of the GNU General Public
# License published by the Free Software Foundation.
#
# ------------------------------------------------------------------
You can’t perform that action at this time.