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
angular.module('test', []) | |
.directive('ngDraggable', function($document) { | |
return { | |
restrict: 'A', | |
scope: { | |
dragOptions: '=ngDraggable' | |
}, | |
link: function(scope, elem, attr) { | |
var startX, startY, x = 0, y = 0, |
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
angular.module('APP', []) | |
.directive('collection', function () { | |
return { | |
restrict: "E", | |
replace: true, | |
scope: { | |
collection: '=' | |
}, | |
template: "<ul><member ng-repeat='member in collection' member='member'></member></ul>" |
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
function isVarName(str) { | |
'use strict'; | |
if (typeof str !== 'string') { | |
return false; | |
} | |
try { | |
new Function('var ' + str)(); | |
} catch (e) { |
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
`dropDups: true` option is not available in 3.0. | |
I have solution with aggregation framework for collecting duplicates and then removing in one go. | |
It might be somewhat slower than system level "index" changes. But it is good by considering way you want to remove duplicate documents. | |
a. Remove all documents in one go | |
var duplicates = []; | |
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
webView.loadData(html, "text/html", "UTF-8"); | |
private void print(WebView webView) { | |
try { | |
// PrintManager | |
String PRINT_SERVICE = (String) Context.class.getDeclaredField( | |
"PRINT_SERVICE").get(null); | |
Object printManager = this.getSystemService(PRINT_SERVICE); | |
// PrintDocumentAdapter |
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
//equivalent of MySQL "SELECT COUNT(*) AS `count`, `fieldName` FROM `someTable` GROUP BY `fieldName | |
db.someCollection.aggregate([{"$group" : {_id:"$fieldName", count:{$sum:1}}}]); | |
//as above but ordered by the count descending | |
db.someCollection.aggregate([{"$group" : {_id:"$fieldName", count:{$sum:1}}}, {$sort:{'count':-1}}]); |
NewerOlder