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
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
'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
'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
var request = require('request'); | |
// The `auth` object will take precedence | |
// over the `Authorization` header | |
var options = { | |
url: 'http://requestb.in/1jt9nmk1', | |
method: 'GET', | |
headers: { | |
Authorization: 'Basic 1234' | |
}, |
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
Date.prototype.duration = function(granularity) { | |
if(!granularity) { | |
granularity = 's'; | |
} | |
var units = [{ | |
enabled: /^[wdhms]$/.test(granularity), | |
singular: 'week', | |
plural: 'weeks', | |
inMillis: 7 * 24 * 60 * 60 * 1000 |
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
// Change underscore's templating from ERB-style to Mustache-style | |
_.templateSettings = { | |
interpolate : /\{\{(.+?)\}\}/g | |
}; |
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 (root, factory) { | |
if (typeof define === 'function' && define.amd) { | |
// AMD. Register as an anonymous module. | |
define(['bean', 'underscore'], function (bean, _) { | |
// Also create a global in case some scripts | |
// that are loaded still are looking for | |
// a global even when an AMD loader is in use. | |
return (root.Flotr2 = factory(bean, _)); | |
}); | |
} else { |
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 EMAIL_REGEX = /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,253}[a-zA-Z0-9])?)*$/; | |
var isValidEmailAddress = function(email) { | |
return EMAIL_REGEX.test(email); | |
}; |
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
return _.reduce($el.serializeArray(), function (hash, pair) { | |
hash[pair.name] = pair.value; | |
return hash; | |
}, {}); |
OlderNewer