Skip to content

Instantly share code, notes, and snippets.

View ygerasimov's full-sized avatar

Yuriy Gerasimov ygerasimov

View GitHub Profile
@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
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)
<?php
/**
* @file
* Contains \OpenEDUSubContext.
*/
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Drupal\DrupalExtension\Context\DrupalSubContextBase;
use Behat\Behat\Context\SnippetAcceptingContext;
# 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
/**
* Enable Google Analytics module.
*/
function openy_update_8011() {
// Enable module.
\Drupal::service('module_installer')->install(['google_analytics']);
}
@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
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.';
var page = require('webpage').create(),
address, output, size;
if (phantom.args.length < 4 || phantom.args.length > 5) {
console.log('Usage: viewport.js URL filename sizeX sizeY');
phantom.exit();
} else {
address = phantom.args[0];
output = phantom.args[1];
sizeX = phantom.args[2];
@ygerasimov
ygerasimov / gist:e59c470b57f903f14359
Created March 5, 2015 15:13
acquia ip_address()
// Code provided by Acquia.
// Non balanced servers (dev and stage) don't have this problem.
if (!empty($conf['reverse_proxy_addresses'])) {
$ips = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
$ips = array_map('trim', $ips);
// Add REMOTE_ADDR to the X-Forwarded-For list (the ip_address function will
// also do this) in case it's a 10. internal AWS address; if it is we should
// add it to the list of reverse proxy addresses so that ip_address will
// ignore it.
$ips[] = $_SERVER['REMOTE_ADDR'];
@ygerasimov
ygerasimov / gist:6fd45fab43671b8054d3
Created December 23, 2014 11:33
Goutte configuration custom cUrl options
default:
suites:
default:
contexts:
- Drupal\DrupalExtension\Context\MinkContext
- FeatureContext
extensions:
Behat\MinkExtension:
base_url: http://mywebsite.com
goutte: