Skip to content

Instantly share code, notes, and snippets.

View lorenzoongithub's full-sized avatar

lorenzo puccetti lorenzoongithub

  • london, united kingdom
View GitHub Profile
//
// http://www.numericjs.com/
//
load('http://www.numericjs.com/lib/numeric-1.2.6.min.js');
a = [[1,2,3],
[4,5,6],
[7,3,9]];
//
// algebraic equations
// in javascript
// http://algebra.js.org/
//
load('http://algebra.js.org/javascripts/algebra.min.js');
var Expression = algebra.Expression;
var Equation = algebra.Equation;
var Fraction = algebra.Fraction;
//
// A minimal test
// for https://lodash.com
//
load('https://cdnjs.cloudflare.com/ajax/libs/lodash.js/3.10.0/lodash.min.js');
x = _.last([1,2,3])
if (x !==3 ) throw '';
x = _.assign({ 'a': 1 }, { 'b': 2 }, { 'c': 3 });
if (x == undefined) throw '';
//
// validate.js
// A declarative way of validating j
// javascript objects.
//
// This test was based on the example
// http://validatejs.org/#validate
//
load("http://cdnjs.cloudflare.com/ajax/libs/validate.js/0.8.0/validate.min.js");
//
// =========
// yolpo
// in action
// =========
//
//
// Load a javascript library to test (e.g. lodash)
//
//
// hello world in react.js
//
load('https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js');
element = document.createElement('div');
HelloMessage = React.createClass({displayName: 'HelloMessage',
render: function() {
return React.createElement('element', null, 'Hello ', this.props.name);
//
// the 'hello world' for backbone.js
// http://backbonejs.org/
//
load('http://code.jquery.com/jquery-1.7.1.min.js');
load('http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js');
load('http://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone-min.js');
ListView = Backbone.View.extend({
//
// isPrime(n) --> returns boolean
// returns true if the number is prime.
//
load('http://www.yolpo.com/prime.0.1.js');
if (isPrime(2) != true) throw '';
if (isPrime(4) == true) throw '';
if (isPrime(169) == true) throw '';
if (isPrime(107777) != true) throw '';
//
// http://handlebarsjs.com/
// minimal templating on steroids
//
load('http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v2.0.0.js');
// 1 Usage
source = "<p>Hello, my name is {{name}}. I am from {{hometown}}. I have " +
"{{kids.length}} kids:</p>" +
load('http://underscorejs.org/underscore-min.js');
function json(x) { return JSON.stringify(x); }
sum = 0;
_.each([1, 2, 3],function(i) { sum+=i });
if (sum !== 6) throw '';
sum = 0;