Skip to content

Instantly share code, notes, and snippets.

View chrisbuttery's full-sized avatar
🏠
Working from home

Chris Buttery chrisbuttery

🏠
Working from home
View GitHub Profile
@chrisbuttery
chrisbuttery / multiple.html
Last active August 29, 2015 13:57
Skater
<!-- multiple skaters -->
<html>
<head>
</head>
<body>
<div class="js-pro-skater">
<span>Favourite Pro Skater: {fullName} of {company}</span><br/>
<span>{firstName} was the best!</span>
@chrisbuttery
chrisbuttery / javascript.js
Last active August 29, 2015 13:58
_trackEvent
module.exports = function(name){
document.addEventListener('blur', function(el){
if (!el.target.value){
_gaq.push(['_trackEvent', name, 'skipped', el.target.name]);
}
else {
_gaq.push(['_trackEvent', name, 'completed', el.target.name]);
}
}, true);
};
@chrisbuttery
chrisbuttery / README.md
Last active May 3, 2019 05:05
Track GA Events

track-event

Delegate a listener for the blur() event, on document.

This component is predominantly used to record 'blur' events on form elements. However is flexible enough to be customised.

Installation

$ component install nib-components/track-event
@chrisbuttery
chrisbuttery / data.js
Last active August 29, 2015 14:00
Re-construct and categorise array
var data = [
{price: "$99.99", stocked: true, name: "iPod Touch", category: "Electronics"},
{price: "$399.99", stocked: false, name: "iPhone 5", category: "Electronics"},
{price: "$199.99", stocked: true, name: "Nexus 7", category: "Electronics"},
{price: "$49.99", stocked: true, name: "Football", category: "Sporting Goods"},
{price: "$9.99", stocked: true, name: "Baseball", category: "Sporting Goods"},
{price: "$29.99", stocked: false, name: "Basketball", category: "Sporting Goods"}
];
@chrisbuttery
chrisbuttery / index.js
Last active August 29, 2015 14:02
baha men lyrics
var BahaMenLyrics = require('bahaMenLyrics');
var dogs = new BahaMenLyrics();
dogs.sing(); // "Who let the Dogs out?! Woof... Woof... Woof... Woof"
var goats = new BahaMenLyrics('Goats', 'Baaaa');
goats.sing(); // "Who let the Goats out?! Baaa... Baaa... Baaa... Baaa"
/*
* Require our plugins.
*/
var gulp = require('gulp'),
debug = require('gulp-debug'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
/*
* Require our plugins.
*/
var gulp = require('gulp'),
debug = require('gulp-debug'),
sass = require('gulp-ruby-sass'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
@chrisbuttery
chrisbuttery / README
Last active August 29, 2015 14:02
Gulp + Browserify
This example uses Browserify and expects a stucture like
|- gulpfile.js
|
|- package.json
|
|- [javascript]
| |
| | - app.js
| |
var promise = getPromise('http://api.icndb.com/jokes/random')
promise.then(function(data) {
console.log('Got data! Promise fulfilled.'); // 1st request finished
// 2nd request
return getPromise('http://api.icndb.com/jokes/random');
}).then(function(result) {
console.log('the final result');
});
{
// --------------------------------------------------------------------
// JSHint Configuration, Strict Edition
// --------------------------------------------------------------------
//
// This is a options template for [JSHint][1], using [JSHint example][2]
// and [Ory Band's example][3] as basis and setting config values to
// be most strict:
//
// * set all enforcing options to true