Skip to content

Instantly share code, notes, and snippets.

View ajcerejeira's full-sized avatar

Afonso Silva ajcerejeira

View GitHub Profile
@ajcerejeira
ajcerejeira / porta65.py
Last active May 9, 2025 14:08
Porta 65 scraper
#!/usr/bin/env python3
"""
Porta 65 scraper
================
Fetch application results from
`Porta65 program <https://www.portaldahabitacao.pt/pt/porta65j/>`_ website
and save them to a CSV file.
@ajcerejeira
ajcerejeira / Makefile
Last active October 17, 2022 23:22
(Ab)using Makefiles in Django projects
# Lightning talk @ DjangoCon EU 2022
# Afonso Cerejeira <github.com/ajcerejeira>
# Intro
# =====
#
# - Makefiles are a set of rules for building targets based on prerequisites;
# - Usually both targets and prerequisites represent filenames;
# - Makefiles define dependency graphs;
@ajcerejeira
ajcerejeira / find.py
Last active September 19, 2022 15:00
A Python function that returns the first element of an iterable that matches a condition.
from typing import Callable, Iterable, TypeVar
T = TypeVar("T")
def find(condition: Callable[[T], bool], iterable: Iterable[T]) -> T | None:
"""Finds the first element of an iterable that matches a given condition.
Arguments:
condition: A callable that returns a bool representingg wheter or not