Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Sham Vinicius Fiorin skatesham

🏠
Working from home
View GitHub Profile
@skatesham
skatesham / yahtzee-game.py
Last active Jul 13, 2021
Yahtzee Game with Python 3 (command line)
View yahtzee-game.py
import random
# Para versão 2, auxilia na pontução
pontuacao = {
'G': 50,
'Q': 40,
'S+': 30,
'S-': 40,
'T': 20,
'A': "SOMA",
@skatesham
skatesham / overriding_method_polymorphic.py
Last active Oct 23, 2020
Polymorphism and Abstract Method Overriding implementing an Interface
View overriding_method_polymorphic.py
from abc import ABC, abstractmethod
def main():
for obj in (LocalFinder(), ExternalFinder()):
obj.explore()
obj.comming_back()
class FinderInterface(ABC):
@skatesham
skatesham / bobble_sort.py
Last active Oct 7, 2020
Simples bobble_sort Sort Algorithm
View bobble_sort.py
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
View mapper-recursive-reflaction.py
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 Sep 13, 2018
Script Set Up Github with Python3 in command line
View setupgithub.py
#! /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 Feb 4, 2018 — forked from JavascriptMick/mongodb-dao.js
Simple Node.js Utility module to enable easy creation of models using node-mongodb-native
View mongodb-dao.js
/*
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 Feb 4, 2018 — forked from lifecoder/CategoryRepository.js
simple DAO example for nodejs
View CategoryRepository.js
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 Jan 22, 2018 — forked from codediodeio/index.js
Firebase Cloud Functions image thumbnail generator using Sharp for 4x faster resizing
View index.js
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 Sep 12, 2017 — forked from ilusi/gist:4205101
m101 hw5.1 to 5.4 - Aggregation Framework
View gist:70515b6b9c250f96aa199981f1214097
// $sum
db.zips.aggregate([
{ $group:
{
"_id": {
"state": "$state"
},
"population": { "$sum": "$pop" }
}
}
@skatesham
skatesham / CRUD Excepion.py
Created Aug 8, 2017 — forked from fmasanori/CRUD Excepion.py
CRUD MongoDB exception
View CRUD Excepion.py
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',