Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Powell shellscape

View GitHub Profile
View overriding-grunt-output.js
// --------
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 / buster.js
Created Jan 30, 2015
Cache Busting a Script in a Five Minute Interval
View buster.js
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));
View datepicker.onafterselect
var _selectDate = $.datepicker._selectDate,
selectHook = function(id, dateStr){
var target = $(id),
inst = this._getInst(target[0]),
result = _selectDate.call(this, id, dateStr);
onAfterSelect && onAfterSelect(inst);
return result;
},
@shellscape
shellscape / gist:1219126
Created Sep 15, 2011
Outlines an issue with VisualStyleRenderer.GetFont / GetThemeFont whereby an actual value is never returned
View gist:1219126
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;
namespace VisualStyleGetFontTest {
@shellscape
shellscape / index.js
Last active Oct 29, 2015
Evaluating AST Tree of PostCSS
View index.js
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 }));
View gist:5189036
<asp:textbox id="date" runat="server" />
<brew:datepicker for="date" runat="server" />
@shellscape
shellscape / before-after-functions
Last active Jan 3, 2016
esformatter plugin examples using real-world formatting requirements.
View before-after-functions
BEFORE:
function(
_, $,
id) {
AFTER:
function (_, $, id) {
@shellscape
shellscape / npm-version-tree.js
Last active Nov 9, 2016
Snippet demonstrating NPM module version tree retrieval.
View npm-version-tree.js
'use strict';
const npm = require('npm');
const semver = require('semver');
const graph = {};
function get (moduleName) {
const silent = true;
return new Promise((resolve, reject) => {
View gulp-david-stylish.js
'use strict';
const chalk = require('chalk');
const stringLength = require('string-length');
const table = require('text-table');
const tableOptions = { stringLength: stringLength };
class Reporter {
log (file) {
View provide-multi-plugin.js
/*
* A webpack plugin for specifying multiple dependencies for a single
* variable.
*
* plugins: [
* new ProvideMultiPlugin({
* 'gilt': [ 'internal.gilt_require', 'internal.require' ]
* })
* ]
*