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
'use strict'; | |
/** | |
* The default alphabet is 25 numbers and lowercase letters. | |
* Any numbers that look like letters and vice versa are removed: | |
* 1 l, 0 o. | |
* Also the following letters are not present, to prevent any | |
* expletives: cfhistu | |
*/ | |
var ALPHABET = |
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
'use strict'; | |
angular.module('q-extra', []) | |
.config(['$provide', function($provide) { | |
$provide.decorator('$q', ['$delegate', function($delegate) { | |
if(angular.isUndefined($delegate.resolve)) { | |
$delegate.resolve = function($q) { | |
return function(val){ | |
var dfd = $q.defer(); | |
dfd.resolve(val); |
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
'use strict'; | |
var util = require('util'), | |
fs = require('fs'); | |
var path = './server/services/defs'; | |
var dirs = fs.readdirSync(path); | |
dirs.forEach(function(dir) { | |
var servicePath = path + '/' + dir; |
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'), | |
app = express(); | |
app.configure(function() { | |
app.use(express.bodyParser()); | |
app.use(app.router); | |
}); | |
app.get('/', function(req, res) { | |
res.send(500); |
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
// This patches the $resource.$save function | |
// to make a PUT when an ID is present. | |
// Inspired by http://kirkbushell.me/angular-js-using-ng-resource-in-a-more-restful-manner/ | |
'use strict'; | |
angular.module( 'fz.restsource', [ 'ngResource' ] ) | |
.factory('$restsource', function($resource) { | |
var idField = '_id'; |
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
exports.promise = function(work) { | |
var dfd = $.Deferred(); | |
work(dfd.resolve, dfd.reject); | |
return dfd.promise(); | |
}; | |
exports.promiseResolved = function() { | |
return $.Deferred().resolve().promise(); | |
}; |
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 UserModel = Backbone.Model.extend({ | |
defaults: { | |
username: "", | |
password: { | |
old: "", | |
new: "", | |
confirm: "" | |
} | |
}, |
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
Backbone.View.extend({ | |
constructor: function (options) { | |
// Do stuff before the View has been setup | |
Backbone.View.apply(this, arguments); | |
// Do stuff after the View has been setup, | |
// particularly after `initialize()` has been called | |
return this; |
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
// Store a copy of the original Backbone.sync | |
var originalSync = Backbone.sync; | |
// Override Backbone.sync for all future requests. | |
Backbone.sync = function(method, model, options) { | |
// Do something special here | |
// And then call the original sync | |
return originalSync.call(model, method, model, options); | |
}; |
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
define(function(require, exports, module) { | |
var _ = require('lodash'); | |
var Validator = require('backbone.validator'); | |
// Duck-punch so that we get the errors in the right format: | |
// Instead of | |
// { | |
// field1: [ "errormsg1", "errormsg2" ], | |
// field2: [ "errormsg3" ] |