Skip to content

Instantly share code, notes, and snippets.

View tblobaum's full-sized avatar
😆

Thomas J Blobaum tblobaum

😆
  • Creston, Iowa
View GitHub Profile
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))
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>');
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
<html>
<body>
<div id='app'></div>
<script>
var helloView = Backbone.View.extend({
events: {
'click': 'open',
},
(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("';")
@tblobaum
tblobaum / LICENSE.txt
Created November 28, 2011 13:01 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
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
@tblobaum
tblobaum / select.js
Created December 10, 2011 16:38 — forked from Raynos/select.js
tiny select. Selecting has never been so awesome \o/
// 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) {
@tblobaum
tblobaum / gist:1518777
Created December 25, 2011 05:47
remove all .gitignores from node_modules
find . -name '.gitignore' -print0 | xargs -0 rm
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()
}
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 ) {