Skip to content

Instantly share code, notes, and snippets.

View JonnatasCabral's full-sized avatar
:octocat:
Software Engineer

Jonnatas Cabral JonnatasCabral

:octocat:
Software Engineer
View GitHub Profile
import base64
txt = open("contract.txt", "rb")
with open("test.pdf", "wb") as pdf:
pdf.write(base64.decodebytes(txt.read()))
# pip install python-Levenshtein gensim
from collections import defaultdict
from gensim import corpora
from gensim import models
from gensim import similarities
from Levenshtein import distance
from Levenshtein import ratio
import pickle
import re

Describing quake 3 reports system

This file describes the structure of a reporting system for quake 3, we will talk about its architecture, classes and functions. For this approach, we will divide the project into two layers, the first layer will have the function of executing a type of ETL, having as a source files of logs of quake 3. The objective is to structure the data taken from the files in a database. The second layer will be responsible for the functions that will provide the information needed to generate the reports on a web page. In all layers we will maintain a pattern of 'models / classes' that will be the interface with the database, and 'functions' that may have inputs and outputs.

With the execution of the first layer we will have a script to read the log files and save the data in a database. We will create classes from the default logs: LogGame and LogPlayer. The LogGame class contains the attributes: start, end, and list of players. The LogPlayer class contains name, kill, gun, death

import numpy as np
class Dataset(object):
data = None
target = None
target_names = None
def __repr__(self):
rep = "Dataset(\n data: {0}, \n target: {1}, \n target_names: {2},\n)"\
.format(self.data, self.target, self.target_names)
from django import template
register = template.Library()
@register.inclusion_tag('templatetags/filters.html', takes_context=True)
def filter(context):
list_filters = []
dict_filters = []
for f in context['filters']:
from datetime import datetime
from datetime import timedelta
class FilterMixin(object):
filter_fields = []
data_field = None
def set_filters(self):
def get_context_data(self, **kwargs):
context = super(RelatorioPautaView, self).get_context_data(**kwargs)
query = context['object_list'].order_by(
'processo_dpvat__estado', 'solicitacao__correspondente')
group_corr = [
(corr, [x for x in corr_list])
for corr, corr_list in itertools.groupby(
query,
lambda x: x.solicitacao.correspondente)]
import itertools
def get_context_data(self, **kwargs):
context = super(RelatorioPautaView, self).get_context_data(**kwargs)
docs = Audiencia.objects.all().order_by(
'processo_dpvat__estado', 'processo_dpvat__estado')
docs_mutuario = [
(tipo, [x for x in doc_list])
for tipo, doc_list in itertools.groupby(