Skip to content

Instantly share code, notes, and snippets.

var stream = require("stream")
getSourceStreamThatThrowsError().
on("error", console.error.bind(null, "source stream")).
pipe(getDestinationStreamThatThrowsError()).
on("error", console.error.bind(null, "dest stream"))
function getSourceStreamThatThrowsError() {
var rs = new stream.Readable
var fs = require('fs'),
gcloud = require('gcloud'),
knox = require('knox'),
path = require('path'),
ProgressBar = require('progress'),
RSVP = require('rsvp'),
tar = require('tar'),
through = require('through2'),
uuid = require('uuid'),
zlib = require('zlib');
@stephenplusplus
stephenplusplus / bucket.js
Created March 3, 2015 16:25
Make public / private
Bucket.prototype.makePublic = function(options, callback) {
var self = this;
if (util.is(options, 'function')) {
callback = options;
options = {};
}
// Allow public to read bucket contents while preserving original permissions.
this.acl.add({
{
"GAE_MODULE_VERSION": "18",
"npm_config_cache_lock_stale": "60000",
"API_PORT": "65435",
"npm_config_sign_git_tag": "",
"npm_package_dependencies_multiparty": "^3.3.2",
"npm_config_user_agent": "npm/1.4.28 node/v0.10.33 linux x64",
"npm_config_always_auth": "",
"npm_config_bin_links": "true",
"npm_config_key": "",
@stephenplusplus
stephenplusplus / subscribe.js
Last active August 29, 2015 14:23
gcloud subscription
'use strict';
var topicName = 'book-process-queue';
var subscriptionName = 'shared-worker-subscription';
var creatingSubscription = false;
var subscription;
var onMessageHandlers = [];
module.exports = function() {
@stephenplusplus
stephenplusplus / 0.md
Last active August 29, 2015 14:27
Measuring how different stream approaches perform
@stephenplusplus
stephenplusplus / npm-package-info.js
Created September 2, 2015 01:59
npm-package-info.js
'use strict';
var Q = require('q');
var packageJson = require('package-json');
var log = process.env.LOGGER || console;
module.exports = function (list) {
log.info('Fetching package info for %s packages', list.length);
@stephenplusplus
stephenplusplus / model.js
Last active October 20, 2015 18:44
firebase model
{
// PRIVATE DASHBOARDS:
"${projectId}:${userId}": {
"${dashboardId}": {
"modified": new Date(),
"plugins": [
{
"title": "Storage Browser",
"state": "storage-browser",
@stephenplusplus
stephenplusplus / proto-builder.js
Created October 27, 2015 18:13
proto-builder
#!/usr/bin/env node
'use strict';
var fs = require('fs');
var pbjs = require('protobufjs');
var commonJsExporter = require('protobufjs/cli/pbjs/targets/commonjs');
function build(protoFilePath, destinationJsFile) {
var fileContents = fs.readFileSync(datastoreProtoFile, 'utf-8');
'use strict';
var fs = require('fs');
var gcloud = require('gcloud');
var gcs = gcloud.storage({
projectId: 'nth-circlet-705',
keyFilename: '/Users/stephen/dev/keyfile.json'
});