Skip to content

Instantly share code, notes, and snippets.

View suissa's full-sized avatar
🏠
Working from home

Jean Carlo Nascimento suissa

🏠
Working from home
  • Oncorithms Institute
  • Brasil
View GitHub Profile
@suissa
suissa / linhaDoTempoSchemaExemploRuim
Created January 28, 2015 19:00
linhaDoTempoSchemaExemploRuim
{hora: [
0: [{
tipo: {type: String, default: ''}
, idPublicacao: Schema.Types.ObjectId
}]
, 1: [{
tipo: {type: String, default: ''}
, idPublicacao: Schema.Types.ObjectId
}]
, 2: [{
db.timeline.findOne()
{
_id: "username_month_day_hour",
time: [
'59': [ { _idEvent: ObjectId(....), text:'some description text', media:['url'], embedded: "..." } ],
'58': [ { _idEvent: ObjectId(....), text:'some description text', media:['url'], embedded: "..." } ],
'57': [ { _idEvent: ObjectId(....), text:'some description text', media:['url'], embedded: "..." } ],
'56': [ ],
'55': [ { _idEvent: ObjectId(....), text:'some description text', media:['url'], embedded: "..." } ],
'54': [ ],
@suissa
suissa / api-stream.js
Created March 11, 2015 00:24
API Stream with Node.js
var http = require('http');
// Criando o servidor para o proxy
http.Server(function(req, res){
res.writeHead(200, {
'Content-Type' : 'application/json; charset=utf-8',
'Transfer-Encoding' : 'chunked'
});
setInterval(function(){
@suissa
suissa / user-settings-sublime.json
Created April 30, 2015 14:03
user-settings-sublime.json
{
"color_scheme": "Packages/Theme - Spacegray/base16-eighties.dark.tmTheme",
"font_size": 16,
"ignored_packages":
[
"Vintage",
"BracketHighlighter",
"Markdown"
],
"tab_size": 2,
var Beer = require('./model')
, Cervejaria = require('./model-cervejaria')
;
Cervejaria
.findOne()
.populate('beers')
.exec(function (err, cervejaria) {
if (err) return console.log('Erro: ', err);
console.log('Cervejaria', cervejaria);
package main
import (
"fmt"
"strconv"
)
func is_happy_number(number int) bool {
str := strconv.Itoa(number)
@suissa
suissa / exe01.js
Last active August 29, 2015 14:22
Workshop Geoloc com MongoDb - Exercicios
var MongoClient = require('mongodb').MongoClient
, url = 'mongodb://localhost:27017/geodb'
, lugar = {
name: "Zona da Creide"
, loc: [50, 50]
}
;
MongoClient.connect(url, function(err, db) {
if(err) return console.log(err);
@suissa
suissa / routes-api.js
Created June 3, 2015 22:45
Meu arquivo que gera rotas automaticamente para o Express a partir de um JSON
var express = require('express')
, router = express.Router()
, Controller = require('./../controller')
;
var cbCreate = function(req, res) {
Controller.create(req, res);
}
, cbRetrieve = function(req, res) {
Controller.retrieve(req, res);
@suissa
suissa / app.js
Created July 22, 2015 01:31
Servidor com rotas manuais em Node.js
var http = require('http');
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/workshop-online-julho-2015');
var db = mongoose.connection;
db.on('error', function(err){
console.log('Erro de conexao.', err);
});
db.on('open', function () {
console.log('Conexão aberta.');
@suissa
suissa / jsfuncional-high-order-functions-example-01.js
Created September 4, 2015 02:13
Examples of high order functions in JavaScript #01
function somar(x, y) {
return x + y;
};
function subtrair(x, y) {
return x - y;
};
function multiplicar(x, y) {
return x * y;