This file contains hidden or 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.all('/user', function (req, res, next) { | |
User.findOne(req.params, function (e, user) { | |
if (!user) var user = new User(req.params) | |
var here = req.sessionId + '#/user' | |
nQuery(here).on('ready', function ($) { | |
$('.form').live('submit', function () { | |
$('.form').serialize(function (data) { | |
//update the user with the form data | |
user.update($.parseQueryString(data)) |
This file contains hidden or 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') | |
, dnode = require('dnode') | |
, nQuery = require('../') | |
, mongoose = require('mongoose') | |
, express = Express.createServer(); | |
var app = function ($) { | |
$.on('/', function () { | |
$.on('ready', function () { | |
$('body').append('<h1>My Blog</h1>'); |
This file contains hidden or 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') | |
, dnode = require('dnode') | |
, nQuery = require('../') | |
, mongoose = require('mongoose') | |
, express = Express.createServer(); | |
mongoose.connect('mongodb://localhost/my_blog'); | |
var Comments = new mongoose.Schema({ | |
title : String |
This file contains hidden or 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
<html> | |
<body> | |
<div id='app'></div> | |
<script> | |
var helloView = Backbone.View.extend({ | |
events: { | |
'click': 'open', | |
}, | |
This file contains hidden or 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() { | |
this.tmpl3 = function tmpl(str, data) { | |
var value = "var out = ''; out+=" + "'" + | |
str.replace(/[\r\t\n]/g, " ") | |
.replace(/'(?=[^%]*%>)/g,"\t") | |
.split("'").join("\\'") | |
.split("\t").join("'") | |
.replace(/<%=(.+?)%>/g, "'; out += $1; out += '") | |
.split("<%").join("';") |
This file contains hidden or 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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
This file contains hidden or 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
// Pretty fast - http://jsperf.com/select-vs-natives-vs-jquery/2 | |
/* | |
Selector function. | |
@param String selector - selector to use. Works with "#foo", ".bar" and "tag". | |
@param Node context - optional context to restrict search to, defaults to document. | |
@return Node|NodeList | |
*/ | |
function select (selector, context) { |
This file contains hidden or 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
find . -name '.gitignore' -print0 | xargs -0 rm |
This file contains hidden or 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 Mongoose = require('mongoose') | |
function mongooseToJSON (schema, options) { | |
options = options || {}; | |
schema.method('toJSON2', function () { | |
var getters = schema.virtuals.modelName.getters | |
for (var key in getters) { | |
var fn = getters[key] | |
this._doc['virtual_'+key] === fn() | |
} |
This file contains hidden or 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 throttle(fn, delay) { | |
var timer = 0 | |
, last = new Date().getTime() | |
return function () { | |
var context = this | |
, args = arguments | |
, should = last + delay | |
, ind = should - new Date().getTime() | |
if ( ind < 0 ) { |