Skip to content

Instantly share code, notes, and snippets.

Edward L Platt elplatt

Block or report user

Report or block elplatt

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View index.html
<link rel="stylesheet" type="text/css" href="style.css"/>
<script type="text/javascript" src="script.js"></script>
<button id="button">Click me!</button>
<div id="new-color"></div>
<div id="all-colors"></div>
elplatt / lineage-example.js
Last active Aug 29, 2015
Alternative to global namespacing. Rather than having globals or Singletons, declare each object you want to access to as a "lineage". The spawn() function is used to pass lineage values from an instance of class Elder to a new instance of class Younger: youngerInstance = elderInstance.spawn(Younger).
View lineage-example.js
Pet = Model.extend({})
PetController = Controller.extend({
"initialize": function (options) {
this.names = options.names;
this.model = this.spawn(Pet)
this.view = this.spawn(PetView, {
"model": this.model
}) // "names" is passed implicitly
elplatt / dict-example.js
Created Aug 28, 2013
This JavaScript class wraps an Object to provide useful hash table / dictionary functionality. All data is maintained in the underlying Object. It doesn't pollute Object.prototype, so it plays nice with jQuery. See dict-example.js for examples.
View dict-example.js
map = {
"USA": { "Detroit": 23, "Cambridge": 5, "Cupertino": 0.5 },
"Canada": { "Waterloo": 1 },
"Switzerland": { "Geneva": 0.5 }
d = new Dict(map);
d.getDict("USA").get("Detroit"); // => 23
d.getDict("China", {}).get("Beijing", 0); // => 0
You can’t perform that action at this time.