Skip to content

Instantly share code, notes, and snippets.

View shellscape's full-sized avatar
🌴

Andrew Powell shellscape

🌴
View GitHub Profile
@shellscape
shellscape / signal-debug.js
Created April 24, 2017 15:08
signal event debugging
(function (root) {
'use strict';
var scope = 'bananas', // whatever your company global variable is
enabled = /(\?|&)debug=true/.test(document.location.search);
if (!root[scope) {
root[scope] = {
signal: {}
};
/*
* A webpack plugin for specifying multiple dependencies for a single
* variable.
*
* plugins: [
* new ProvideMultiPlugin({
* 'gilt': [ 'internal.gilt_require', 'internal.require' ]
* })
* ]
*
'use strict';
const chalk = require('chalk');
const stringLength = require('string-length');
const table = require('text-table');
const tableOptions = { stringLength: stringLength };
class Reporter {
log (file) {
@shellscape
shellscape / npm-version-tree.js
Last active November 9, 2016 15:25
Snippet demonstrating NPM module version tree retrieval.
'use strict';
const npm = require('npm');
const semver = require('semver');
const graph = {};
function get (moduleName) {
const silent = true;
return new Promise((resolve, reject) => {
const path = require('path'),
webpack = require('webpack'),
ExtractTextPlugin = require('extract-text-webpack-plugin'),
CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = {
output: {
path: path.join(__dirname, 'dist'),
publicPath: '/',
filename: '/assets/js/build.js'
@shellscape
shellscape / github-graph.js
Last active June 28, 2021 00:28
Embedding the Github Contribution Calendar
var proxy = 'https://urlreq.appspot.com/req?method=GET&url=',
url = proxy + 'https://github.com/{{ site.github }}',
colors = {
'eeeeee': 'github-graph-none',
'd6e685': 'github-graph-litte',
'8cc665': 'github-graph-some',
'44a340': 'github-graph-more',
'1e6823': 'github-graph-most'
};
@shellscape
shellscape / index.js
Last active October 29, 2015 15:16
Evaluating AST Tree of PostCSS
var postcss = require('postcss'),
fs = require('fs'),
path = require('path'),
css = fs.readFileSync(path.join(__dirname, 'lesstest.less'), 'utf-8'),
root = postcss.parse(css);
console.log(require('util').inspect(root, { depth: 6 }));
@shellscape
shellscape / buster.js
Created January 30, 2015 16:38
Cache Busting a Script in a Five Minute Interval
var now = new Date(),
month = now.getMonth(),
day = now.getDate(),
year = now.getFullYear(),
hours = now.getHours(),
minutes = now.getMinutes(),
buster = '' + month + day + year + hours;
buster += (minutes - (minutes % 5));
@shellscape
shellscape / overriding-grunt-output.js
Created February 7, 2014 15:57
overriding grunt output
// --------
var hooker = require('hooker'),
prefix,
newline = true;
// Override grunt.log.header to update a per-line prefix and prevent default logging.
hooker.hook(grunt.log, 'header', function () {
prefix = '[' + grunt.task.current.nameArgs + '] ';
@shellscape
shellscape / before-after-functions
Last active January 3, 2016 09:29
esformatter plugin examples using real-world formatting requirements.
BEFORE:
function(
_, $,
id) {
AFTER:
function (_, $, id) {