Skip to content

Instantly share code, notes, and snippets.

View ummdorian's full-sized avatar

Dorian Damon ummdorian

View GitHub Profile
@ummdorian
ummdorian / Fix for Drupal 8 decimal field validation.php
Last active March 7, 2017 18:26
Fix for Drupal 8 decimal field validation fix re: "invalid number error" addressed here: https://www.drupal.org/node/2230909
<?php
function hook_form_BASE_FORM_ID_alter()(array &$form, FormStateInterface $form_state){
$form['#validate'][] = 'module_remove_decimal_errors';
}
function module_remove_decimal_errors(array &$form, FormStateInterface $form_state) {
$errorsToRemove = array('field_your_field][0][value','field_your_other_field][0][value');
$errorsToKeep = array();
$currentErrors = $form_state->getErrors();
@ummdorian
ummdorian / Lemme log in tho
Last active July 5, 2018 22:50
Windows powershell change drupal 8 user password
// update password
drush user-password username --password=password
// generate a hash to manually add to database
php core/scripts/password-hash.sh password
// url to reset
/user/password
// drush change password
@ummdorian
ummdorian / Terminus site create commands for windows
Created September 20, 2017 14:16
Terminus site create commands for windows
(powershell)
terminus site:create "--org"'"orgName"' "newSiteMachineName" "newSiteHumanName" "upstreamHash"
(windows cmd)
terminus site:create --org "orgName" "newSiteMachineName" "newSiteHumanName" "upstreamHash"
@ummdorian
ummdorian / gist:9e0b978efbf9191d43b4a01e2b5f7abd
Last active October 19, 2017 18:06
Responsive Background Image Swapping
<div
class="featured-media featured-media--full-height featured-media--align-center clearfix background-image-swap"
style="background-image:url('/sites/default/files/styles/600x400/public/2017-10/maxresdefault.jpg?itok=E5qxr2Dx');"
data-src-set="
/sites/default/files/styles/2400x1600/public/2017-10/maxresdefault.jpg?itok=F7dLgnBM|all and (min-width: 1800px)|
/sites/default/files/styles/1800x1200/public/2017-10/maxresdefault.jpg?itok=iiH_TyjT|all and (min-width: 1201px) and (max-width: 1799px)|
/sites/default/files/styles/1200x800/public/2017-10/maxresdefault.jpg?itok=a5RsL9YX|all and (min-width: 961px) and (max-width: 1200px)|
/sites/default/files/styles/900x600/public/2017-10/maxresdefault.jpg?itok=tlhEVdgF|all and (min-width: 601px) and (max-width: 960px)|
/sites/default/files/styles/600x400/public/2017-10/maxresdefault.jpg?itok=E5qxr2Dx||
"
@ummdorian
ummdorian / pantheon rsync files
Last active February 13, 2018 14:38
send files to pantheon via rsync
rsync -razv -e 'ssh -p 2222' --ignore-existing files live.*site_id*@appserver.live.*site_id*.drush.in:files/
@ummdorian
ummdorian / module_name.php
Created February 27, 2018 16:39
Views Nested Condition Group
<?php
function adw_calendar_query_views_events_list_alter(Drupal\Core\Database\Query\AlterableInterface $query){
if(
$query->getMetaData('view')->getDisplay()->display['id'] == 'page_1'
|| $query->getMetaData('view')->getDisplay()->display['id'] == 'page_2'
){
@ummdorian
ummdorian / index.php
Created March 28, 2018 14:57
Drupal 8 Query Alter Group By (views)
<?php
function module_query_views_events_alter(Drupal\Core\Database\Query\AlterableInterface $query){
// If this the right query
if(
$query->getMetaData('view') != ''
&& $query->getMetaData('view')->getDisplay()->display['id'] == 'block_3'
){
If composer memory limit:
export COMPOSER_MEMORY_LIMIT=-1
If php memory limit:
php -d memory_limit=-1 $(which composer) {{ command goes here }}
nvm install
nvm use
npm install
npm run dev {url} (optional watches changes)
npm run build (full build pre-commit)
query {
nodeQuery(
filter: {
conditions: [
{
operator: EQUAL,
field: "type",
value: ["page"]
},
{