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 express = require('express'); | |
var app = express(); | |
app.get('/', function(req, res){ | |
console.log('/'); | |
res.send('first'); | |
}); | |
app.get('/about', function(req, res){ | |
console.log('/about'); |
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
app.post('/login', function(req, res){ | |
User.findOne({email:req.body.email}, function(err, user){ | |
if (err) throw err; | |
if (user && user.isValidPassword(req.body.password)){ | |
user.last_login = Date.now(); | |
user.save(function(err){ | |
if (err) throw err; | |
req.session.user = user; | |
// console.log(req.session.user) // THIS WORKS! |
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
font(name, path, prefix) | |
font-family name | |
font-weight normal | |
font-style normal | |
src: url(path + prefix + '.eot') | |
src: url(path + prefix + '.eot?#iefix') format(embedded-opentype) | |
src: url(path + prefix + '.woff') format(woff) | |
src: url(path + prefix + '.ttf') format(truetype) | |
src: url(path + prefix + '.svg#' + name) format(svg) |
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
/** | |
* Loader instances support evented ajax calls, with caching | |
* @requires $.bindable() | |
*/ | |
var Loader = function(){ | |
this._cache = {}; | |
}; | |
Loader.prototype.load = function(cfg){ | |
var _self = this, | |
_cfg = {}, |
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
/** | |
* Loggable adds a log method to the passed object. | |
* @param obj {Object} Object which will get a new log() method | |
* @param objName {String} Optional parameter for displaying a string before each log output | |
* @param debugMode {boolean} Optional switch for disabling logging | |
*/ | |
var loggable = function(obj /* , objName, debugMode */){ | |
var objName = arguments[1] || "", | |
debugMode = (typeof arguments[2]!=="undefined") ? arguments[2] : true; | |
prefix = objName ? objName + ": " : ""; |
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
jQuery.fn.extend({ | |
/** | |
* Binds new resize handler to window object. For IE and Safari handler is executed on resize completion. | |
* @param newHandler function object | |
*/ | |
resizeEnd: function(newHandler){ | |
$(this).resize(function(){ | |
var handlerCode = newHandler.toString(); // for hash reference | |
if ($.browser.msie || $.browser.safari){ // handle after resize operation is complete (once) |
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
/** | |
* Sorts an array of json objects by some common property, or sub-property. | |
* @param {array} objArray | |
* @param {array|string} prop Dot-delimited string or array of (sub)properties | |
*/ | |
function sortJsonArrayByProp(objArray, prop){ | |
if (arguments.length<2){ | |
throw new Error("sortJsonArrayByProp requires 2 arguments"); | |
} | |
if (objArray && objArray.constructor===Array){ |