Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Victor H. Villalobos B. viktorvillalobos

🏠
Working from home
View GitHub Profile
@viktorvillalobos
viktorvillalobos / chunks_generators.py
Created Nov 2, 2020
Generate chunks using python generators.
View chunks_generators.py
# 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 Oct 22, 2020
Data Classes for Django QuerySet filters and exclutions proposal
View django_filter_queryset_entities_proposal.py
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 Aug 3, 2018
Selenium scraping class with chrome and headless mode.
View class_selenium_scraper.py
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 Sep 25, 2015
setup.py cx_freeze + Python3.4 + PyQt5 + Requests
View setup.py
from cx_Freeze import setup, Executable
import requests.certs
build_exe_options = \
{"include_files":[
(requests.certs.where(),'cacert.pem'),
('config.ini'),
('input/'),
('output/')
]}
You can’t perform that action at this time.