This file contains 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
:reg + | |
--- Registers --- | |
"+ has("gui_running") | |
Press ENTER or type command to continue |
This file contains 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 cheerio = require('cheerio'); | |
var request = require('request'); | |
request.get('http://gshow.globo.com/programas/na-moral/videos/feed.atom', function(err, headers, body){ | |
if(err) | |
throw err; | |
if(headers.statusCode !== 200) | |
throw new Error('Resposta não OK.'); |
This file contains 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
// Definindo uma função no escopo global | |
global.somar = function(a, b){ | |
return a + b; | |
}; | |
// Agora em qualquer lugar do seu projeto, dentro do mesmo | |
// processo, você pode chamar esta função | |
var total = somar(1 + 2); | |
console.log(total); // 3 |
This file contains 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
alan@sweet:~/Projetos/teste/ntp$ dig pool.ntp.br | |
; <<>> DiG 9.9.3-rpz2+rl.13214.22-P2-Ubuntu-1:9.9.3.dfsg.P2-4ubuntu1.1 <<>> pool.ntp.br | |
;; global options: +cmd | |
;; Got answer: | |
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17223 | |
;; flags: qr rd ra; QUERY: 1, ANSWER: 7, AUTHORITY: 0, ADDITIONAL: 1 | |
;; OPT PSEUDOSECTION: | |
; EDNS: version: 0, flags:; udp: 4000 |
This file contains 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 tamanho = 1024 * 1024 * 100; //100mb | |
var text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus.\n' + | |
' Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante \n' + | |
'hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet \n' + | |
'vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut \n' + | |
'libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur \n' + | |
'adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, \n' + | |
'adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur \n' + | |
'dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero \n' + |
This file contains 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 cheerio = require('cheerio'); | |
var request = require('request'); | |
var url = 'http://www.americanas.com.br/produto/7112345/geladeira-refrigerador-frost-free-brastemp-clean-brm39-352-litros-inox'; | |
request.get(url, function(err, res, body){ | |
if(err) | |
throw err; | |
if(res.statusCode !== 200) | |
throw new Error('Resporta não OK ' + res.statusCode); |
This file contains 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 express = require('express'); | |
var db = require('./db'); | |
var app = express(); | |
app.get('/api/games', function(req, res){ | |
db.collection('games').find().toArray(function(err, docs){ | |
if(err) | |
throw err; | |
// resṕondemos com todos os games encontrados |
This file contains 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 db = require(__dirname + '/../lib/mongodb'); | |
var async = require('async'); | |
var slug = require('slug'); | |
var mongo = require('mongodb'); | |
var ObjectID = require('mongodb').ObjectID; | |
// Dados dos campos para comversão | |
var database = 'minhaApp'; | |
var from = 'titulo'; // O nome do campo que terá seu valor sluguificado | |
var to = 'slug'; // O nome do campo para guardar o slug no documento |
This file contains 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 mongodb = require('mongodb'); | |
var config = require(__dirname + '/../config/general.json'); | |
var db = null; | |
mongodb.MongoClient.connect(config.mongodb, function(err, database) { | |
if(err) | |
throw err; | |
db = database; | |
process.emit('dbready'); |
This file contains 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 mongodb = require('mongodb'); | |
var config = require(__dirname + '/../config/general.json'); | |
var db = null; | |
mongodb.MongoClient.connect(config.mongodb, function(err, database) { | |
if(err) | |
throw err; | |
db = database; | |
process.emit('dbready'); |
OlderNewer