Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

{
"error": "Bad Request",
"message": "the length of name must be at least 3 characters long",
"statusCode": 400,
"validation": {
"keys": [
"name"
],
"source": "params"
}
@alanhoff
alanhoff / hapi-upload.js
Last active August 29, 2015 14:06
Recebendo uploads com Hapi.js
server.route({
method: 'POST',
path: '/submit',
config: {
payload: {
output: 'file', // Vamos receber arquivos
parse: true, // Fazer o parse dos campos
allow: 'multipart/form-data' // Só podemos receber forms
maxBytes: 10000000 // Limite de 10MB,
@alanhoff
alanhoff / teste.js
Last active August 29, 2015 14:06 — forked from thebergamo/teste.js
var file = __dirname + '/../upload/'+ req.payload.code+'.jpg';
fs.exists(file, function(exists){
if(!exists)
return res(Boom.notFound('Image not found'));
res.file(file);
});
sudo apt-get install automake build-essential git gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg-turbo8-dev libpng12-dev libwebp-dev libtiff5-dev libexif-dev libxml2-dev swig libmagickwand-dev
git clone https://github.com/jcupitt/libvips.git
cd libvips
git checkout 7.38
./bootstrap.sh
./configure --enable-debug=no --enable-cxx=yes --without-python --without-orc --without-fftw
make
sudo make install
sudo ldconfig
var net = require('net');
var HOST = '127.0.0.1';
var PORT = 8080;
var client = new net.Socket();
client.connect(PORT, HOST, function() {
console.log('CONNECTED TO: ' + HOST + ':' + PORT);
// Write a message to the socket as soon as the client is connected,
var net = require('net');
var buffertools = require('buffertools').extend();
var delimitador = new Buffer('\r\n');
var server = net.createServer(function(socket){
console.log('Socket conectado.');
var buffer = new Buffer(0);
socket.on(data, function(buff){
// Acrescentamos os dados ao buffer
@alanhoff
alanhoff / loglib.js
Created September 9, 2014 12:38
Encapsulamento
// Faz o no terminal de acordo com o contexto do log
module.exports = function(contexto){
return {
error: function(texto){
console.error('%s %s', contexto, texto);
},
log: function(texto){
console.log('%s %s', contexto, texto);
}
}
function handler(request, response){
if(request.url !== '/socket.io/socket.io.js')
fileServer.serve(request, response);
}
@alanhoff
alanhoff / node.md
Created August 19, 2014 13:40
Node.js para frontenders

Programas em Node.js úteis para frontenders:

  • Grunt.js
  • Gulp
  • Slush
  • Bower
  • JSHint
  • node-static
  • Browserify
  • LiveReload
{<body}
bla bla bla
{/body}
{<footer}
<script type="text/javascript">
console.log('jQuey definido?', $);
</script>
{/footer}