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
| /** | |
| * Gera expressão regular para endereços de api | |
| * | |
| * @param string endereco | |
| * @returns object | |
| **/ | |
| function at(endereco){ | |
| return new RegExp('^'+endereco.replace(/\//g, '\\/')+'(\\/.+|\\/$|$)'); | |
| } |
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
| // context | |
| var mongoose = require('mongoose'); | |
| mongoose.connect('mongodb://...'); | |
| /** | |
| * Generates Mongoose uniqueness validator | |
| * | |
| * @param string modelName | |
| * @param string field | |
| * @param boolean caseSensitive |
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
| /* | |
| * https://groups.google.com/forum/?fromgroups=#!topic/angular/suCtNH10M2U | |
| * | |
| * <p ng-repeat="campo in campos"> | |
| * <label>{{campo.label}}</label> | |
| * <input ng-name="campo.name" /> | |
| * </p> | |
| * | |
| * formName[fieldName].$error.required | |
| */ |
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
| /* | |
| * <select get-remote="http://path/to/users.json as users"> | |
| * <option ng-repeat="user in users" ng-value="user.id">{{user.name}}</option> | |
| * </select> | |
| */ | |
| .directive('getRemote', function ($http) { | |
| return { | |
| restrict: 'A', | |
| link: function ($scope, $element, $attrs) { | |
| var pars = $attrs.getRemote.toLowerCase().split(' as '); |
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
| /** | |
| * {{ 'October 13, 1975 11:13:00' | toDate }} | |
| * {{ 'October 13, 1975 11:13:00' | toDate:'yyyy-MM-ddTHH:mm:ss.SSSZ' }} | |
| */ | |
| .filter('toDate', function ($filter) { | |
| return function(input, format) { | |
| format = format || 'medium'; | |
| return $filter('date')(new Date(input), format); | |
| }; | |
| }) |
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
| .directive('popover', ['$compile', function($compile){ | |
| return { | |
| restrict: 'E', | |
| link: function ($scope, $element, $attrs) { | |
| var triggerSelector = $attrs.triggerSelector || '[popover-trigger], [data-popover-trigger], [x-popover-trigger], .popover-trigger, .x-popover-trigger'; | |
| var elTrigger = $element.find(triggerSelector).first(); | |
| var triggerHTML = elTrigger.clone().wrap('<div>').parent().html(); | |
| elTrigger.remove(); | |
| var triggerElement = $compile(triggerHTML)($scope); | |
| $element.replaceWith(triggerElement); |
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
| .directive('timePicker', function($compile) { | |
| var range = function(qtd) { | |
| var arr = []; | |
| for(var i=0;i<qtd;i++) | |
| arr.push(i<10?'0'+i:''+i); | |
| return arr; | |
| }; | |
| var timePickerHoras = range(24); | |
| var timePickerMinutos = range(60); | |
| return { |
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
| // obtém pacote nos paths específicos | |
| var requireAt = function requireAt(packageName, paths) { | |
| // armazena paths originais deste ambiente, preservando-os | |
| var originalPaths = module.paths; | |
| // define paths para este ambiente, sobreescrevendo atuais | |
| module.paths = paths; | |
| // obtém modulo nos paths deste beat |
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
| // motor | |
| function Motor(hp){ | |
| this.hp = hp; | |
| this.rotacoes = 0; | |
| console.log('criou novo motor:', this); | |
| } | |
| Motor.prototype.liga = function(){ | |
| this.rotacoes = 2000; | |
| console.log('ligou o motor:', this); | |
| }; |
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 dados = [ | |
| ['Nome', 'Sobrenome', 'Profissão'], | |
| ['Paula', 'Tejando', 'Adivinha' ], | |
| ['Cuca', 'Beludo', 'Padeiro' ], | |
| ['Thomas', 'Turbano', 'Popeye' ] | |
| ]; | |
| var csv = dados.map(function(linha){ | |
| return linha.map(function(celula){ | |
| return '"'+(celula.replace(/\"/g, '\"').replace(/\r/g, '\\r'))+'"'; |