Skip to content

Instantly share code, notes, and snippets.

View d1b1's full-sized avatar
🎯
Focusing

Stephan L. Smith d1b1

🎯
Focusing
View GitHub Profile
@d1b1
d1b1 / Validator.prototype.arrayOf(size, regex)
Last active December 11, 2015 04:08
Custom Node.js Validator - arrayOf(size, regex) - Provides the ability to validate that a request value is an array of a given size where each element matches the regex pattern provided. Uses underscore. Designed for a node.js API path where 'date=2012-11-01,2012-12-01' will be used for a date filter into Mongo.
// This is a custom validator that will ensure that
// the value is an array of two elements where each
// element matches the same regex format.
var _ = reqquire('underscore');
var simpleDateRegex = new RegExp("^[0-9]{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])");
Validator.prototype.arrayOf = function(size, regex) {
// Split the string into an array.
@d1b1
d1b1 / delicious.jquery.js
Created February 2, 2012 04:19
Delicious Tag Builder for browser side jekyll blogs.
function get_delicious_json( tags, settings) {
var url = 'http://feeds.delicious.com/v2/json/' + settings.username + '/';
var tagStories = new Object();
var target = $('<ul>', {}).appendTo(settings.target);
$.each(tags.split(settings.separator), function(index, tagStr) {
$.getJSON(url + tagStr + "?callback=?", function(data) {
$.each(data, function(key, val) {
t = val.u;