Skip to content

Instantly share code, notes, and snippets.

View jthomas's full-sized avatar
💻
serverless all the things.

James Thomas jthomas

💻
serverless all the things.
View GitHub Profile
@jthomas
jthomas / gist:2966649
Created June 21, 2012 15:56
Rendering Dijit widgets server-side in NodeJs
var fs = require('fs'),
jsdom = require("jsdom").jsdom,
document = jsdom("<html><head></head><body></body></html>"),
window = document.createWindow();
// Fix window objects in global scope.
global.document = document;
global.navigator = window.navigator;
global.window = window;
@jthomas
jthomas / gist:2775152
Created May 23, 2012 13:08
Creating custom DOM events
// Register for custom events
document.addEventListener("oncustom", function () {
console.log("fired!");
});
// Createcustom DOM events and fire
var evt = document.createEvent("Event");
evt.initEvent("oncustom", true, true);
document.dispatchEvent(evt)
@jthomas
jthomas / gist:2401041
Created April 16, 2012 19:47
Authenticating user to access restricted feeds
<html>
<script src="./lib/require.js"></script>
<script>
require.config({
paths : {
//create alias to plugins (not needed if plugins are on the baseUrl)
async: 'src/async',
goog: 'src/goog',
propertyParser : 'src/propertyParser'
}
@jthomas
jthomas / gist:1891911
Created February 23, 2012 09:31
Loading AMD modules using Dojo
// This doesn't work....
define("a/b/c", function () {
// return something....
});
var mod = require("a/b/c");
// This does work...