This file contains 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 validators = module.exports = { | |
isEmail: function(str) { | |
return str.match(/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/); | |
}, | |
isUrl: function(str) { | |
//A modified version of the validator from @diegoperini / https://gist.github.com/729294 | |
return str.length < 2083 && str.match(/^(?!mailto:)(?:(?:https?|ftp):\/\/)?(?:\S+(?::\S*)?@)?(?:(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[0-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))|localhost)(?::\d{2,5})?(?:\/[^\s]*)?$/i); | |
}, | |
//node-js-core | |
isIP : function(str) { |
This file contains 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 http = require('http'); | |
var NG_PREFIX = ")]}',\n"; | |
http.ServerResponse.prototype.ngJSON = function(obj){ | |
// allow status / body | |
if (2 == arguments.length) { | |
// res.json(body, status) backwards compat | |
if ('number' == typeof arguments[1]) { | |
this.statusCode = arguments[1]; |
This file contains 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
// Add COR ability | |
$httpProvider.defaults.useXDomain = true; | |
delete $httpProvider.defaults.headers.common['X-Requested-With']; | |
$httpProvider.defaults.withCredentials = true; |
This file contains 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
oo.load(function(){ | |
var regionQuery = new oo.Query('PROFILE ID', "30d"); | |
//Add metrics, dimensions, and filter for region | |
regionQuery.addMetric('ga:visits'); | |
regionQuery.addDimension('ga:metro'); | |
regionQuery.setFilter('ga:region==California'); | |
regionQuery.execute(function(data){ |
This file contains 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
/* | |
* Checks two Date objects based on human date (mm/dd/yyyy) two test equality | |
* | |
* @param {Date} date1 | |
* @param {Date} date2 | |
* @return {Boolean} | |
*/ | |
function sameHumanDate(date1, date2){ | |
if (date1.getDate() === date2.getDate() && | |
date1.getFullYear() === date2.getFullYear() && |
This file contains 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 Busboy = require('busboy'), | |
Grid = require('gridfs-stream'), | |
mongoose = require('mongoose'), | |
router = module.exports = require('express').Router(); | |
var gfs = new Grid(mongoose.connection.db, mongoose.mongo); | |
router | |
.get('/:item/receipt/info', function(req, res, next){ | |
gfs.files.find({ |
This file contains 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
/** | |
* Created by tyler on 5/1/14. | |
*/ | |
(function(){ | |
'use strict'; | |
angular.module('fsApp') | |
.directive('nsCents', [function () { |
This file contains 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
package pogs | |
import ( | |
"net/http" | |
"reflect" | |
"strings" | |
"github.com/gorilla/mux" | |
"github.com/tshaddix/parcel/encoding" | |
) |
This file contains 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
import util from 'util'; | |
class AppError { | |
constructor(message) { | |
Error.call(this); | |
Error.captureStackTrace(this, this.constructor.name); | |
this.name = this.constructor.name; | |
this.message = message; | |
} |
This file contains 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
import Joi from 'joi'; | |
import _ from 'lodash'; | |
import { | |
BadRequestError | |
} from './errors'; | |
const _promisedValidate = (msg, schema) => { | |
return new Promise((resolve, reject) => { | |
Joi.validate(msg, schema, { |
OlderNewer