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
/** | |
Code copyright Dustin Diaz and Ross Harmes, Pro JavaScript Design Patterns. | |
**/ | |
// Constructor. | |
var Interface = function (name, methods) { | |
if (arguments.length != 2) { | |
throw new Error("Interface constructor called with " + arguments.length + "arguments, but expected exactly 2."); | |
} | |
this.name = name; |
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
// mongoose v3.6.18 | |
// | |
var mongoose = require('mongoose'); | |
mongoose.connect('localhost/mydb'); | |
var Schema = mongoose.Schema; | |
var MasterSchema = new Schema({ | |
name: String, | |
}); |
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
<html> | |
<head> | |
<script type="text/javascript" src="bower_components/monet/src/main/javascript/monet.js"></script> | |
<script type="text/javascript" src="bower_components/jquery/dist/jquery.js"></script> | |
<script> | |
window.onload= function() { | |
var read = IO(function(id) { | |
return $(id).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 BVT = function(width, depth, init, elems) { | |
this._width = width; | |
this._depth = depth; | |
this._leaf = depth === 1; | |
this._shift = (this._depth - 1) * Math.round(Math.log(width) / Math.log(2)); | |
this._himask = this._width - 1; | |
this._lomask = Math.pow(2, this._shift) - 1; | |
this._elems = elems; | |
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 suits = ["hearts", "spades", "clubs", "diamonds"]; | |
function pickCard(x: {suit: string; card: number; }[]): number; | |
function pickCard(x: number): {suit: string; card: number; }; | |
function pickCard(x): any { | |
if (typeof x == "object") { | |
var pickedCard = Math.floor(Math.random() * x.length); | |
//return pickedCard; | |
return 'notANumber'; |
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
/// <reference path='dst/ramda.d.ts' /> | |
import R = require('ramda'); | |
import Basic = require('./base'); | |
import Base = Basic.Base; | |
module Bar { | |
export function bar(s: string): Base { | |
return { | |
step: stepBar(s), |
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 R = require('ramda'); | |
var Bar; | |
(function (Bar) { | |
function bar(s) { | |
return { | |
step: stepBar(s), | |
display: displayBar(s) | |
}; | |
} |
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
// hello world | |
var R = require('ramda'); | |
var assert = require('assert'); | |
var obj = {person: {name: 'Joe'}}; | |
var clone = R.cloneObj(obj); | |
assert.deepEqual(clone, obj); |
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 domify = require('domify') | |
var R = require('ramda'); | |
var assert = require('assert'); | |
var obj = {person: {name: 'Joe'}}; | |
var clone = R.cloneObj(obj); | |
clone.person.name = 'Doe'; | |
document.body.appendChild(domify(obj.person.name + ": should be Joe")); |
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
Prototypical description of a deep copy method | |
deepCopy:: a -> b | |
copyDate:: Date -> Date | |
a == Number ? s = a: | |
a == String ? b = a: | |
a == Boolean ? b = a: | |
a == Function ? b = a: // remains by reference | |
a == Date ? b = copyDate a: |