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
<nav class="pagination"> | |
<% if (locals.prev) { %> | |
<a href="/pages/<%= (page + 1) %>">Previous</a> | |
<% } %> | |
<% if (locals.next) { %> | |
<a href="/pages/<%= (page - 1) %>">Next</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 locations = { | |
seattle: {reviews:[{title:"c"}]}, | |
portland: {reviews:[{title:"v"}]}, | |
provo: {reviews:[{title:"c"}]}, | |
}; | |
sort(locations).by("title").on("reviews"); | |
function sort(obj) { | |
sort.obj = obj; |
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
// run this in the console of the page | |
$(".dsq-commenter-name").eq(Math.round(Math.random() * $(".dsq-commenter-name").length)).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
// NOTE: Avoid using any requires up here as | |
// this file may be included on the client. | |
function DateTime (dateOrString, time) { | |
var time; | |
this._date; | |
this.offset; | |
// if you're a DateTime object or an old timemodule object |
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
function doStuff(cb) { | |
var badJSON = "asdlfihsdofy893q4fuiH:asdfh98#@!!!"; | |
var bad = JSON.parse(badJSON) | |
console.log("bad", bad) | |
cb(bad) | |
} | |
try{ | |
doStuff(function(str) { | |
console.log("hi", str) |
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
// groups users by type | |
var map = function() { | |
emit(this.type, 1) | |
} | |
var reduce = function(key, values) { | |
var result = 0 | |
values.forEach(function(value) { | |
result += value | |
}) | |
return result |
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
// main app | |
var helpers = require('./util/helpers') | |
app.helpers({"timeAgo": helpers.timeAgo}) | |
// view code | |
<span class="created"><%= timeAgo(activity.created) %></span> | |
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
// helpers file | |
/* | |
* JavaScript Pretty Date | |
* Copyright (c) 2008 John Resig (jquery.com) | |
* Licensed under the MIT license. | |
* | |
* Small Modification by Jamund Ferguson to accept a real Date object | |
*/ | |
exports.timeAgo = function(time) { |
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
// NOTE: Avoid using any requires up here as | |
// this file may be included on the client. | |
function DateTime (dateOrString, time) { | |
var time | |
this._date | |
this.offset | |
// generate a new datetime of now |