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
@sirlancelot
sirlancelot / README.md
Last active April 21, 2017 21:47 — forked from anonymous/zzz.js
An experiment to create named parameters in Javascript.
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
@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');
@sirlancelot
sirlancelot / waves.txt
Created July 19, 2011 21:47
Shortwave Descriptor
#kill-defaults
> Each command is defined on a single line comprised of:
>
> 1. a case-insensitive, alpha-numeric trigger followed
> by whitespace
> 2. a url followed by whitespace (if the url contains
> spaces they must be encoded as `%20`)
> 3. a short description
>
> Urls may contain the following replacement tokens:
@sirlancelot
sirlancelot / migrate-credentials.sh
Created March 20, 2011 23:45
migrade user credentials
#!/bin/bash
#############################
# Migrate User Credentials
#
# @author Matthew Pietz
Mode=0
BackupPath="/tmp/user-mig.$$"
StorageFile="user-migrate.tar.gz"
StartID=1000