Skip to content

Instantly share code, notes, and snippets.

Avatar

Sam Deering sdeering

View GitHub Profile
@sdeering
sdeering / gist:8437725
Created Jan 15, 2014
Some .bashrc git alias commands
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"
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;
/**
@sdeering
sdeering / Drupal 8 Custom Block Access Plugin
Created Aug 28, 2019
Adds a new tab in the block settings to control the block visibility based on a custom field
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.
*
@sdeering
sdeering / generate xml sitemap using bash script and jq to fetch remote json
Last active Aug 9, 2019
generate xml sitemap using bash script and jq to fetch remote json
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"
}
@sdeering
sdeering / gist:8035033
Created Dec 19, 2013
Use grunt connect to make the karma test coverage directory browseable.
View gist:8035033
coverage: {
options: {
// required for output on index.html base filepath
base: __dirname + 'test/coverage/',
// required to override base to make the directory browseable
directory: __dirname + 'test/coverage/',
port: '5555',
keepalive: true
}
}
@sdeering
sdeering / tmux.conf
Created Nov 28, 2013
My Tmux Config Linux
View tmux.conf
# remap prefix to Control + a
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# force a reload of the config file
unbind r
bind r source-file ~/.tmux.conf
# quick pane cycling
View gist:7459482
/*
http://www.jquery4u.com/snippets/url-parameters-jquery/
*/
$.urlParam = function(name){
var results = new RegExp('[\\?&amp;]' + name + '=([^&amp;#]*)').exec(window.location.href);
return results[1] || 0;
}
You can’t perform that action at this time.