This file contains 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
// assume this is node.js/browserify land so this is actually private | |
var next_server_number = function( servers ){ | |
var current_int = 1; | |
servers = servers.sort( function( a, b ){ | |
return a - b; | |
}); | |
for( var i = 0; i < servers.length; i++ ){ | |
if( current_int === servers[i] ){ | |
current_int++; | |
} |
This file contains 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 rpc = require('rpc-stream'); | |
var engine = require('engine.io-stream'); | |
var rpc_client = rpc(); | |
var engine_stream = engine('/test'); | |
remote = rpc_client.wrap(['addMessage']); | |
engine_stream | |
.pipe( rpc_client ) |
This file contains 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 NO_OP = function(){}; | |
var domready = require('domready'); | |
var sizzle = require('sizzle'); | |
var elClass = require('element-class'); | |
var jsonp = require('jsonp'); | |
var xhr = require('xhr'); | |
var Modular = function( config ){ | |
this.url = config.url; |
This file contains 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 gulp = require('gulp'); | |
var vinylSource = require('vinyl-source-stream'); | |
var watchify = require('watchify'); | |
gulp.task( 'browserify', function(){ | |
// use watchify instead of gulp-browserify and gulp.watch | |
var bundler = watchify('./src/universe-experiment.js'); | |
bundler.transform('hbsfy'); | |
bundler.transform('uglifyify'); | |
var rebundle = function(){ |
This file contains 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 $ = require('jquery'); | |
// Set up hbsfy for Solidus feature parity | |
var Handlebars = require('hbsfy/runtime'); | |
// Pull in Handlebars helpers | |
var HandlebarsHelper = require('handlebars-helper'); | |
HandlebarsHelper.help( Handlebars ); | |
// Set partials | |
Handlebars.registerPartial( 'favorite', require('../../views/favorite.hbs') ); |
This file contains 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 getElementsByClass = function( classname ){ | |
var els_with_class = []; | |
var els = document.getElementsByTagName('*'); | |
for( var i = 0; i < els.length; i++ ){ | |
var el = els[i]; | |
if( el.className.split(' ').indexOf( classname ) > -1 ) els_with_class.push( el ); | |
} | |
return els_with_class; | |
}; |
This file contains 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 shoe = require('shoe'); | |
var through = require('through'); | |
var result = document.getElementById('result'); | |
var stream = shoe('/chat'); | |
stream.on( 'data', function( msg ){ | |
console.log( 'data', msg ); | |
}); |
This file contains 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
// Thing constructor | |
var Thing = function(){ | |
this.pies = ['cherry','apple']; | |
}; | |
Thing.prototype = {}; | |
Object.defineProperties( Thing.prototype, { | |
piescount: { | |
get: function(){ return this.pies.length; } |
This file contains 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 convertOffset = function( offset ){ | |
if( typeof offset !== 'string' ) return; | |
var hours = parseInt( offset.substr( -4, 2 ), 10 ); | |
var minutes = parseInt( offset.substr( -2, 2 ), 10 ); | |
var negative = ( offset.substr( -5, 1 ) === '-' ); | |
var offset_in_minutes = hours * 60 + minutes; | |
if( negative ) offset_in_minutes = offset_in_minutes * -1; | |
return offset_in_minutes; | |
}; |
This file contains 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
{ | |
"storyteller": { | |
"headers": { | |
"Api-Key": "e801cf0a-ee44-42d3-a29f-aff82fd0521b" | |
} | |
} | |
} |