Skip to content

Instantly share code, notes, and snippets.

View wehrhaus's full-sized avatar

Justin Wehrman wehrhaus

View GitHub Profile
@wehrhaus
wehrhaus / Super_Sub_Constructor_Pattern
Last active August 29, 2015 14:01
Superconstructor / Subconstructor Example
// Superconstructor
function Person(name) {
this.name = name;
}
Person.prototype.sayHelloTo = function (otherName) {
console.log(this.name + ' says hello to ' + otherName);
};
Person.prototype.describe = function () {
return 'Person name ' + this.name;
};
@wehrhaus
wehrhaus / Require.js config with noConflict jQuery released back into the wild
Last active August 29, 2015 14:00
Require.js config with noConflict jQuery released back into the wild
/js
/libs
jquery-private.js
jquery.js
config.js
@wehrhaus
wehrhaus / app.js
Created April 24, 2014 01:52
Render `pretty` Jade templates via Express v3.x using 'pretty' flag
if (app.get('env') === 'development') {
app.use(function(req, res, next) {
app.locals.pretty = true;
next();
});
}
@wehrhaus
wehrhaus / optionAlphaSort.js
Last active August 29, 2015 14:00
Take a <select> object with a group of <options> that are sorted by a numeric value attribute and sort alphabetically by the text.
$(document).ready(function () {
var $selector = $('#selector'),
$options = $selector.find('option'),
sortedOptions = [], i;
for(i = 0; i < $options.length; i += 1) {
sortedOptions.push([$($options[i]).text(), i]);
}
@wehrhaus
wehrhaus / bvFilter.js
Last active August 29, 2015 13:59
Filter BazaarVoice Results
// Util for cleaning up the BV Timestamp
var decomposeTimestamp = function (timestamp) {
var month = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
d = new Date(timestamp),
component = {};
return component {
day: function () { return d.getDate(); },
month: function (type) { // call month('num') for 1 thru 12 instead of Names
if (type === 'num') {
@wehrhaus
wehrhaus / decomposeTimestamp.js
Created April 11, 2014 03:50
Breakdown timestamp into useable parts.
var decomposeTimestamp = function (timestamp) {
var month = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
d = new Date(timestamp),
component = {};
return component = {
day: function () { return d.getDate(); },
month: function (type) { // call month('num') for 1 thru 12 instead of Names
if (type === 'num') {
return d.getMonth() +1;
@wehrhaus
wehrhaus / take_note
Last active August 29, 2015 13:57
Simple note keeper script. Creates files based on date and timestamps entries.
#!/bin/bash
# Simple note keeper script.
# Creates files based on date and timestamps entries.
# setup date format to ##.##.##
dateStamp=$(date +"%m.%d.%y")
# write note to:
fileName=$HOME/TakeNote/note_${dateStamp}.txt
@wehrhaus
wehrhaus / .gitignore
Last active August 29, 2015 13:57
Starter .gitignore file
# Generics
*~
*.lock
*.DS_Store
*.sublime-workspace
# Logs
logs
*.log