Skip to content

Instantly share code, notes, and snippets.

View antmbraun's full-sized avatar

Anthony Braun antmbraun

View GitHub Profile
@antmbraun
antmbraun / gist:0c8ec79ad8518389cf5f58691933df6a
Created November 11, 2025 15:29
AI code review instructions
You are a senior code-review assistant. Your job is to compare the current branch against origin/master (may be github/master) and review the changes. Run git fetch origin to get the latest code before you start.
1. **High-Level Summary**
In 2–3 sentences, describe:
– **Product impact**: What does this change deliver for users or customers?
– **Engineering approach**: Key patterns, frameworks, or best practices in use.
2. **Evaluation Criteria**
For each new file, changed file and each diffed hunk, evaluate the changes in the context of the existing codebase. Understand how the modified code interacts with surrounding logic and related files—such as how input variables are derived, how return values are consumed, and whether the change introduces side effects or breaks assumptions elsewhere. Assess each change against the following principles:
/**
* @file
* Fires Optimizely custom events when certain conditions are met.
* Knows which events to fire based on values in drupalSettings.optimizely_custom_events array which is populated in mb.module.
*
*/
(function () {
Drupal.behaviors.optimizely_custom_events = {
attach: function () {
// Load plugins
var
autoprefixer = require("autoprefixer"), // CSS vendor prefixes
cssnano = require("cssnano"), // Minify CSS
postcss = require("gulp-postcss"), // PostCSS
concat = require("gulp-concat"), // Combine files
gulp = require("gulp"),
gulpSass = require('gulp-sass')(require('sass')), // Compile Sass
inlineImage = require("gulp-inline-image"), // Allow for base64 icons via inline-image()
rename = require("gulp-rename"), // Rename files
@antmbraun
antmbraun / gist:3ae4f22c6ddd1de2b959284c0ec74e3f
Last active September 12, 2024 10:48
Get all instances of paragraphs in Drupal 8
$entity_storage = \Drupal::entityTypeManager()->getStorage('paragraph');
$query = \Drupal::entityQuery('paragraph')
->condition('type', "paragraph_type_machine_name")
->accessCheck(false);
$results = $query->execute();
$hosted_paragraphs_found = [];
@antmbraun
antmbraun / gist:9dfd501ccd020a5ed729b229de774449
Last active April 2, 2020 23:58
avalanche forecast getter
/**
* Avalanche forecast Shortcode Callback
*
* @return string HTML containing the avalanche forecast image or an error message.
*/
function shortcode_avalanche_forecast() {
// First check the cache.
if ( $cached_value = get_transient("avalanche_forecast") ) {
return $cached_value;
}