Skip to content

Instantly share code, notes, and snippets.

View thebergamo's full-sized avatar
🤟

Marcos Bérgamo thebergamo

🤟
View GitHub Profile
@thebergamo
thebergamo / heranca.js
Created June 24, 2014 12:59
Herança JS
function Animal() {
}
Animal.prototype.nascer = function() {
// ...
}
Animal.prototype.morrer = function() {
// ...
}
Animal.prototype.respirar = function() {
// ...
@thebergamo
thebergamo / recursividade.js
Last active August 29, 2015 14:02
recursividade.js
files = ['a.txt', 'j.txt'];
ret = "";
function concatFiles(file, ret){
shifted = file.shift();
if(!shifted){
console.log(ret);
return;
}
### Keybase proof
I hereby claim:
* I am mkdarkness on github.
* I am mkdarkness (https://keybase.io/mkdarkness) on keybase.
* I have a public key whose fingerprint is 0E46 BB8E 44A1 8CF8 BB96 5F87 9CB0 9362 58FF 7528
To claim this, I am signing this object:
@thebergamo
thebergamo / subdocs.js
Last active August 29, 2015 14:03
subdoc
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
//loading required Schemas
var departamentsSchema = mongoose.model('departments').schema;//require('./departaments');
var badgesSchema = mongoose.model('badges').schema; //require('./badges');
var permissionsSchema = mongoose.model('badges').schema;//require('./permissions');
//user schema
@thebergamo
thebergamo / test_user.js
Created July 2, 2014 17:29
test_user.js
var request = require('request');
var assert = require('assert');
describe('API / USER Test', function(){
//test get list
describe('GET /api/users', function(){
it('code 200 && array', function(done){
request('http://localhost:8080/api/users', function(err, res){
assert.equal(res.statusCode, 200);
assert.ok(typeof JSON.parse(res.body) === "object");
@thebergamo
thebergamo / express.js
Last active August 29, 2015 14:03
express.js
var express = require('express');
var domain = require('domain');
var app = express();
app.use(function(req, res, next){
var d = domain.create();
d.add(req);
d.add(req);
@thebergamo
thebergamo / Del_USER.js
Last active August 29, 2015 14:03
Mocha + SuperTest + REST
describe('DELETE /api/user', function () {
it('Delete User Sucess', function (done) {
request('http://localhost:8080/api/')
.del('user/53b48b72f4211ee61908efac')
.expect(202, done);
});
});
@thebergamo
thebergamo / del_user.js
Created July 3, 2014 12:33
Testes Deletar Usuário
describe('DELETE /api/user', function () {
it('Delete User Sucess', function (done) {
request('http://localhost:8080/api/')
.del('user/53b48b72f4211ee61908efac')
.expect(202, done);
});
});
@thebergamo
thebergamo / get_users.js
Created July 3, 2014 12:33
Listar Todos Usuários
describe('GET /api/users', function(){
it('recovery users list', function(done){
request('http://localhost:8080/api/')
.get('users')
.set('Content-Type', 'application/json')
.expect('Content-Type', /json/)
.expect(function(res){
if(('error' in res.body)) return "Error here!";
})
.expect(200, done);
@thebergamo
thebergamo / post_user.js
Last active August 29, 2015 14:03
Criar Usuários
//Usaremos o describe para ser a nossa suite do POST no verbo "user" da nossa API
describe('POST /api/user', function () {
//Usaremos o It para dizer o que iremos testar dentro dessa suite.
it('Create User Sucess', function (done) {
// criando um objeto com os campos de usuário para testar uma inserção.
var user = {
"email": "marcos@thedon.com.br",
"name":{
"first": "Marcos",
"last": "Bérgamo"