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
// I don't have answers yet, just questions. Keep in mind that I prefer code | |
// that is easiest to maintain. | |
// Example from http://www.nczonline.net/blog/2010/10/26/wanted-dynamic-execution-contexts-in-javascript/ | |
// Consider: | |
// Let's say you start with this, but need to (in a later commit) add a few | |
// additional vars. | |
var myglobal = { |
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
// | |
// Module pattern: | |
// http://yuiblog.com/blog/2007/06/12/module-pattern | |
// | |
var APP = (function(window, document, $, undefined) { | |
// For use only inside APP. | |
var PRIVATE_CONSTANT_1 = 'foo'; | |
var PRIVATE_CONSTANT_2 = 'bar'; | |
// Expose contents of APP. |
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
//******************************************* | |
// Level 1, basic API, minimum support | |
//******************************************* | |
/* | |
Modules IDs are strings that follow CommonJS | |
module names. | |
*/ | |
//To load code at the top level JS file, | |
//or inside a module to dynamically fetch |
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
// Popcorn Instance Methods | |
var p = Popcorn( "#video" ) | |
p.play() | |
// Play the video (Native "pass through" method) | |
// Returns the Popcorn instance object | |
p.load() | |
// Load the video (Native "pass through" method) | |
// Returns the Popcorn instance object |
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
// Popcorn Instance Methods | |
var p = Popcorn( "#video" ) | |
p.play() | |
// Play the video (Native "pass through" method) | |
// Returns the Popcorn instance object | |
p.load() | |
// Load the video (Native "pass through" method) | |
// Returns the Popcorn instance object |
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
/* | |
* def.js: Simple Ruby-style inheritance for JavaScript | |
* | |
* Copyright (c) 2010 Tobias Schneider | |
* This script is freely distributable under the terms of the MIT license. | |
*/ | |
(function(global) { | |
__super__ = function(){ | |
var caller = __super__.caller; |
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 SerialPort = require("./serialport") | |
var sp = new SerialPort("/dev/ttyUSB0") | |
sp.write("OMG USB"); | |
// Reading is not perfect yet | |
sp.on('data', function(data) { | |
sys.puts("data"); | |
}); | |
sp.close(); |
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
function pp (t) { | |
if (typeof console == "object" && typeof console.log == "function") | |
console.log(t); | |
else | |
print(t); | |
} |
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
v8 = V8::Context.new | |
v8["foo"] = proc do |hello| | |
# can I get the JS callstack here? | |
puts hello | |
end | |
v8.eval("function bar() { baz('sven' )}; function baz(name) { foo(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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" | |
"http://www.w3.org/TR/html4/strict.dtd"> | |
<html lang="en"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>Text Editor</title> | |
<meta name="generator" content="TextMate http://macromates.com/"> | |
<meta name="author" content="Peter Wagenet"> | |
<!-- Date: 2010-05-12 --> |