Skip to content

Instantly share code, notes, and snippets.

@thatmarvin
thatmarvin / gist:2204602
Created March 26, 2012 11:50
Mongoose does not populate virtuals? :(
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var UserSchema = new Schema({
name: {
first: {
type: String
},
last: {
type: String
@thatmarvin
thatmarvin / gist:3023815
Created June 30, 2012 13:49
Gnarly Node.js Balanced Payments client
/*
Usage:
// In app.js
var balanced = require('./this-file.js');
balanced.configure({
secret: '...',
marketplaceUri: '...'
});
@thatmarvin
thatmarvin / postageapp.js
Created February 21, 2013 22:43
Demonstrating HTTP 500 response from PostageApp
/*
Remember to fill in your API key.
usage: node postageapp.js email@example.com
*/
var apiKey = 'FILL IN YOUR API KEY HERE',
postageapp = require('postageapp')(apiKey),
recipient = process.argv[2];
'use strict';
var express = require('express')
, app = module.exports = express.createServer();
// Configuration
app.configure(function () {
app.use(app.router);
});
var Q = require('q');
require('should');
require('mocha-as-promised')();
// This pretends to be the API client
function get(url) {
var deferred = Q.defer();
if (url === '/1') {
deferred.resolve([
@thatmarvin
thatmarvin / setter-test.js
Created April 19, 2013 22:17
Setter isn't invoked when value === null
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var assert = require('assert');
mongoose.connect('mongodb://localhost/test');
var OrderSchema = new Schema({
total: {
type: Number,
angular.module("ui.bootstrap", ["ui.bootstrap.tpls", "ui.bootstrap.position","ui.bootstrap.tooltip","ui.bootstrap.popover"]);
angular.module("ui.bootstrap.tpls", ["template/tooltip/tooltip-html-unsafe-popup.html","template/tooltip/tooltip-popup.html","template/popover/popover.html"]);
angular.module('ui.bootstrap.position', [])
/**
* A set of utility methods that can be use to retrieve position of DOM elements.
* It is meant to be used where we need to absolute-position DOM elements in
* relation to other, existing elements (this is the case for tooltips, popovers,
* typeahead suggestions etc.).
*/
module.exports = function (grunt) {
grunt.initConfig({
stylus: {
compile: {
options: {
compress: true,
use: [ require('bootstrap.stylus') ]
},
files: [{
expand: true,
@thatmarvin
thatmarvin / test-ui-router.html
Created November 17, 2014 19:38
ui.router erroring out in IE8
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="//code.angularjs.org/1.2.25/angular.js"></script>
<script src="//rawgit.com/angular-ui/ui-router/0.2.12/release/angular-ui-router.js"></script>
<script>
angular.module('fooApp', [
'ui.router'
@thatmarvin
thatmarvin / interval-provider-patch.js
Last active August 29, 2015 14:10
Patches Angular 1.2.x's $interval with fix from 1.3.x
/**
* The following is stolen from the patch that landed in 1.3.0-beta.13:
* https://github.com/angular/angular.js/pull/7999
*
* Remove this if upgraded to Angular 1.3.x.
*/
(function () {
'use strict';