Skip to content

Instantly share code, notes, and snippets.

View ygerasimov's full-sized avatar

Yuriy Gerasimov ygerasimov

View GitHub Profile
<?php
define('LOGFILE', '/tmp/callback.log');
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
if (file_exists(LOGFILE)) {
print file_get_contents(LOGFILE);
}
else {
print 'Log file does not exist.';
@ygerasimov
ygerasimov / backtrac-self-test.sh
Created June 22, 2017 08:49
Backtrac.io snippet to test single environment. Wait for snapshot to complete before deploy.
#!/bin/bash
# Written in bash
# echo $SHELL
# change these values
APIKEY='8AAABBBCCC5'
PROJECTID='111222'
nid=`curl -sS --header "x-api-key: $APIKEY" --request POST https://backtrac.io/api/project/$PROJECTID/snapshot | sed 's/.*\"nid\":\"\([^\"]*\).*/\1/'`
<?php
/**
* Enable Google Analytics module.
*/
function openy_update_8011() {
// Enable module.
\Drupal::service('module_installer')->install(['google_analytics']);
}
# Lamp + PHP CS + Drush
image: sharpe/drupal:latest
pipelines:
branches:
8.x-1.x:
- step:
script:
#start mysql and create drupal db
- service mysql start
<?php
/**
* @file
* Contains \OpenEDUSubContext.
*/
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Drupal\DrupalExtension\Context\DrupalSubContextBase;
use Behat\Behat\Context\SnippetAcceptingContext;
Command+E recent files
Ctrl+T refactor this: rename, variable, move method, interface
Command+N create constructor, getters, setters
Option+Enter initialize variable constructor
Shift+Shift search everywhere
Command+Up browse in current file’s folder
Command+Option+O search symbol
Command+, Settings
Control+G multiple cursors of same word
Control+V, Control+H windows splits (manually added)
@ygerasimov
ygerasimov / diffy-authentication.sh
Created August 1, 2018 03:15
Get started with Diffy API's
#!/bin/bash
TOKEN=`curl -sS -X POST -H "Content-Type: application/x-www-form-urlencoded" -d "_username=ENCODEDEMAIL%40gmail.com&_password=ENCODEDPASSWORD" https://diffy.website/api/login_check | grep -o "token\":.*\"}" | sed "s/token\":\"//g" | sed "s/\"}//g"`
if [ -z "$TOKEN" ]
then
echo "Problem authenticating."
exit 1
fi
@ygerasimov
ygerasimov / patches.json
Created June 13, 2019 23:36
Umami distro composer.json patches section.
"patches": {
"drupal/core": {
"Fix styling of Umami for layout builder": "https://www.drupal.org/files/issues/2019-04-24/ootb-layout-builder-buttons-checkbox-3044366-38.patch"
}
}
@ygerasimov
ygerasimov / .platform.app.yaml
Last active June 18, 2019 00:22
Umami Diffy Platform.sh triggering hooks.
hooks:
# The deploy hook runs after your application has been deployed and started.
deploy: |
cd web
drush si demo_umami -y --account-pass=nKraDzZq8ZUq747Bn9PaXAB83 --account-mail="[email protected]"
drush cron
drush status > sites/default/files/drush-status.txt
php ../scripts/diffy-visual-testing.php
@ygerasimov
ygerasimov / OrderAddressLabelsTest.php
Created December 3, 2019 16:32
Attempt to have a BrowserTest based on installing a profile from existing configuration
<?php
namespace Drupal\Tests\mymodule_core\Unit;
use CommerceGuys\Addressing\AddressFormat\AddressFormatRepository;
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Database\Database;
use Drupal\Core\DrupalKernel;
use Drupal\Core\Installer\Form\SelectProfileForm;
use Drupal\Core\Site\Settings;