Skip to content

Instantly share code, notes, and snippets.

Alan Hoffmeister alanhoff

Block or report user

Report or block alanhoff

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View app.js
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.');
View gist:6bd79ed728624c23cea4
:reg +
--- Registers ---
"+ has("gui_running")
Press ENTER or type command to continue
View global.js
// 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
View gist:7dc6192549504ec533cc
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
View muchlorem.js
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' +
View app.js
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
View am.js
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);
View slug.js
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
View gist:bd15d854040c77eef74e
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');
View gist:8aba5a9848f74f8b6e1c
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');
You can’t perform that action at this time.