This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<section class="tan two-line"> | |
<a href="#" class="simple">Order your<br /> B.E.A.R.S. Today</a> | |
<a href="#" class="round">Order your<br /> B.E.A.R.S. Today</a> | |
<a href="#" class="square">Order your<br /> B.E.A.R.S. Today</a> | |
</section> | |
<section class="gold two-line"> | |
<a href="#" class="simple">Order your<br /> B.E.A.R.S. Today</a> | |
<a href="#" class="round">Order your<br /> B.E.A.R.S. Today</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getIpAddress = function (interfaces) { | |
'use strict'; | |
var ip = [], | |
iface = null; | |
// loop through each interface in the interfaces object | |
for (iface in interfaces) { | |
// loop through each of the objects in the iface array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use shell commands to commit your ignored, compiled files, push | |
// everything to Heroku, and reset your commit like it never happened | |
gulp.task('deploy', ['other', 'compilation', 'tasks'], function () { | |
var shell = require('shelljs'); | |
if (!shell.which('git')) { | |
console.error('You need git installed to deploy.'); | |
shell.exit(1); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Assume you retrieve an array of blog posts, with each item in the array looking like: | |
// { | |
// title: "", | |
// date: new Date(), | |
// ... other properties that are less interesting | |
// } | |
// And we want to sort this array by date, print a pretty date, | |
// and group posts from the same year under the same heading. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db.reviews.find({}, function (err, result) { | |
if (err) next(err); | |
// each item in the result array looks like this | |
// { | |
// source: 'The Washington Post', | |
// location: 'City, State', | |
// review: 'Several paragraphs of review text' | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = { | |
/** | |
* Given the width of a container, the width of an item, and the gutter between inner items, | |
* calculate the number of items that can fit on a single row inside the container. | |
* @param {number} rowWidth the width, in pixels, of the container | |
* @param {number} itemWidth the width of each individual item in the container | |
* @param {number} [gutter] the space, in pixels, between each item (optional) | |
* @return {number} the number of items that fit in a row without overflow, never less than 1 | |
*/ | |
calculateItemsPerRow: function (rowWidth, itemWidth, gutter) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var foo = { | |
filter: function () {} | |
}; | |
var bar = []; | |
// return filtered array or object | |
function filterer(baz) { | |
return baz.filter(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// `gulp stylus --prod` will enable "production mode" | |
// `gulp stylus` will leave the prod flag undefined, so it will do a dev build | |
var gulp = require('gulp'), | |
gutil = require('gulp-util'), | |
prod = gulp.env.prod; | |
gulp.task('stylus', ['cleancss'], function () { | |
var stylus = require('gulp-stylus'), | |
prefix = require('gulp-autoprefixer'), | |
minify = require('gulp-minify-css'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mdeps = require('module-deps'), | |
_ = require('lodash'), | |
deps = []; | |
var md = mdeps({ | |
transform: 'hbsfy', | |
global: true | |
}); | |
md.on('end', function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// beautiful | |
function findAnagram(parent, child) { | |
// split the parent string into chars and iterate | |
return parent.split('').map(function (char, index, arr) { | |
// map each char in parent to an array of substrings with the same length as child.length | |
// and alphabetize the substrings for easy comparison later | |
return arr.slice(index, index + child.length).sort().join(''); | |
}).filter(function (subset) { | |
// compare the alphabetized substring to the alphabetized child | |
return subset === child.split('').sort().join(''); |
OlderNewer