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 / bobble_sort.py
Last active October 7, 2020 23:25
Simples bobble_sort Sort Algorithm
import unittest
def bobble_sort(values):
"""
Sorting list algorithm type of BobbleSort.
Time O(n**2 - n)
Space O(n + 3)
:author sham vinicius fiorin
:param values: List of comparable objects
class Mapper:
def convertValue(self, data, obj):
"""
Mapper from dict to class, covering it's chieldrens but the key on dict must be mapping the chield with .
Exemple: data = {
"x": 0,
"y": 1,
"chield.a": "Sham Vinicius",
"chield.b": "Fiorin",
"chield.layer.c": "xxx",
@skatesham
skatesham / setupgithub.py
Created September 13, 2018 19:18
Script Set Up Github with Python3 in command line
#! /usr/bin/python
import subprocess
print("---------------------------------------------------")
print("Automatic Watched Set Up of Github in Python")
print("-----------by Sham Vinicius Fiorin-----------------")
print("---------------------------------------------------")
config = input("Set up configurations[N/s]?")
if('s' in config.lower()):
subprocess.run(["git", "init"])
@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,
@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 / 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 / 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 / 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 / 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 / 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)