Skip to content

Instantly share code, notes, and snippets.

View benjbmc's full-sized avatar

Benjamin R. benjbmc

View GitHub Profile
@chrisjhoughton
chrisjhoughton / wait-el.js
Last active April 17, 2025 08:14
Wait for an element to exist on the page with jQuery
var waitForEl = function(selector, callback) {
if (jQuery(selector).length) {
callback();
} else {
setTimeout(function() {
waitForEl(selector, callback);
}, 100);
}
};
# Views and Blocks
* Cache views
* Export views to code
* Revert views to code
# Performance
* Enable page cache
* Enable block cache
@johnpolacek
johnpolacek / .gitconfig
Last active October 10, 2025 00:40
My current .gitconfig aliases
[alias]
recent = "!git for-each-ref --sort=-committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)' | head -n 10"
co = checkout
cob = checkout -b
coo = !git fetch && git checkout
br = branch
brd = branch -d
brD = branch -D
merged = branch --merged
st = status
@drazisil
drazisil / pretty-json.php
Last active October 12, 2021 16:15
Pretty-print a JSON string in PHP.
<?php
/**
* Formats a JSON string for pretty printing
*
* @param string $json The JSON to make pretty
* @param bool $html Insert nonbreaking spaces and <br />s for tabs and linebreaks
* @return string The prettified output
* @author Jay Roberts
*/
@jmolivas
jmolivas / chain-mysql.sh
Last active January 22, 2018 21:37
How to download and install Drupal 8 using Drupal Console
drupal chain --file=~/.console/chain/quick-start-mysql.yml
@raphaellarrinaga
raphaellarrinaga / drupal_8_twig_cheatsheet.md
Last active February 23, 2025 02:49
[Drupal 8 Twig cheatsheet] #tags: drupal8, twig, cheatsheet

Drupal 8 Twig cheatsheet

Please note I created that sheet as a personal side note/draft and not everything is fully tested. There could be errors or better things to do. So if you spot something wrong or something that can be improved, feel free to comment below and I will do the changes.

Getting Drupal 8 field values in Twig

Image path: {{ file_url(content.field_name['#items'].entity.uri.value) }}

@crittermike
crittermike / router_rebuild.sh
Created September 16, 2016 15:15
Rebuild Drupal 8 routing table with Drush
drush ev '\Drupal::service("router.builder")->rebuild();'
@CoalaWeb
CoalaWeb / phpstorm-js-auto-minify.md
Last active February 14, 2023 09:32
Adding a watcher for on-the-fly compression of JS files in PHPStorm

Note: This tutorial has been written for Ubuntu but with some slightly changes it should be applicable to other operating systems.

Prerequisites

  • Operating System: Ubuntu (Debian)
  • IDE: PHPStorm
  • Node is installed

Steps

We won't need to leave the IDE so open up your project in PHPStorm

@mccabe615
mccabe615 / phpdangerousfuncs.md
Last active September 20, 2025 11:00
Dangerous PHP Functions

Command Execution

exec           - Returns last line of commands output
passthru       - Passes commands output directly to the browser
system         - Passes commands output directly to the browser and returns last line
shell_exec     - Returns commands output
\`\` (backticks) - Same as shell_exec()
popen          - Opens read or write pipe to process of a command
proc_open      - Similar to popen() but greater degree of control
pcntl_exec - Executes a program