Skip to content

Instantly share code, notes, and snippets.

Dan MacTough danmactough

Block or report user

Report or block danmactough

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View Mongoose+Express test 01
// Create the record we will test modify
var mongoose = require('mongoose')
, Schema = mongoose.Schema
, crypto = require('crypto')
, sys = require('sys')
, User
;
function defineModels(mongoose, fn) {
var Schema = mongoose.Schema
@danmactough
danmactough / Mongoose+Express test 02a
Created Jul 6, 2011
Modify the record (working)
View Mongoose+Express test 02a
var mongoose = require('mongoose')
, Schema = mongoose.Schema
, crypto = require('crypto')
, sys = require('sys')
, User
;
function defineModels(mongoose, fn) {
var Schema = mongoose.Schema
, ObjectId = Schema.ObjectId
View Mongoose+Express test 02b
var mongoose = require('mongoose')
, Schema = mongoose.Schema
, crypto = require('crypto')
, sys = require('sys')
, User
;
function defineModels(mongoose, fn) {
var Schema = mongoose.Schema
, ObjectId = Schema.ObjectId
@danmactough
danmactough / express-form-alt.js
Created Jul 20, 2011
Alternative to Connect - Multipart
View express-form-alt.js
/*!
* Alternative to Connect - Multipart
* Copyright(c) 2010, 2011 TJ Holowaychuk <tj@vision-media.ca>, Dan MacTough <danmactough@gmail.com>
* MIT Licensed
*/
/**
* Module dependencies.
*/
View gist:1206674
Model.post('init', function() {
if (!this.isNew) {
var my = this
, activePaths = Object.keys(this._activePaths.states.init);
Object.keys(my._doc).forEach(function(path){
if (activePaths.indexOf(path) === -1) {
delete(my._doc[path]);
}
});
this._doc = my._doc;
View index.js
var mongoose = require('mongoose');
mongoose.connect('localhost', 'testing_535');
console.error('mongoose version', mongoose.version);
var OID = mongoose.Types.ObjectId;
var ASchema = new mongoose.Schema({
square: mongoose.Schema.ObjectId
, task: Number
});
View includes.jade
html
body
h1 My Site
p Welcome to my super lame site.
include template.jqtl
@danmactough
danmactough / gist:2041678
Created Mar 15, 2012
Bash one-liner to create JSON { shorturl: longurl } from a directory of Adjix redirects
View gist:2041678
grep "rel=\"canonical\"" * | awk '{ OFS = ""; ORS = ","; file = substr($1, 0, 4); href = match($0, /http:\/\/[^\"]+/); print "\"", file, "\": \"", substr($0, RSTART, RLENGTH), "\""}' | awk '{ OFS = ""; ORS = ""; len = length($0); print "{", substr($0, 1, len - 1), "}" }'
View test-update-getters-setters-defaults.js
var mongoose = require('mongoose')
, Schema = mongoose.Schema
, ObjectId = Schema.ObjectId
;
mongoose.connect('mongodb://localhost/test_update_getters_setters_defaults');
var Fooschema = new Schema ({
name : { type: String, default: 'foo', required: true }
, date : Date
View rpmlist
Installed Packages
ConsoleKit.i686 0.4.2-3.fc14 @updates
ConsoleKit-libs.i686 0.4.2-3.fc14 @updates
ConsoleKit-x11.i686 0.4.2-3.fc14 @updates
GConf2.i686 2.31.91-1.fc14 @fedora
GConf2-gtk.i686 2.31.91-1.fc14 @fedora
ImageMagick.i686 6.6.4.1-16.fc14 installed
ModemManager.i686 0.4.998-1.git20110706.fc14 installed
ORBit2.i686 2.14.19-1.fc14 @fedora
SDL.i686 1.2.14-11.fc14 @updates
You can’t perform that action at this time.