Skip to content

Instantly share code, notes, and snippets.

View csymlstd's full-sized avatar

Casey Milstead csymlstd

View GitHub Profile
@csymlstd
csymlstd / ffmpeg.md
Last active October 1, 2019 21:46
Document Conversion

Generate Video Thumbnails

  1. Install Dependencies
sudo apt update
sudo apt install ffmpeg
ffpmeg -v
@csymlstd
csymlstd / wp-regenerate-slugs.php
Last active September 25, 2019 15:21
Wordpress Regenerate Slugs and Redirect
<?php
//required include files
require('wp-blog-header.php');
require_once("wp-config.php");
require_once("wp-includes/wp-db.php");
include_once WP_PLUGIN_DIR . '/redirection/models/group.php';
if(!isset($_GET['run'])) return;
@csymlstd
csymlstd / drupal-8-ui-dialog-trigger.js
Created May 29, 2019 14:42
Drupal 8 Trigger UI Dialog
let url = '/user'
Drupal.ajax({
url,
dialog: {
'width': 'auto',
'maxWidth': 500
},
dialogType: 'modal'
}).execute()
@csymlstd
csymlstd / d8-post-deploy.sh
Created March 28, 2019 17:15
Drupal 8 Post Deployment Script
echo 'Rebuilding Cache'
./vendor/drush/drush/drush cr
echo 'Updating DB'
./vendor/drush/drush/drush updb -y
echo 'Importing Config'
./vendor/drush/drush/drush cim -y
echo 'Updating Entities'
./vendor/drush/drush/drush entup -y
@csymlstd
csymlstd / settings.local.php
Created March 26, 2019 15:13
Drupal 8 Local Settings
<?php
// @codingStandardsIgnoreFile
/**
* @file
* Local development override configuration feature.
*
* To activate this feature, copy and rename it such that its path plus
* filename is 'sites/default/settings.local.php'. Then, go to the bottom of
@csymlstd
csymlstd / Form.php
Created February 17, 2019 03:42
Drupal 8: Attach an existing entity field to a custom form
<?php
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class CustomUserForm extends FormBase {
public function buildForm(array $form, FormStateInterface $form_state) {
$form['#parents'] = [];
$entity = \Drupal::service('entity_type.manager')->getStorage('user')->create();
@csymlstd
csymlstd / stripe_error_handler.php
Created January 28, 2019 17:56
Stripe PHP Error Handling
<?php
# https://stackoverflow.com/questions/17750143/catching-stripe-errors-with-try-catch-php-method
try {
// Use a Stripe PHP library method that may throw an exception....
\Stripe\Customer::create($args);
} catch (\Stripe\Error\Base $e) {
// Code to do something with the $e exception object when an error occurs
echo($e->getMessage());
} catch (Exception $e) {
// Catch any other non-Stripe exceptions
@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 / custom-error.js
Created November 16, 2018 15:37
Custom Error class
// https://levelup.gitconnected.com/the-definite-guide-to-handling-errors-gracefully-in-javascript-58424d9c60e6
class CustomError extends Error {
constructor(code = 'GENERIC', status = 500, ...params) {
super(...params)
if (Error.captureStackTrace) {
Error.captureStackTrace(this, CustomError)
}
@csymlstd
csymlstd / containers.sh
Created November 8, 2018 18:10
Docker Containers
# Redis
docker run --name some-redis -p6379:6379 -d redis redis-server --appendonly yes