Skip to content

Instantly share code, notes, and snippets.

View jamiehollern's full-sized avatar

Jamie Hollern jamiehollern

  • Tag1 Consulting
  • Dùn Phris/Zürich
  • 13:56 (UTC +01:00)
View GitHub Profile
@WengerK
WengerK / README.md
Last active August 20, 2019 09:08
Drupal 8 - Debugging Ajax Commands & Dialogs

Drupal 8 - Debugging Ajax Commands & Dialogs

'Cause it's nearly impossible to var_dump or dump into an Ajax Dialog or an Ajax Command, the most easier way is to write into the Apache logs.

To do this, just add the following snippet in your code:

error_log(var_export($var), TRUE);
@colorfield
colorfield / standup.sh
Created October 8, 2020 19:54
Standup winner
#!/bin/bash
team=("Stephanie" "Dan" "Tish" "Alex" "Blazej" "John" "Mattia" "Christophe" "Maria" "Matt" "Gesche" "Lisa" "Dominic" "Nick" "Jamie" "Thomas" "Vasi" "Inky" "Chris" "Philipp" "Marco" "Beat")
suspense=("Picking" "🤔Changing" "😛Cheating")
RANDOM=$$$(date +%s)
# Get the winner
winner=${team[$RANDOM % ${#team[@]} ]}
# Produce some suspense
@johannez
johannez / allow_email_login.php
Last active February 24, 2021 01:07
Drupal 8 - Allow login by email
<?php
/**
* Implements hook_form_alter().
*/
function MODULE_form_user_login_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
// Allow login with email.
array_unshift($form['#validate'], 'MODULE_user_login_form_validate');
// Change the field label.
$form['name']['#title'] = new \Drupal\Core\StringTranslation\TranslatableMarkup('Email or Username');
@bcantoni
bcantoni / json-int.php
Created March 22, 2012 19:42
Demo of PHP workaround for large integers in JSON data responses
<?php
/* Demonstration of problem with large integers in JSON, and
a couple options for dealing with them as strings instead.
ref:
* http://php.net/manual/en/function.json-decode.php
* http://stackoverflow.com/questions/2907806/handling-big-user-ids-returned-by-fql-in-php
*/
$json = <<<EOT
@shovon
shovon / increase_swap.sh
Created April 10, 2015 15:18
Increasing swap size. Only tested on the ubuntu/trusty64 Vagrant box. CREDIT GOES TO ---> http://jeqo.github.io/blog/devops/vagrant-quickstart/
#!/bin/sh
# size of swapfile in megabytes
swapsize=8000
# does the swap file already exist?
grep -q "swapfile" /etc/fstab
# if not then create it
if [ $? -ne 0 ]; then
@mizner
mizner / scotchboxphp7.txt
Last active August 23, 2021 10:45
Scotchbox PHP 7
List of PHP 7 Packages: https://launchpad.net/ubuntu/+source/php7.0
Disclaimer: I get unreliable results when I don't run these commands seperately and in order.
vagrant ssh
sudo apt-get update
sudo add-apt-repository ppa:ondrej/php
sudo apt-get install php7.0
sudo apt-get update
@acrosman
acrosman / SidebarCondition.php
Last active December 1, 2021 01:50
A Drupal 8 block condition to set visibility based on a node's field value.
<?php
namespace Drupal\my_block\Plugin\Condition;
use Drupal\Core\Condition\ConditionPluginBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@shammelburg
shammelburg / auth-middleware.js
Last active December 8, 2021 17:13
express-graphql-api
const jwt = require('jsonwebtoken');
const authMiddleware = (req, res, next) => {
const authHeader = req.get('Authorization')
if (!authHeader) {
req.error = "No authentication header found."
req.isAuth = false
return next()
}
@JeffTomlinson
JeffTomlinson / MyService.php
Last active December 22, 2021 07:49
Drupal 8 Logger Dependency Injection
<?php
namespace Drupal\my_module\Services;
use Drupal\Core\Logger\LoggerChannelFactory;
/**
* Class MyService.
*
* @package Drupal\my_module\Services
@WengerK
WengerK / README.md
Last active January 4, 2022 21:15
Programatically use Solr on Drupal 8

🔍 Solr (6.1.0+) search Engine & Tika (1.13+) Extractor

We are using solr for search index.

Solr need to be configured for drupal. Follow the INSTALL.txt found in the search_api_solr module.

As a pre-requisite for running your own Solr server, you'll need Java 6 or higher.

Installation