Skip to content

Instantly share code, notes, and snippets.

View csymlstd's full-sized avatar

Casey Milstead csymlstd

View GitHub Profile
@csymlstd
csymlstd / SubRequestController.php
Last active October 12, 2019 02:58 — forked from Daveiano/SubRequestController.php
Drupal 8: how to create a sub-request
<?php
namespace Drupal\content_helper\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* Class SubRequest.
*
@csymlstd
csymlstd / get_node_by_path.php
Created January 15, 2019 14:46 — forked from crittermike/get_node_by_path.php
Drupal 8 Get node ID by path alias
<?php
$path = \Drupal::service('path.alias_manager')->getPathByAlias('/this-is-the-alias');
if(preg_match('/node\/(\d+)/', $path, $matches)) {
$node = \Drupal\node\Entity\Node::load($matches[1]);
}
@csymlstd
csymlstd / remove-utf8-bom.js
Created September 26, 2018 19:35 — forked from antic183/remove-utf8-bom.js
remove utf-8 bom with javascript
// remove utf-8 BOM from ressource "res"
// res.charCodeAt(0) === 0xFEFF | res.charCodeAt(0) === 65279
if (res.charCodeAt(0) === 0xFEFF) {
res = res.substr(1);
}
@csymlstd
csymlstd / fix-wordpress-permissions.sh
Created May 22, 2018 19:42 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@csymlstd
csymlstd / axios.refresh_token.js
Last active July 16, 2018 20:37 — forked from culttm/axios.refresh_token.js
axios interceptors for refresh token
axios.interceptors.response.use(function (response) {
return response;
}, function (error) {
const originalRequest = error.config;
if (error.response.status === 401 && !originalRequest._retry) {
originalRequest._retry = true;
@csymlstd
csymlstd / regex.md
Created December 5, 2017 23:18 — forked from etiennemarais/regex.md
Regular expression for handlebars variables, includes, if/else blocks and unescaped variables

Regex

{{[{]?(.*?)[}]?}}

Captures the value of the variable name in a handlebars template

{{> components/templates/email/includes/email-tr-spacer }}
{{# deliveryAddress }}
@csymlstd
csymlstd / states-select.html
Created August 4, 2016 19:26 — forked from trent-boyd/states-select.html
HTML: US States in Select Element
<!-- Full State Name -->
<select name="State">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>