- Use one-time-bind on expressions ( {{::value}} )
- Replace
$scope.$apply()
with$scope.$digest()
whenever possible - Move filters to controllers
To get the total watchers on the current page, you can run this script on the browser console:
$scope.$apply()
with $scope.$digest()
whenever possibleTo get the total watchers on the current page, you can run this script on the browser console:
var dbUrl = 'mongodb://username:[email protected]:port/database-name'; | |
MongoClient.connect( | |
dbUrl, | |
function(err, db) { | |
if(err) throw err; | |
db.collection('ItemModel').find({}).toArray(function(err, docs) { | |
console.dir(docs); | |
console.dir(docs.length); | |
db.close(); | |
}); |
# https://github.com/docker/docker/issues/1799 | |
RUN echo "module.exports={\n\ | |
x:{\n\ | |
arg1:'${arg1}'\n\ | |
},\n\ | |
a:{\n\ | |
b:{\n\ | |
c:{\n\ | |
d:{\n\ | |
arg2:'${arg2}'\n\ |
angular | |
.module('myApp', [ | |
'ui.router', | |
'lbServices', | |
'ngStorage' | |
]) | |
.run([ | |
'$rootScope', '$state', 'LoopBackAuth', | |
function ($rootScope, $state, LoopBackAuth) { | |
$rootScope.$on('$stateChangeStart', function (event, toState, toParams) { |
var loopbackUtils = require('loopback/lib/utils'); // handle both callbacks and promise based invocations | |
module.exports = function(MyModel) { | |
MyModel.remoteMethod('generateToken', { | |
accepts: [ | |
{arg: 'id', type: 'string', required: true} | |
], | |
http: {path: '/:id/generateToken', verb: 'get'} | |
}); |
// it resides in `/server/boot/` directory | |
'use strict'; | |
var path = require('path'); | |
var fileName = path.basename(__filename, '.js'); // gives the filename without the .js extension | |
var log = require('debug')('boot:'+fileName); | |
module.exports = function(app) { | |
var Role = app.models.Role; |
/** A quick github search for sample code: | |
* > https://github.com/search?utf8=%E2%9C%93&q=-1+AccessToken.create+path%3A%2Fcommon%2Fmodels&type=Code&ref=searchresults | |
* Yields two similar result: | |
* > https://github.com/patriciamolina/test/blob/90a8829728e4a404109e1eafa0a1075687042792/common/models/customer.js#L421 | |
* > https://github.com/stormpath/loopback-stormpath/blob/e1cb4d98eacfe36ade2d58e1a48e6cfd590308ff/common/models/stormpath-user.js#L458 | |
*/ | |
module.exports = function(SellerModel) { | |
SellerModel.observe('after save', function(ctx, next) { | |
console.log('`after save` supports isNewInstance?', ctx.isNewInstance !== undefined); |
//require('log-prefix')(function() { return '[' + Date.now() + '] %s'; });
// prints: [1465008912650] ...
//require('log-prefix')(function() { return '[' + new Date().toISOString() + '] %s'; });
// prints: [2016-06-04T02:54:36.488Z] ...
//require('log-prefix')(function() { return '[' + new Date().toUTCString() + '] %s'; });
// prints: [Sat, 04 Jun 2016 02:53:26 GMT] ...
@pulkitsinghal here’s a gist of the core of it all:
https://gist.github.com/doublemarked/e4bf329d11c55baf468f
@pulkitsinghal this will log access tokens with all log messages.
Bunyan produces JSON, so you’re essentially going to need to parse
the log to fish out things, but JSON makes it easy to do that.
For simple things (like access tokens) you can also use grep
'use strict'; | |
var loopback = require('loopback'); | |
var Promise = require('bluebird'); | |
var path = require('path'); | |
var fileName = path.basename(__filename, '.js'); // gives the filename without the .js extension | |
var log = require('debug')('common:models:'+fileName); | |
//var logger = require('./../lib/logger')('common:models:'+fileName); |