Skip to content

Instantly share code, notes, and snippets.

@hspedro
hspedro / check-approvals.yml
Last active February 27, 2023 19:29
GitHub Action to Count Number of Approvals
# 1. Create a project variable named `MIN_APPROVALS_NEEDED`, must be an integer
# 2. Check approvals will use the token to fetch REST API and get the reviews for a current Pull Request
# 3. With JQ it parses all that has label "APPROVED" and count
# 4. If greater or equal, exit successfully. Otherwise, fail
#
env:
MIN_APPROVALS_NEEDED: ${{ vars.MIN_APPROVALS_NEEDED }}
jobs:
@hspedro
hspedro / crawl-iptu-cps.js
Created June 30, 2022 18:24
Crawl IPTU Cartography Codes for Campinas
/* JS snippet that can be ran in the console to crawl for cartography codes
* of houses in Campinas:
* 1. Log in: https://cidadao.campinas.sp.gov.br/
* 2. Go to 'IPTU - CONSULTA IPTU DO EXERCICIO'
* 3. Run the script
*
* The output should be a list of valid cartography codes.
* Each cartography code starts with a BASE_CODE that can be found here:
* https://zoneamento.campinas.sp.gov.br/
* Use this to adjust the BASE_CODE
@hspedro
hspedro / heap.py
Created June 15, 2022 15:42
Heap Implementation Python
from __future__ import annotations
from typing import List, Optional
import sys
class MinHeap:
"""
Abstracting the node data as Int but could be Any, given a custom comparison
function to guide ourselves on how to compare the nodes.
@hspedro
hspedro / singly_linked_list.py
Last active December 5, 2021 19:43
Custom Singly-Linked List in Python
from __future__ import annotations
from typing import Any, List, Optional
class SLLNode:
def __init__(self, data: Any, next_node: Optional[SLLNode] = None):
self.data = data
self.next_node = next_node
def __str__(self):