Skip to content

Instantly share code, notes, and snippets.

@bpereto
bpereto / sentry.py
Created October 23, 2023 19:05
Litestar Sentry Integration
from typing import TYPE_CHECKING
from sentry_sdk.consts import OP
from sentry_sdk.hub import Hub
from sentry_sdk.integrations import DidNotEnable, Integration
from sentry_sdk.integrations.asgi import SentryAsgiMiddleware
from sentry_sdk.tracing import SOURCE_FOR_STYLE, TRANSACTION_SOURCE_ROUTE
from sentry_sdk.utils import event_from_exception, transaction_from_function
__all__ = ["LitestarIntegration"]
@bpereto
bpereto / inject_so.py
Created June 30, 2020 10:49
inject_so.py
import ctypes
import sys
import os
class user_regs_struct(ctypes.Structure):
_fields_ = [
("r15", ctypes.c_ulonglong),
("r14", ctypes.c_ulonglong),
("r13", ctypes.c_ulonglong),
("r12", ctypes.c_ulonglong),
@bpereto
bpereto / remote-user-ldap-backend.py
Created February 15, 2019 07:14
RemoteUserLdapBackend: Combine the RemoteUser Authentication and the django-auth-ldap to populate Users in Django
"""
Combine the RemoteUser Authentication and the django-auth-ldap
to populate Users in Django
https://docs.djangoproject.com/en/2.1/howto/auth-remote-user/
https://django-auth-ldap.readthedocs.io/en/latest/
"""
import logging
from django.contrib.auth import load_backend, login
@bpereto
bpereto / drf-rules-permission-class-with-httpmethod-map.py
Last active November 28, 2019 09:19
Django Restframework Rules Permission integration with HTTPMethod Map
"""
Django REST Framework Permission Class for Django Rules
"""
from rest_framework import permissions, exceptions
from rest_framework.viewsets import ModelViewSet
from django.http import Http404
class DjangoRulesMethodObjectPermissions(permissions.BasePermission):
"""
@bpereto
bpereto / keybase.md
Last active September 12, 2019 06:06

Keybase proof

I hereby claim:

  • I am bpereto on github.
  • I am bpereto (https://keybase.io/bpereto) on keybase.
  • I have a public key ASBrTmqKGMOhjSnmMSzIeLX5rlbaW88wLaeFzzU81rtaIAo

To claim this, I am signing this object: