Skip to content

Instantly share code, notes, and snippets.

View lorenzoongithub's full-sized avatar

lorenzo puccetti lorenzoongithub

  • london, united kingdom
View GitHub Profile
@lorenzoongithub
lorenzoongithub / esprima.js
Last active August 29, 2015 14:20
esprima.js
//
// esprima is a formidable javascript parser written in javascript
//
// http://esprima.org
//
// The following code was derived from here
// https://raw.githubusercontent.com/marijnh/acorn/master/test/tests.js
//
load('http://esprima.org/esprima.js');
//
// http://khan.github.io/structuredjs/
//
// structured.js is a Javascript library that provides a simple interface
// for checking the structure of Javascript code, backed by the abstract syntax tree
// generated by Esprima.
//
// This gist was originally derived from
// https://github.com/Khan/structuredjs/blob/master/tests.js
//
//
// moment.js is a powerful library to parse, validate, manipulate, and display dates in JavaScript.
// see: http://momentjs.com/
//
// this gist was loosely based on this article
// http://www.sitepoint.com/managing-dates-times-using-moment-js/
//
load('https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.js');
//
// mori.js - A library for using ClojureScript's persistent data structures and supporting API
// from the comfort of vanilla JavaScript.
//
// http://swannodette.github.io/mori/
//
// Inspired from https://raw.githubusercontent.com/swannodette/mori/master/spec/mori-spec.js (9/May/2015)
//
@lorenzoongithub
lorenzoongithub / validator.js
Last active August 29, 2015 14:22
validator.js
//
// validator.js - String validation and sanitization
// https://github.com/chriso/validator.js
//
// loosely based on https://github.com/chriso/validator.js/blob/master/test/validators.js
//
load('https://cdnjs.cloudflare.com/ajax/libs/validator/3.12.0/validator.js');
//
// http://jshint.com - a JavaScript Code Quality Tool
//
load('https://cdnjs.cloudflare.com/ajax/libs/jshint/2.7.0/jshint.js');
JSHINT('var a=0;');
if (JSHINT.errors.length != 0) throw '';
//
// lodash - https://lodash.com/
//
load('https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.9.3/lodash.js');
x = _.assign({ 'a': 1 }, { 'b': 2 }, { 'c': 3 })
if (x.a != 1) throw '';
if (x.b != 2) throw '';
if (x.c != 3) throw '';
//
// https://lodash.com/ - lodash v3.9.3
//
// A JavaScript utility library delivering consistency, modularity, performance, & extras.
//
// The work here was derived from the examples in here: https://lodash.com/docs
//
load('https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.9.3/lodash.js');
@lorenzoongithub
lorenzoongithub / validator.js
Last active August 29, 2015 14:22
validator.js
//
// source: https://github.com/chriso/validator.js
//
load('https://cdnjs.cloudflare.com/ajax/libs/validator/3.12.0/validator.js');
//
//should validate email addresses
//
if (validator.isEmail("foo@bar.com") == false) throw "";
//
// momentjs.com -
//
load('http://momentjs.com/static/js/global.js');
//
// add short reverse args
//