View Drupal 8 Send Google Analytics Event from PHP Back-end
/** | |
* Send Google analytics tracking event. | |
* | |
* @param mixed $action | |
* Event action. | |
*/ | |
public function sendGoogleTrackingEvent($action) { | |
if (!$this->isProduction()) return; | |
$googleAnalyticsUA = 'UA-XXXXXXXX-XX'; |
View Drupal 8 Create Block If Not Exists Function DB Update Script
<?php | |
/** | |
* @file | |
* DB post-updates for blocks. | |
*/ | |
use Drupal\block_content\Entity\BlockContent; | |
/** |
View Drupal 8 Custom Block Access Plugin
<?php | |
namespace Drupal\slq_blocks\Plugin\Condition; | |
use Drupal\Core\Condition\ConditionPluginBase; | |
use Drupal\Core\Form\FormStateInterface; | |
/** | |
* Provides a 'Site Theme' condition. | |
* |
View generate xml sitemap using bash script and jq to fetch remote json
#!/bin/bash | |
# Bash script to generate a sitemap.xml from external json data | |
# Author: Sam Deering | |
# POSIX variable reset in case getopts has been used previously | |
OPTIND=1 | |
# Initialize our own variables: | |
URL='http://localhost:4200/items.json' |
View Python command line to output a json file
curl http://localhost:4200/assets/settings/collections.json | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["data"]' |
View console-sass-version.json
{ | |
"minimum_web_client_version": "master-1094" | |
} |
View gist:4356baed3692d26ab778
/** | |
* CSRF Token Security. | |
*/ | |
(function() { | |
angular.module("app").config(['$httpProvider', function ($httpProvider) { | |
//check for token in meta tag | |
var csrf_token = $('meta[name=csrf-token]').attr('content'); |
View .htaccess
<IfModule mod_rewrite.c> | |
<IfModule mod_negotiation.c> | |
Options -MultiViews | |
</IfModule> | |
RewriteEngine On | |
# Redirect root requests | |
RewriteCond %{REQUEST_URI} ^/$ | |
RewriteRule !^/ /back-end/public%{REQUEST_URI} [L] |
View gist:11131879
function _functionName(url) { | |
return Q.fcall(function () { | |
var deferred = Q.defer(); | |
var options = { | |
url: url, | |
headers: { | |
'User-Agent': 'my-app' | |
}, |
View gist:8437725
#------------------------------------------------------------- | |
# Git Alias Commands | |
#------------------------------------------------------------- | |
alias g="git status" | |
alias ga="git add" | |
alias gaa="git add ." | |
alias gau="git add -u" | |
alias gc="git commit -m" | |
alias gca="git commit -am" | |
alias gb="git branch" |
NewerOlder