Skip to content

Instantly share code, notes, and snippets.

View HacKanCuBa's full-sized avatar
⛷️
Also in gitlab.com/hackancuba

Iván || HacKan HacKanCuBa

⛷️
Also in gitlab.com/hackancuba
View GitHub Profile
@HacKanCuBa
HacKanCuBa / find-https-debian-archives.py
Last active July 4, 2023 19:37 — forked from eighthave/find-https-debian-archives.py
Script to find official Debian mirrors that support HTTPS
#!/usr/bin/env python3
"""Find Debian HTTPS archives.
Script based on https://gist.github.com/eighthave/7285154
I made it asynchronous and parallel, so overall I measured it to be 6 times faster or more.
Requires Python 3.7+
Additional resources not exactly related to this script but could be helpful for
@HacKanCuBa
HacKanCuBa / logo_turtle.py
Last active July 17, 2023 20:11
Logo (programming language) turtle excercise
"""Logo (programming language) turtle exercise."""
import typing
import unittest
from dataclasses import dataclass
from enum import Enum
from itertools import zip_longest
from unittest import TestCase
@HacKanCuBa
HacKanCuBa / replacing_openpgp_2019.md
Last active September 14, 2023 14:25
Replacing OpenPGP in 2019

Replacing OpenPGP in 2019

Update for 2023: this is still a thing!

It's 2019, and OpenPGP has to die already (for very many reasons I won't list, but see 1, 2 and 3). At least for most uses.
I'll try to list here some replacements categorized by usage (also see 5), because there's no one single-do-all app, and there shouldn't be!

All of this resurfaced because of a vuln exploited recently on SKS keyservers (that has NOTHING to do with OpenPGP nor GnuPG but yes, they're related to the environment) (see 4).

Note: only FOSS software listed (although some server-side implementations could be closed, where applicable).

@HacKanCuBa
HacKanCuBa / gunicorn.py
Last active March 17, 2024 07:01 — forked from kodekracker/gunicorn.py
A config file of gunicorn(http://gunicorn.org/) contains fundamental configuration.
"""Gunicorn config file.
by HacKan (https://hackan.net)
Find it at: https://gist.github.com/HacKanCuBa/275bfca09d614ee9370727f5f40dab9e
Based on: https://gist.github.com/KodeKracker/6bc6a3a35dcfbc36e2b7
Changelog
=========
See revisions to access other versions of this file.
@HacKanCuBa
HacKanCuBa / cache_helpers.py
Last active March 17, 2024 07:04
Cache handy helpers
"""Handy cache helpers.
These are not yet production ready, as I haven't toroughly tested them, but close.
---
Mandatory license blah blah:
Copyright (C) 2023 HacKan (https://hackan.net)
This Source Code Form is subject to the terms of the Mozilla Public
@HacKanCuBa
HacKanCuBa / sqlalchemy_helpers.py
Last active March 17, 2024 07:04
SQLAlchemy handy helper functions
import functools
from contextlib import asynccontextmanager, contextmanager
from time import monotonic
from typing import Annotated, Any, AsyncGenerator, Generator, Hashable, Iterable, Literal, Optional, Sized, Union, overload
from sqlalchemy import event
from sqlalchemy.dialects.mysql.asyncmy import AsyncAdapt_asyncmy_cursor
from sqlalchemy.engine import URL, Connection, Engine, Row, create_engine
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, async_sessionmaker, create_async_engine
from sqlalchemy.orm import Session, sessionmaker
@HacKanCuBa
HacKanCuBa / pickle_deal.py
Created March 1, 2022 21:54
How pickle changes according to how the interpreter gets called
"""Pickle dumps test.
When pickle dumps a class, it will include the FQDN for the module. In this example,
we see how an imported class gets dumped including its module information, whereas
a local one has the current module name, which could be `__main__` or other depending
on how the interpreter was called!
If you save this file as `pickle_deal.py` and then in a python terminal you import it
`import pickle_deal`, you will see the following printed:
b'\x80\x04\x95)\x00\x00\x00\x00\x00\x00\x00\x8c\x0bpickle_deal\x94\x8c\x07Decimal\x94\x93\x94\x8c\x07123.456\x94\x85\x94R\x94.'