Skip to content

Instantly share code, notes, and snippets.

🍕
Is life without pizza really living?

Matthew Pietz sirlancelot

🍕
Is life without pizza really living?
Block or report user

Report or block sirlancelot

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sirlancelot
sirlancelot / try-handlebars.url
Last active Dec 12, 2017
Try Handlebars Bookmarklet. Add this url to your bookmarks bar for a quick-and-dirty Handlebars.js template compiler.
View try-handlebars.url
data:text/html;base64,PGh0bWwgbGFuZz0iZW4iPgo8aGVhZD4KCTxtZXRhIGNoYXJzZXQ9IlVURi04Ij4KCTx0aXRsZT5UcnkgSGFuZGxlYmFycy5qczwvdGl0bGU+Cgk8bGluayByZWw9InN0eWxlc2hlZXQiIGhyZWY9Imh0dHBzOi8vY2RuanMuY2xvdWRmbGFyZS5jb20vYWpheC9saWJzL25vcm1hbGl6ZS81LjAuMC9ub3JtYWxpemUubWluLmNzcyI+Cgk8bGluayByZWw9J3N0eWxlc2hlZXQgcHJlZmV0Y2gnIGhyZWY9J2h0dHBzOi8vY2RuanMuY2xvdWRmbGFyZS5jb20vYWpheC9saWJzL3R3aXR0ZXItYm9vdHN0cmFwLzQuMC4wLWJldGEuMi9jc3MvYm9vdHN0cmFwLmNzcyc+Cgk8c3R5bGU+CglodG1sLGJvZHksI2FwcCwucm93IHsgaGVpZ2h0OiAxMDAlOyB9Cglib2R5IHsKCQliYWNrZ3JvdW5kLWNvbG9yOiAjMTExMzExOwoJCWNvbG9yOiAjZmZmZmZmOwoJfQoJLmVkaXRvcnMgPiAuZm9ybS1ncm91cCwKCS5wcmV2aWV3ID4gLmZvcm0tZ3JvdXAgewoJCWRpc3BsYXk6IC13ZWJraXQtYm94OwoJCWRpc3BsYXk6IC1tcy1mbGV4Ym94OwoJCWRpc3BsYXk6IGZsZXg7CgkJLXdlYmtpdC1ib3gtb3JpZW50OiB2ZXJ0aWNhbDsKCQktd2Via2l0LWJveC1kaXJlY3Rpb246IG5vcm1hbDsKCQktbXMtZmxleC1kaXJlY3Rpb246IGNvbHVtbjsKCQlmbGV4LWRpcmVjdGlvbjogY29sdW1uOwoJCW1hcmdpbi1ib3R0b206IDA7Cgl9CgkuZWRpdG9ycyA+IC5mb3JtLWdyb3VwID4gLmFjZV9lZGl0b3IsCgkucHJldmlldyA+IC5mb3JtLWdyb3VwID4gLmFjZV
@sirlancelot
sirlancelot / post-checkout
Last active Dec 9, 2017
Git hooks for Node.js
View post-checkout
#!/bin/bash
# Warn when `package.json` is changed between checkouts.
PREVIOUS_HEAD=$1
NEW_HEAD=$2
BRANCH_SWITCH=$3
if [ $(git diff $PREVIOUS_HEAD..$NEW_HEAD --name-only -- package.json | wc -l) == "1" ]; then
echo "[post-checkout] \`package.json\` changed, running \`npm install --no-optional\`..."
npm install --no-optional
@sirlancelot
sirlancelot / .eslintrc.js
Last active May 16, 2019
Starter ESLint config
View .eslintrc.js
const MAYBE = process.env.NODE_ENV === "production" ? "error" : "off"
const prettierRc = {
arrowParens: "always",
semi: false,
trailingComma: "es5",
}
module.exports = {
root: true,
@sirlancelot
sirlancelot / nodeBrowserAdaptor.js
Last active Aug 29, 2015
Module definition compatible for use in Node.js & Browser environments.
View nodeBrowserAdaptor.js
// Defines a module that works in Node & Browsers
(function(global, factory) {
var mock = { exports: {} }
var local = (typeof module === "object" && module.exports) ? module : mock
factory(local, local.exports)
if (local === mock) global["yourNamespaceHere"] = local.exports
}(this, function(module, exports) {
"use strict";
// Add your work to `exports` or `module.exports`
}))
@sirlancelot
sirlancelot / README.md
Last active Apr 21, 2017 — forked from anonymous/zzz.js
An experiment to create named parameters in Javascript.
View README.md
var createNamedParameters = require("./named-parameters")

var fn = createNamedParameters(["greeting", "person"], function(a, b) {
	console.log(a, b)
})

fn.greeting("hello") // set a
fn.person("world")   // set b
fn() // console.log gets run
View AddCustomCodePlugin.js
module.exports = AddCustomCodePlugin
function AddCustomCodePlugin() {}
AddCustomCodePlugin.prototype.apply = function(compiler) {
var self = this
compiler.plugin("compilation", function(compilation) {
compilation.mainTemplate.plugin("local-vars", self.localVars.bind(self)))
})
}
@sirlancelot
sirlancelot / gulpfile-runtasks.js
Last active Aug 29, 2015
Run a series of gulp tasks followed by a callback when they are complete. As long as all sub-tasks properly identify themselves as sync, async, stream, or promise, the callback will not execute until all sub-tasks are complete. Standard Gulp principles apply around dependencies as well.
View gulpfile-runtasks.js
var gulp = require("gulp");
module.exports = runTasks;
// Run a series of subtasks and execute a callback when they're complete.
function runTasks(subTasks, next) {
// If no subTasks were provided, just move on.
if (!subTasks || !subTasks.length)
return void (typeof next === "function" && next());
// Always use an array.
View multiple-instance.js
var MultipleInstance = (function() {
var uid = 0;
function MultipleInstance() {
// Increment the ID and make it a read-only property
Object.defineProperty(this, "id", { __proto__: null, value: ++uid });
}
return MultipleInstance;
}());
MultipleInstance.prototype.whatever = function() {
You can’t perform that action at this time.