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
import unittest | |
def max_min(x): | |
''' | |
:param seq: uma sequencia | |
:return: (min, max) | |
Entra com uma lista X, ele retorna o Maior numero e o Menor; Tempo em O(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
class ListaVaziaErro(Exception): | |
pass | |
class Noh(): | |
def __init__(self, valor, esquerdo = None, direito = None): | |
self.valor = valor | |
self.direito = direito | |
self.esquerdo = esquerdo |
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
import unittest | |
class Pilha(): | |
def __init__(self): | |
self.lista = [] | |
def empilhar(self, valor): | |
self.lista.append(valor) | |
def vazia(self): |
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
Oficina MongoDB e Python - FISL | |
Resumo university.mongodb.com/courses/M101P/about | |
Install python 2.7 (provavelmente vc já tem) | |
https://www.python.org/downloads/ | |
para testar python -V | |
Install mongoDB 3.4 | |
https://www.mongodb.org/downloads | |
criar diretório \data\db com as permissões necessárias para testar bin\mongod (servidor) |
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
from datetime import datetime | |
from pymongo import MongoClient | |
connection = MongoClient("mongodb://localhost") | |
db = connection.test | |
post = {"title": "My Blog Post", | |
"content": "Here's my blog post.", | |
"date": datetime.utcnow()} |
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
import pymongo | |
import sys | |
def main(): | |
connection = pymongo.MongoClient("mongodb://localhost") | |
db = connection.m101 | |
people = db.people | |
person = {'name': 'Barack Obama', 'role':'President', | |
'address':{'address1':'The White House', | |
'street': '1600 Pensylvania Avenue', |
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
// $sum | |
db.zips.aggregate([ | |
{ $group: | |
{ | |
"_id": { | |
"state": "$state" | |
}, | |
"population": { "$sum": "$pop" } | |
} | |
} |
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
const functions = require('firebase-functions'); | |
const gcs = require('@google-cloud/storage')(); | |
const sharp = require('sharp') | |
const _ = require('lodash'); | |
const path = require('path'); | |
const os = require('os'); | |
exports.generateThumbnail = functions.storage.object('uploads/{imageId}').onChange(event => { | |
const object = event.data; // The Storage object. |
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 mongo = require('mongodb'), | |
EventEmitter = require('events').EventEmitter; | |
function Connector(settings) { | |
settings.port = settings.port || mongo.Connection.DEFAULT_PORT; | |
this.settings = settings; | |
this.server = new mongo.Server(settings.host, settings.port); | |
this.db = new mongo.Db(settings.database, this.server, {native_parser: true}); | |
} |
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
/* | |
Simple Node.js Utility module to enable easy creation of models using node-mongodb-native | |
Useage:- | |
var dao = require('./mongodb-dao'); | |
exports.NewClient = function(clientId, plan){ | |
return { | |
clientId: clientId, | |
plan: plan, |
OlderNewer