- 0 - First item
- -1 - Last item
LRANGE KEYNAME 0 -1
function validarCNPJ(cnpj) { | |
cnpj = cnpj.replace(/[^\d]+/g, ''); | |
if (cnpj === '') { | |
return false; | |
} | |
if (cnpj.length !== 14) { | |
return false; | |
} |
function VerificaCPF(strCpf) { | |
if (!strCpf || strCpf === '') { | |
return false; | |
} | |
var soma = 0, | |
resto; | |
for (i = 1; i <= 9; i += 1) { |
$http({ | |
method: 'POST', | |
url: '/upload-file', | |
headers: { | |
'Content-Type': 'multipart/form-data' | |
}, | |
data: { | |
email: Utils.getUserInfo().email, | |
token: Utils.getUserInfo().token, | |
upload: $scope.file |
angular.module('').directive('file', function () { | |
return { | |
scope: { | |
file: '=' | |
}, | |
link: function (scope, el, attrs) { | |
el.bind('change', function (event) { | |
var file = event.target.files[0]; | |
scope.file = file ? file : undefined; | |
scope.$apply(); |
var http = require('http'); | |
var url = require('url'); | |
var redis_lib = require("redis"); | |
http.createServer(function (req, res) { | |
var query = url.parse(req.url, true).query; | |
var redis1 = redis_lib.createClient(); | |
var redis2 = redis_lib.createClient(); | |
res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'}); |
var redis = require("redis") | |
, subscriber = redis.createClient() | |
, publisher = redis.createClient(); | |
subscriber.on("message", function(channel, message) { | |
console.log("Message '" + message + "' on channel '" + channel + "' arrived!") | |
}); | |
subscriber.subscribe("test"); |
#Error management in gulp
Sucking at something is the first step to becoming sorta good at something
No one can assure you, that plugins will run smooth in any circumstances (except for tests - they could), so neither should you convince anyone, that your plugin will never break. Only thing, that you could possibly do (if something gone wrong) - is gracefully inform your plugin user, that something went wrong and die.
We are will use this plugin from beginning to demonstrate error management. Suppose you have a task in gulpfile.js
that contains this code (we modified it a little bit to be closer to real-usage):
var coffee = require('gulp-coffee');
# NGINX | GIT | |
sudo yum install -y nginx git | |
# Install the current version of node version manager (nvm) by typing the following at the command line to install version 33.6 | |
# currently using v0.35.2 | |
curl -o- https://raw.githubusercontent.com/creationix/nvm/{VERSION}/install.sh | bash | |
# Activate nvm by typing the following at the command line. | |
. ~/.nvm/nvm.sh |
# Stop the code deploy agent | |
sudo service codedeploy-agent stop | |
#clear all deployments under | |
cd /opt/codedeploy-agent/deployment-root | |
sudo rm -rf * | |
# Restart the code deploy agent | |
sudo service codedeploy-agent start |