Skip to content

Instantly share code, notes, and snippets.

View rbg246's full-sized avatar

Richard Gaunt rbg246

  • Melbourne, Australia
View GitHub Profile
@rbg246
rbg246 / TransformerAbstract.php
Created July 24, 2018 07:15
Abstract Transformer class for PHP
<?php
/**
* Class TransformerAbstract
* contains functions for validating fields
*
* @package Drupal\streamtime
*/
abstract class TransformerAbstract {
@rbg246
rbg246 / check-for-google-analytics-id.js
Created November 30, 2015 09:28
Prints a list of universal analytic ids found on a site
function checkAnalytics () {
var ids = ga.getAll();
var len = ids.length;
console.log('Universal Analytics');
console.log('ids', ids);
console.log('=======================================================');
console.log('Number of Universal Analytics IDs found : ' + ids.length);
console.log('=======================================================');
console.log('Universal Analytics IDs');
console.log('=======================================================');
<?php
/**
* This snippet adds extra classes to Drupal
* menu leafs (li tags) and menu itself (ul tags).
*/
/**
* Since the standart preprocess function for menu tree, which is
* template_preprocess_menu_tree, located in includes/menu.inc,
@rbg246
rbg246 / gist:a2a9f0e3f045e911c283
Created June 10, 2015 09:27
Universal Analytics - Check IDs loaded on webpage
function checkAnalytics () {
var ids = ga.getAll();
var len = ids.length;
console.log('Universal Analytics');
console.log('ids', ids);
console.log('=======================================================');
console.log('Number of Universal Analytics IDs found : ' + ids.length);
console.log('=======================================================');
console.log('Universal Analytics IDs');
console.log('=======================================================');
function countCSSRules() {
var results = '',
log = '';
if (!document.styleSheets) {
return;
}
for (var i = 0; i < document.styleSheets.length; i++) {
countSheet(document.styleSheets[i]);
}
function countSheet(sheet) {
@rbg246
rbg246 / config.js
Created June 1, 2015 09:46
CasperJS Test File - iterating through a Data Object specifying multiple viewports for each page
module.exports = {
clientScripts : [
'./node_modules/jquery/dist/jquery.min.js',
'./node_modules/lodash/index.js'
],
viewportSize : {
width: 1600,
height: 1200
},
timeout : 50000,
@rbg246
rbg246 / gist:5af38b48afb45bd77fa8
Last active August 29, 2015 14:20
Virtual Box - Setup, linking Virtual box with your computer's localhost and vhosts
Reference: http://stackoverflow.com/questions/1261975/addressing-localhost-from-a-virtualbox-virtual-machine
In Virtual Box - running Windows:
You can reach your localhost via:
http://10.0.2.2
If you need to link to vhosts on your localhost though you need to update the virtual box's hosts file
@rbg246
rbg246 / page-tests
Created April 29, 2015 23:05
Example of Mocha and SpookyJS iterating through a series of pages, running example tests
function pageParser() {
return {
url : window.location.href,
title : $('title').text(),
description : $('meta[name="description"]').attr('content')
};
}
var Spooky, config, i, run_spooky, scraping, spooky, spooky_is_ready;
Spooky = require('spooky');
config = {
child: {
port: 8081
}
};