Skip to content

Instantly share code, notes, and snippets.

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

Víctor Villalobos viktorvillalobos

🏠
Working from home
View GitHub Profile
@viktorvillalobos
viktorvillalobos / chunks_generators.py
Created November 2, 2020 22:02
Generate chunks using python generators.
# based on: https://stackoverflow.com/questions/24527006/split-a-generator-into-chunks-without-pre-walking-it
def chunks(iterable, size=10):
iterator = iter(iterable)
for first in iterator:
yield chain([first], islice(iterator, size - 1))
@viktorvillalobos
viktorvillalobos / django_filter_queryset_entities_proposal.py
Last active October 22, 2020 16:07
Data Classes for Django QuerySet filters and exclutions proposal
from __future__ import annotations
from dataclasses import dataclass
from typing import Optional
class Model:
def __init__(self, name: str, age: int) -> None:
self.name = name
self.age = age
@viktorvillalobos
viktorvillalobos / class_selenium_scraper.py
Created August 3, 2018 18:13
Selenium scraping class with chrome and headless mode.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class WebDriver:
DOWNLOAD_DIR = '/tmp'
def __init__(self, headless=True):
self.options = webdriver.ChromeOptions()
@viktorvillalobos
viktorvillalobos / setup.py
Created September 25, 2015 01:16
setup.py cx_freeze + Python3.4 + PyQt5 + Requests
from cx_Freeze import setup, Executable
import requests.certs
build_exe_options = \
{"include_files":[
(requests.certs.where(),'cacert.pem'),
('config.ini'),
('input/'),
('output/')
]}