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 request = require('request'); | |
| var cheerio = require('cheerio'); | |
| // use [] ao invés de Array() | |
| var posts = []; | |
| // Iniciando o request principal | |
| request('http://www.hardmob.com.br/promocoes', function teste(error, response, html) { | |
| if (error || response.statusCode !== 200) | |
| throw error | new Error('status code ', + response.statusCode); |
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 http = require('http'); | |
| var path = require('path'); | |
| var url = require('url'); | |
| // Pegando a imagem na internet | |
| http.get(url.parse(process.argv[2]), function(res){ | |
| var img = ''; | |
| res.on('data', function(buff){ | |
| img += buff.toString('base64'); |
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
| <!doctype html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Centralizando divs</title> | |
| </head> | |
| <body> | |
| <div id="youtube" style="width: 560px; height: 315px;"> | |
| <iframe width="560" height="315" src="//www.youtube.com/embed/DDpSUqjtrRk?rel=0" frameborder="0" allowfullscreen></iframe> | |
| </div> |
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 gulp = require('gulp'); | |
| var connect = require('gulp-connect'); | |
| var livereload = require('gulp-livereload'); | |
| var watch = require('gulp-watch'); | |
| gulp.task('connect', function() { | |
| connect.server({ | |
| root : __dirname | |
| }); | |
| }); |
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
| #!/bin/bash | |
| git add . --all | |
| git commit -am "$2" | |
| git push $1 master |
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 fs = require('fs'); | |
| var speed = require('./speedometer'); | |
| var write = fs.createWriteStream('./dump.bin'); | |
| var read = fs.createReadStream('/dev/urandom'); | |
| var measure = speed(write, 1000); | |
| measure.on('speed', function(bytes){ | |
| console.log(bytes + ' bytes per seconds'); | |
| }); |
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-marked v0.0.1 | |
| * (c) 2013 J. Harshbarger | |
| * License: MIT | |
| */ | |
| /* jshint undef: true, unused: true */ | |
| /* global angular:true */ | |
| /* global marked:true */ |
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 text = 'Seitan XOXO meh cornhole, before they sold out mustache scenester photo booth. IPhone selvage Pitchfork aesthetic. Polaroid post-ironic Thundercats quinoa, roof party PBR mumblecore cred +1 semiotics scenester freegan organic Godard. Cred Banksy meggings actually, Helvetica kogi gluten-free fap ethical slow-carb flexitarian before they sold out four loko. Fixie ugh yr single-origin coffee mustache. Mumblecore cardigan Helvetica mlkshk iPhone. Biodiesel synth pug Banksy mustache food truck McSweeney\'s, Intelligentsia post-ironic whatever ethnic dreamcatcher.'; | |
| var cut = function(text, max, delimiter){ | |
| return text.split(' ').reduce(function(arr, word){ | |
| if(!Array.isArray(arr)) | |
| arr = [new Buffer(arr)]; | |
| if(Buffer.concat([arr[arr.length -1], new Buffer(' ' + word)]).length > max) | |
| arr.push(new Buffer(word)); | |
| else |
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 download = require('./lib/download'); | |
| download('http://meuarquivolocodedoido.com.br/arquivo.txt', './downloads') | |
| .then(function(id){ | |
| console.log('Arquivo gravado com id %s', id); | |
| }) | |
| .catch(function(err){ | |
| console.log('Deu pau..'); | |
| console.log(err.stack); | |
| }); |
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 httpProxy = require('http-proxy'); | |
| var http = require('http'); | |
| var domain = require('domain'); | |
| var proxy = httpProxy.createProxyServer(); | |
| // Criamos um server normal para escutar na porta 80 | |
| var server = http.createServer(); | |
| // Um objeto com o nome dos domínios que podemos | |
| // redirecionar. |