Skip to content

Instantly share code, notes, and snippets.

View sirlancelot's full-sized avatar
🍕
Is life without pizza really living?

Matthew Pietz sirlancelot

🍕
Is life without pizza really living?
View GitHub Profile
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 August 29, 2015 14:05
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.
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.
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() {
@sirlancelot
sirlancelot / gist:8060281
Created December 20, 2013 19:46
The best answers to: http://regex.alf.nu/
foo
k$
[a-f]{4}
(...).*\1
^(?!.*(.)(.)\2\1)
^(.)(.).*\2\1$
^(?!(xx+)\1+$)
(.)(.\1){3}
^.{5}[^e]?$
^(([147]4|40|3[269]|9[05]|[378]1).+|0[369]*|[81][257])*$
@sirlancelot
sirlancelot / pre-commit
Created October 10, 2013 05:49
A Bolt.cm Git pre-commit hook to clear the `bolt_log` upon commit. I use Git for deployment purposes and so storing the database in Git makes this a little easier.
#!/bin/bash -e
# Clear up the log of any database added to the index before committing it.
git diff-index --name-only --cached HEAD \
| grep -e "database/.*\.db" \
| while read DB; do
echo "Truncating log table in database: $DB"
sqlite3 "$DB" "DELETE FROM bolt_log; VACUUM;"
git add "$DB"
done
@sirlancelot
sirlancelot / nodejs.org.css
Created May 24, 2013 16:06
Affix the green bar to the top of the page. Really neat effect when scrolling and watching the "Fork me on Github" button.
body::before {
content: "";
height: 6px;
background-color: #8cc84b;
position: fixed;
left: 0;
right: 0;
top: 0;
}
@sirlancelot
sirlancelot / post.md
Created January 15, 2013 18:25
Getting the Body You've Always Wanted

Getting the Body You've Always Wanted

  1. Wait until at least April, when the ground softens.
  2. Dress warmly (think layers), bring a shovel and a lantern on a stick.
  3. Listen. Is someone coming?
  4. Cover your lantern with a blanket, wait.
  5. Continue. If you're not used to hard physical labor, wear weight-lifting gloves to avoid excess chafing.
  6. You may need a wheelbarrow. You probably should have brought a wheelbarrow.
  7. Come back with a wheelbarrow.
  8. Try to have the body you've always wanted back to your house by dawn.
@sirlancelot
sirlancelot / example.js
Created June 29, 2012 17:25
Highlight words in an element
// Highlight words containing github.
$("#content p").highlight("github");
@sirlancelot
sirlancelot / SetIfDefault.vim
Created January 21, 2012 04:03
A Vim function to set an option only if it is currently at its default value.
" ===============================================
" _ __(_)__ _ ________
" _| |/ / // ' \/ __/ __/
" (_)___/_//_/_/_/_/ \__/
"
" Maintainer: Matthew Pietz
"
" ===============================================
" Put your overrides in here
@sirlancelot
sirlancelot / extern.js
Created December 30, 2011 19:50
Creates a jQuery selector that matches all external links
jQuery.expr[':'].external = function(obj) {
return !obj.href.match(/^mailto\:/) && (obj.hostname != location.hostname);
};
// Add class to all external links
$('a:external').addClass('external');