Skip to content

Instantly share code, notes, and snippets.

View mchurichi's full-sized avatar

Maximiliano Churichi mchurichi

View GitHub Profile
@obeattie
obeattie / db_utils.py
Created October 14, 2009 12:51
Exposes SQLAlchemy's sessions and transactions as context managers (so they will be managed automatically inside blocks), and also provides a transaction decorator, which wraps an entire function in a transaction
"""Utilities for managing database sessions."""
from __future__ import with_statement
import contextlib
import functools
@contextlib.contextmanager
def temp_session(session_cls, **kwargs):
"""Quick and dirty context manager that provides a temporary Session object
to the nested block. The session is always closed at the end of the block.
@matthewbednarski
matthewbednarski / postal-codes.json
Last active May 25, 2023 12:38
Global postal codes regex formats
[{ "Note": "The first two digits (ranging from 10–43) correspond to the province, while the last two digits correspond either to the city/delivery zone (range 01–50) or to the district/delivery zone (range 51–99). Afghanistan Postal code lookup", "Country": "Afghanistan", "ISO": "AF", "Format": "NNNN", "Regex": "^\\d{4}$"}, { "Note": "With Finland, first two numbers are 22.", "Country": "Åland Islands", "ISO": "AX", "Format": "NNNNN", "Regex": "^\\d{5}$"}, { "Note": "Introduced in 2006, gradually implemented throughout 2007.", "Country": "Albania", "ISO": "AL", "Format": "NNNN", "Regex": "^\\d{4}$"}, { "Note": "First two as in ISO 3166-2:DZ", "Country": "Algeria", "ISO": "DZ", "Format": "NNNNN", "Regex": "^\\d{5}$"}, { "Note": "U.S. ZIP codes (range 96799)", "Country": "American Samoa", "ISO": "AS", "Format": "NNNNN (optionally NNNNN-NNNN or NNNNN-NNNNNN)", "Regex": "^\\d{5}(-{1}\\d{4,6})$"}, { "Note":
@kunzimariano
kunzimariano / Meffeliar.md
Last active August 10, 2020 18:47
Meffeliar

Meffeliar

  • To fuck up. To Meffel it.

  • To be completely sure about something while being wrong at the same time. Subjects with this kind of tendency, frequently fall into believing they are right, and everyone else wrong. After an inmediate epiphany, where they realize this is not the case, they switch strategy and start acting as if since the very beginning they were saying the opposite.

  • A person who is able to deal with his shameful sins by doing the act of "reset". Reset involves going to church, and by doing so, achieving a new clean state. Make no mistake, this reset does not require penitence, as in the traditional catholic way. It provides a fresh start without any requirement, and can be used an unlimited amount of times.

  • To try to fuck someone up, but to end up fucking oneself up. Usually in a lame and notorious way.

@toransahu
toransahu / models.py
Last active May 5, 2023 14:04
Writable Nested Serializers | Multiple Images Upload | DRF
#!/usr/bin/env python3.6.4
# coding="UTF-8"
__author__ = 'Toran Sahu <toran.sahu@yahoo.com>'
__copyright__ = 'Copyright (C) 2018 Ethereal Machines Pvt. Ltd. All rights reserved'
from django.db import models
from os import path
from utils import directory_path_with_id
# On the host
```
# dnf install libtpms swtpm swtpm-tools
# modprobe tpm_vtpm_proxy
# mkdir /tmp/my_vtpm
# swtpm chardev --tpm2 --vtpm-proxy --tpmstate dir=/tmp/my_vtpm -d
New TPM device: /dev/tpm1 (major/minor = 253/1)
# container_id=$(mktemp)