Skip to content

Instantly share code, notes, and snippets.

View csymlstd's full-sized avatar

Casey Milstead csymlstd

View GitHub Profile
/// twitch-videoad.js
const origFetch = window.fetch;
window.fetch = (url, init, ...args) => {
if (typeof url === "string") {
if (url.includes("/access_token")) {
url = url.replace("player_type=site", "player_type=thunderdome");
} else if (
url.includes("/gql") &&
init &&
typeof init.body === "string" &&
@csymlstd
csymlstd / keybase.md
Created March 19, 2020 15:14
keybase

Keybase proof

I hereby claim:

  • I am csymlstd on github.
  • I am csymlstd (https://keybase.io/csymlstd) on keybase.
  • I have a public key ASCVLVT4G9s6_iv9P_-oYjKCvbRnKmpWEHscwQ-Z9V-usgo

To claim this, I am signing this object:

@csymlstd
csymlstd / print-friendly-links.md
Created January 20, 2020 23:35
Print Friendly Links
@csymlstd
csymlstd / functions.php
Created November 12, 2019 21:15
wp cache bust js and css
<?php
add_filter( 'style_loader_src', 'pb_remove_ver_css_js', PHP_INT_MAX - 1 );
add_filter( 'script_loader_src', 'pb_remove_ver_css_js', PHP_INT_MAX - 1 );
function pb_remove_ver_css_js( $src ) {
if ( ! $src ) return;
if ( strpos( $src, 'ver=' ) ) {
$src = remove_query_arg( 'ver', $src );
@csymlstd
csymlstd / functions.php
Created November 12, 2019 21:14
wp ajax route to increment post view count
<?php
function get_post_count($id = null) {
if($id == null) return;
$key = 'post_views_count';
$count = get_post_meta($id, $key, true);
if($count == '') {
$count = 0;
delete_post_meta($id, $key);
@csymlstd
csymlstd / gist:61cb25fc23b455d6c1f4422b7b1b2b90
Created November 12, 2019 17:49
galderma image generation service commands
sudo systemctl enable image_generation_daemon.timer
@csymlstd
csymlstd / commands.sh
Created November 6, 2019 20:56
Clam AV on Ubuntu for Drupal 8
## Drupal's ClamAV default settings should be adjusted to
## Daemon mode (over UNIX socket)
## /var/run/clamav/clamd.ctl
# stop the daemon
sudo systemctl stop clamav-freshclam
# update definitions
sudo freshclam
@csymlstd
csymlstd / mymodule.module.php
Last active October 25, 2019 16:44
Drupal 8: allow users to filter custom entities on the json api
<?php
// Related to SA-CONTRIB-2018-081
// https://www.drupal.org/node/3036792
function mymodule_jsonapi_asset_filter_access(\Drupal\Core\Entity\EntityTypeInterface $entity_type, \Drupal\Core\Session\AccountInterface $account) {
return ([
JSONAPI_FILTER_AMONG_ALL => AccessResult::allowedIfHasPermission($account, 'administer asset entities'),
JSONAPI_FILTER_AMONG_PUBLISHED => AccessResult::allowedIfHasPermission($account, 'view published asset entities'),
JSONAPI_FILTER_AMONG_OWN => AccessResult::allowedIfHasPermissions($account, ['view published asset entities', 'view published asset entities'], 'AND'),
]);
@csymlstd
csymlstd / sudoers
Created October 15, 2019 15:09
Allow passwordless sudo on a script so Buddy.works can run it
# End of /etc/sudoers
username ALL = NOPASSWD: /var/www/scripts/fix_permissions.sh
@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.
*