Skip to content

Instantly share code, notes, and snippets.

/*
* Support for iTunes-style m4a tags
* See:
* http://atomicparsley.sourceforge.net/mpeg-4files.html
* http://developer.apple.com/mac/library/documentation/QuickTime/QTFF/Metadata/Metadata.html
* Authored by Joshua Kifer <joshua.kifer gmail.com>
*/
var ID4 = {};
@aadsm
aadsm / screening.js
Created September 13, 2010 20:30 — forked from rmurphey/screening.js
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}
1) (foo?bar.doSomething:bar.doSomethingElse)(el); // <-- minimizers can still work here
2) bar[foo?"doSomething":"doSomethingElse"](el); // <-- goodbye method renaming
(function(ul) {
arr.forEach(function(text) {
setupItem(ul.appendChild(document.createElement("li")), text);
})
})(document.appendChild(document.createElement("ul")));
function setupItem(li, text) {
li.textContent = text;
li.addEventListener("click", onClick, false);
}
@aadsm
aadsm / gist:1374750
Created November 17, 2011 22:24
Object.defineProperty bug in IE10 (10.0.8102.0)
<!doctype html>
<!--
runnable version: http://jsfiddle.net/uVkHh/
Expected result:
Super.foo
foo: {
"value": "this.foo",
"writable": false,
@aadsm
aadsm / gist:1378111
Created November 18, 2011 23:39
Chrome and Safari issue creating new properties that were defined has writable: false in the prototype chain
<!doctype html>
<!--
o.foo (o.hasOwnProperty("foo") === true) shouldn't be created because o's prototype "foo" descriptor has writable === false.
According to the 5th version of Ecma-262 (http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf):
11.13.1 Simple Assignment ( = )
The production AssignmentExpression : LeftHandSideExpression = AssignmentExpression is evaluated as follows:
[...]
@aadsm
aadsm / gist:1536976
Created December 30, 2011 00:49
Marked Text gets "corrupted" when there is a matching bracket
<!doctype html>
<html>
<head>
<script src="http://codemirror.net/lib/codemirror.js"></script>
<link rel="stylesheet" href="http://codemirror.net/lib/codemirror.css">
<style>
.highlight {
background-color: yellow;
}
</style>
@aadsm
aadsm / gist:3086468
Created July 10, 2012 21:56
2-way data bindings in MontageJS
var foo = {c: 3};
var bar = {a: {b: {c: 3}}};
// define a binding between foo.c and bar.a.b.c, so when we change the
// value of any of the two paths the new value will be copied to the
// other one.
Object.defineBinding(foo, "c", {
boundObject: bar,
boundObjectPropertyPath: "a.b.c"
});
@aadsm
aadsm / gist:3088137
Created July 11, 2012 05:09
Property Change Listeners in MontageJS
var bar = {a: {b: {c: 3}}};
// we're going to listen to changes of the bar.a.b.c value
bar.addPropertyChangeListener("a.b.c", function() {
console.log("bar.a.b.c was changed to: " + bar.a.b.c);
});
bar.a.b.c = 4; // Outputs: bar.a.b.c was changed to: 4
bar.a = {b: {c: 6}}; // Outputs: bar.a.b.c was changed to: 6
bar.a.b.c = 3 + 3; // notification not fired, the value didn't change
<!-- this file should be in other.reel/other.html -->
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/montage-serialization">{
"owner": {
"properties": {
"element": {"#": "other"}
}
.range {
width: 100%;
}