This file contains hidden or 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
| //calculate aspect ratio | |
| // Via: http://stackoverflow.com/questions/1186414/whats-the-algorithm-to-calculate-aspect-ratio-i-need-an-output-like-43-169 | |
| function gcd (a, b) { | |
| return (b == 0) ? a : gcd (b, a%b); | |
| } | |
| var w = screen.width; | |
| var h = screen.height; | |
| var r = gcd (w, h); | |
| console.log("Dimensions = " + w + " x " + h); |
This file contains hidden or 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
| module.exports = function(Model, options) { | |
| // Model is the model class | |
| // options is an object containing the config properties from model definition | |
| Model.defineProperty('created', {type: Date, default: '$now'}); | |
| Model.defineProperty('modified', {type: Date, default: '$now'}); | |
| } |
This file contains hidden or 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 FILTERED_PROPERTIES = ['createdAt', 'updatedAt']; | |
| Model.observe('before save', function filterProperties(ctx, next) { | |
| if (ctx.options && ctx.options.skipPropertyFilter) return next(); | |
| if (ctx.instance) { | |
| FILTERED_PROPERTIES.forEach(function(p) { ctx.instance.unsetAttribute(p); }); | |
| } else { | |
| FILTERED_PROPERTIES.forEach(function(p) { delete ctx.data[p]; }); | |
| } | |
| next(); | |
| }); |
This file contains hidden or 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
| module.exports = function(Place) { | |
| Place.nearby = function(here,cb){ | |
| Place.find({where: {location: {near: here}}, limit:3}, function(err, nearbyPlaces) { | |
| cb(null, nearbyPlaces); | |
| }); | |
| }; | |
| Place.remoteMethod('nearby', { | |
| accepts: [ | |
| {arg: 'here', type: 'GeoPoint', required: true, description: 'geo location (lat & lng)'} |
This file contains hidden or 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
| // App/Services/Normalizer.js | |
| import { Schema, arrayOf, normalize } from 'normalizr' | |
| import { camelizeKeys } from 'humps' | |
| const normalizer = (data, schema) => { | |
| const camelizedJson = camelizeKeys(data) | |
| return normalize(camelizedJson, schema) | |
| } |
This file contains hidden or 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
| // server/boot/authentication.js | |
| server.middleware('auth', loopback.token({ | |
| model: server.models.accessToken, | |
| currentUserLiteral: 'me' | |
| })); |
This file contains hidden or 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
| // common/models/model.js | |
| app.models.Model.beforeRemote('create', function(ctx, modelInstance, next) { | |
| ctx.args.data.userId = ctx.req.accessToken.userId; | |
| next(); | |
| }); |
This file contains hidden or 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
| npm install --save passport-facebook-token | |
| Then add this entry in providers.json: | |
| "facebook-mobile" : { | |
| "provider": "facebook-token", | |
| "module": "passport-facebook-token", | |
| "strategy": "FacebookTokenStrategy", | |
| "clientID": "XXXXXXX", | |
| "clientSecret": "XXXXXXX", | |
| "callbackPath": "/auth/facebook-token/callback", |
This file contains hidden or 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 express = require('express'); | |
| var app = express(); | |
| var url = "https://username.jsreportonline.net/"; | |
| var client = require("jsreport-client")(url, "[email protected]", "password"); | |
| app.get('/', function (req, res) { | |
| res.send('Go to /report or /base64'); |
OlderNewer