Skip to content

Instantly share code, notes, and snippets.

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

Sham skatesham

🏠
Working from home
View GitHub Profile
@skatesham
skatesham / Max_Min.py
Last active March 8, 2016 21:39
Max_min Entrega
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).
'''
@skatesham
skatesham / Duplamente.py
Last active March 8, 2016 21:40
Lista Encadeada Duplamente Ligada
class ListaVaziaErro(Exception):
pass
class Noh():
def __init__(self, valor, esquerdo = None, direito = None):
self.valor = valor
self.direito = direito
self.esquerdo = esquerdo
@skatesham
skatesham / FunçãoVerificarBalanceamento.py
Last active March 16, 2016 17:06
Questão de Estrutura de Dados - Entrega 5
import unittest
class Pilha():
def __init__(self):
self.lista = []
def empilhar(self, valor):
self.lista.append(valor)
def vazia(self):
@skatesham
skatesham / Oficina MongoDB e Python FISL
Created August 8, 2017 14:19 — forked from fmasanori/Oficina MongoDB e Python FISL
Oficina MongoDB e Python FISL
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)
@skatesham
skatesham / CRUD MongoDB.py
Created August 8, 2017 14:19 — forked from fmasanori/CRUD MongoDB.py
CRUD MongoDB Python2
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()}
@skatesham
skatesham / CRUD Excepion.py
Created August 8, 2017 14:19 — forked from fmasanori/CRUD Excepion.py
CRUD MongoDB exception
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',
@skatesham
skatesham / gist:70515b6b9c250f96aa199981f1214097
Created September 12, 2017 04:40 — forked from ilusi/gist:4205101
m101 hw5.1 to 5.4 - Aggregation Framework
// $sum
db.zips.aggregate([
{ $group:
{
"_id": {
"state": "$state"
},
"population": { "$sum": "$pop" }
}
}
@skatesham
skatesham / index.js
Created January 22, 2018 01:16 — forked from codediodeio/index.js
Firebase Cloud Functions image thumbnail generator using Sharp for 4x faster resizing
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.
@skatesham
skatesham / CategoryRepository.js
Created February 4, 2018 05:59 — forked from lifecoder/CategoryRepository.js
simple DAO example for nodejs
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});
}
@skatesham
skatesham / mongodb-dao.js
Created February 4, 2018 05:59 — forked from JavascriptMick/mongodb-dao.js
Simple Node.js Utility module to enable easy creation of models using node-mongodb-native
/*
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,