#A simple Slideshow module wrapped in a Backbone View
- Dependencies ** underscore.js ** backbone.js
Viewable in action in this jsfiddle
// | |
// Super simple base64 encoding / decoding with node.js | |
// | |
var base64 = exports = { | |
encode: function (unencoded) { | |
return new Buffer(unencoded).toString('base64'); | |
}, | |
decode: function (encoded) { | |
return new Buffer(encoded, 'base64').toString('utf8'); |
#A simple Slideshow module wrapped in a Backbone View
Viewable in action in this jsfiddle
This example expects to have d3.min.js and d3.layout.min.js in the same directory as pie.js and pie_serv.js. | |
Run with node pie_serv.js |
Get the Heroku db as detailed here: | |
http://devcenter.heroku.com/articles/pgbackups#exporting_via_a_backup | |
1. heroku pgbackups:capture | |
2. heroku pgbackups:url <backup_num> #=>backup_url | |
- get backup_num with cmd "heroku pgbackups" | |
3. curl -o latest.dump <backup_url> | |
Then locally do: | |
$ pg_restore --verbose --clean --no-acl --no-owner -h localhost -U myuser -d mydb latest.dump |
/* | |
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js | |
*/ | |
var http = require('http'), | |
fs = require('fs'), | |
util = require('util'); | |
http.createServer(function (req, res) { | |
var path = 'video.mp4'; |
"use strict"; | |
var Q = require("q"); | |
module.exports = function fromEventEmitter(ee) { | |
var deferred = Q.defer(); | |
ee.on("success", deferred.resolve); | |
ee.on("error", deferred.reject); | |
return deferred.promise; |
init: function() { | |
var view = this; | |
var resizeHandler = function() { | |
view.rerender(); | |
}; | |
this.set('resizeHandler', resizeHandler); | |
$(window).bind('resize', this.get('resizeHandler')); | |
}, |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using Raven.Abstractions.Data; | |
using Raven.Abstractions.Indexing; | |
using Raven.Client.Bundles.MoreLikeThis; | |
using Raven.Client.Indexes; | |
using Raven.Json.Linq; | |
using Xunit; |
# | |
# blob : Object from MongoDB | |
# | |
# blob.body: Buffer | |
# blob.size: length of buffer, substitute for blob.body.length | |
# blob.type: MIME (Eg. audio/x-wav) | |
# | |
# req : Object from http | |
# res : Object from http | |
# _ : Object from underscore |
The question: how can we use ES6 modules in Node.js, where modules-as-functions is very common? That is, given a future in which V8 supports ES6 modules:
export
syntax, without breaking consumers that do require("function-module")()
?import
syntax, while not demanding that the module author rewrites his code to ES6 export
?@wycats showed me a solution. It involves hooking into the loader API to do some rewriting, and using a distinguished name for the single export.
This is me eating crow for lots of false statements I've made all over Twitter today. Here it goes.