Skip to content

Instantly share code, notes, and snippets.

@remotevision
remotevision / grant.client_credentials.js
Created January 16, 2017 21:12
loopback-component-oauth2 not working
/* /server/test/grant.client_credentials.js */
'use strict';
/* jshint camelcase: false */
var chai = require('chai');
chai.should();
var loopback = require('loopback');
var app = require('../server/server');
var request = require('supertest')('https://localhost:3000');
info: Welcome to Nodejitsu remotevision
info: jitsu v0.13.3, node v0.9.6
info: It worked if it ends with Nodejitsu ok
warn: You are using unstable version of node.js. You may experience problems.
info: Executing command tokens create shared
info: Creating a token for remotevision
error: Error running command tokens create shared
error: Nodejitsu Error (401): Not Authorized
help: For help with this error contact Nodejitsu Support:
help: webchat: <http://webchat.nodejitsu.com/>
{
"name": "bandwango-node",
"version": "0.0.0",
"main": "./static/admin/index.html",
"ignore": [
"**/.*",
"node_modules",
"./static/admin/components"
],
"devDependencies": {
{
"name": "bandwango",
"subdomain": "bandwango",
"scripts": {
"start": "bower install && grunt && node app.js",
"test": "mocha"
},
"version": "0.0.1-20",
"engines": {
"node": "0.8.x"
@remotevision
remotevision / gist:8923118
Created February 10, 2014 20:03
jitsu deploy
info: Creating snapshot 0.0.1-30
info Uploading: [=============================] 100%
info: Updating app bandwango
info: Activating snapshot 0.0.1-30 for bandwango
info: Starting app bandwango
error: Error running command deploy
error: Errors occured while starting the application
error: Error starting application. This could be a user error.
error: info: Running start for app.
error: info: Cleaning /opt/run
@remotevision
remotevision / gist:8923029
Created February 10, 2014 19:57
Package.json
{
"name": "bandwango",
"subdomain": "bandwango",
"scripts": {
"start": "node app.js",
"test": "mocha"
},
"version": "0.0.1-30",
"engines": {
"node": "0.8.x"
// images = [{ name: 'image name', data: [data or data url] }]
(function($) {
$.imageUrl = function(images, key) {
var imageObject = $.grep(images, function(e){ return e.name == key; });
if(imageObject.length > 0) {
return imageObject[0].data;
} else {
return null;
@remotevision
remotevision / store_images
Created October 5, 2013 00:15
Store array of images and return name, url for each
exports.storeImages = function(images, metadata, callback){
try {
if(!images) callback([]);
if(images.length == 0) callback([]);
var schema = {owner: String};
gridfstore.register('bandwango', schema);
var results = [];
@remotevision
remotevision / not working in browser
Last active December 23, 2015 23:09
Base64 image in GridFS
////////////////////////////
// Doesn't work in browser
// expecting image to be displayed (no html)
////////////////////////////
// generic images route
server.get(version+'/images/:id', function(req, res) {
gridfstore.read( req.params.id, function(error,data) {
var img = new Buffer(data.buffer, 'base64');
[2013-02-19T01:24:32.855Z] TRACE: restify/86380 on ryan.local: running pre chain (req.remoteAddress=127.0.0.1, req.remotePort=54533)
OPTIONS /deliveryMethods/51204d5ceaf649f325000007 HTTP/1.1
host: localhost:3000
connection: keep-alive
access-control-request-method: PUT
origin: http://localhost:3001
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17
access-control-request-headers: accept, origin, content-type
accept: */*
referer: http://localhost:3001/