Skip to content

Instantly share code, notes, and snippets.

View rwaldron's full-sized avatar

Rick Waldron rwaldron

  • Boston, MA
View GitHub Profile
@rwaldron
rwaldron / var-indenting.js
Created April 29, 2011 02:33 — forked from cowboy/var-indenting.js
JavaScript var indenting thoughts.
// 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 = {
@rwaldron
rwaldron / module_pattern_init.js
Created April 28, 2011 01:40 — forked from nathansmith/module_pattern_init.js
Init + Module Pattern JS
//
// 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.
//*******************************************
// 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
// 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
// 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
@rwaldron
rwaldron / def.js
Created March 22, 2011 01:37 — forked from tbtlr/def.js
/*
* 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;
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();
@rwaldron
rwaldron / pp.js
Created March 19, 2011 17:30 — forked from voodootikigod/pp.js
function pp (t) {
if (typeof console == "object" && typeof console.log == "function")
console.log(t);
else
print(t);
}
@rwaldron
rwaldron / here.js
Created March 16, 2011 21:53 — forked from wycats/here.js
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) }")
<!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 -->