Skip to content

Instantly share code, notes, and snippets.

@bencooling
bencooling / css | components | tiles.markdown
Created August 26, 2015 12:11
css | components | tiles
@bencooling
bencooling / Responsive Navigation Bar by Grafikart.fr.markdown
Created August 25, 2015 06:44
Responsive Navigation Bar by Grafikart.fr
@bencooling
bencooling / api | google maps simple.markdown
Created August 25, 2015 06:43
api | google maps simple
@bencooling
bencooling / gulp-nodemon-livereload.js
Created May 26, 2015 03:38
gulp nodemon livereload
var gulp = require('gulp');
var livereload = require('gulp-livereload');
var nodemon = require('gulp-nodemon');
var notify = require('gulp-notify');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var minifyCSS = require('gulp-minify-css');
var rename = require('gulp-rename');
// compile scss to css, prefix, minify, save to assets/style.css
@bencooling
bencooling / upstart-job.conf
Last active August 29, 2015 14:21
Ubuntu Upstart Job Configuration
# /etc/init/testjob.conf
# Two basic stanzas that define purpose of job script and who created it
description "A test job file for experimenting with Upstart"
author "Ben Cooling"
# Run after system services and processes have already loaded (to prevent any conflict)
start on runlevel [2345]
exec echo Test Job ran at `date` >> /var/log/testjob.log
@bencooling
bencooling / node-process-lifecycle-events.js
Created May 20, 2015 03:41
nodejs process lifecycle events
/* demonstrate process lifecycle
--------------------------------*/
console.log('Start process');
// Event is fired when user kills process (ctl+d)
process.on('SIGINT', function() {
console.log('I\'m dying.');
setTimeout(function(){
process.exit(1);
@bencooling
bencooling / prototype.js
Created March 13, 2015 11:18
prototype examples
// method on prototype
function Foo(){}
Foo.prototype.me = function(){ return "Foo"; };
function Bah(){}
Bah.prototype = new Foo();
Bah.prototype.me = function(){
return Object.getPrototypeOf(Object.getPrototypeOf(this)).me() + ' & Bah';
};
@bencooling
bencooling / node-promises-bluebird.js
Created December 23, 2014 00:47
Node Promises Bluebird
"use strict";
var BbPromise = require('bluebird');
function delay(ms) {
var deferred = BbPromise.pending();
setTimeout(function(){
deferred
.fulfill("Hello "+ ms);
}, ms);
@bencooling
bencooling / basic-streams-refactored.js
Last active October 30, 2016 11:16
Node, basic read, transform & write streams
var stream = require('stream');
var a = new stream.Readable({
read: function(){}
});
var b = new stream.Transform({
transform: function (chunk, encoding, done) {
var str = chunk.toString() + 'bah';
this.push(str);
@bencooling
bencooling / multiple-jquery.js
Created November 3, 2014 04:33
requirejs implementation that won't override global jQuery
'use strict';
/*
|--------------------------------------------------------------------------
| Requirejs configuration
|--------------------------------------------------------------------------
|
| This file is used by both the browser & command line optomisation
| tool (see gruntfile.js)
|