Skip to content

Instantly share code, notes, and snippets.

View olivx's full-sized avatar

Thiago Oliveira olivx

  • Tivit
  • Sao Paulo
View GitHub Profile
@olivx
olivx / ipartition.py
Created January 17, 2019 12:05
work with many files sending to server
import six
if six.PY2:
from collections import Iterator
elif six.PY3:
from collections.abc import Iterator
# https://github.com/turicas/rows/tree/05cea12a42cc46ebc6ac3d33614a3e77c497e6d4
# https://github.com/turicas/rows/blob/05cea12a42cc46ebc6ac3d33614a3e77c497e6d4/rows/plugins/utils.py#L35-L51
# encoding=utf8
from django.conf import settings
from django.utils import timezone
from django.core.files import File
from django.core.files.base import ContentFile
from django.core.management.base import BaseCommand, CommandError
from combo.models import CandidateCV
from django.contrib.auth.models import User
@olivx
olivx / simple_keywors.py
Created January 15, 2019 18:52
simple keywords nltk
import nltk
from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
nltk.download('stopwords')
nltk.download('punkt')
punctuations = ['(',')',';',':','[',']',',']
stop_words = stopwords.words('portuguese')
@olivx
olivx / extrac_text_from_pdf.py
Created January 15, 2019 18:47
extract text from pdf
pdfReader = PyPDF2.PdfFileReader(absolute_file_name)
num_pages = pdfReader.numPages
count = 0
text_from_pdf = ""
while count < num_pages:
pageObj = pdfReader.getPage(count)
count +=1
text_from_pdf += pageObj.extractText()
@olivx
olivx / console_loanding.py
Created January 15, 2019 18:45
create a login on console
import sys
for index, item in enumerate(range(0,100000000)):
# efeito loading
current = index + 1
filled_length = int(100 * current // total_items)
bar = '*' * filled_length + '-' * (100 - filled_length)
percent = 100 * (current / total_items)
percent = ("{0:." + '1' + "f}").format(100 * (current / float(total_items)))
new_candidates = CompanyCandidate.objects.filter(company=obj,date__range=[date_initial, date_end])
truncate_newcand = connection.ops.date_trunc_sql('month', 'date')
context['new_candidates_total'] = len(new_candidates)
context['new_candidates_ext'] = new_candidates.extra({'month': truncate_newcand}).values(
'month').annotate(jcount=Count('pk')).order_by('month')
def export_job_agenda(request, job):
# import ipdb; ipdb.set_trace()
job_object = get_object_or_404(Job, pk=job)
schedule = Schedule.objects.filter(job=job_object)
list_schedule = []
# para cada agendamento
for sc in schedule:
def export_job_agenda(request, job):
# import ipdb; ipdb.set_trace()
job_object = get_object_or_404(Job, pk=job)
schedule = Schedule.objects.filter(job=job_object)
list_schedule = []
# para cada agendamento
for sc in schedule:
def export_job_agenda(request, job):
# import ipdb; ipdb.set_trace()
job_object = get_object_or_404(Job, pk=job)
schedule = Schedule.objects.filter(job=job_object)
list_schedule = []
# para cada agendamento
for sc in schedule:
def export_job_agenda(request, job):
# import ipdb; ipdb.set_trace()
job_object = get_object_or_404(Job, pk=job)
schedule = Schedule.objects.filter(job=job_object)
list_schedule = []
# para cada agendamento
for sc in schedule: