Skip to content

Instantly share code, notes, and snippets.

View Tobi-De's full-sized avatar
👁️‍🗨️
Trade-offs everywhere!

Tobi Tobi-De

👁️‍🗨️
Trade-offs everywhere!
View GitHub Profile
@jboner
jboner / latency.txt
Last active May 8, 2025 06:10
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@Nagyman
Nagyman / workflows-in-django.md
Last active November 20, 2024 01:08
Workflows in Django

Workflows (States) in Django

I'm going to cover a simple, but effective, utility for managing state and transitions (aka workflow). We often need to store the state (status) of a model and it should only be in one state at a time.

Common Software Uses

  • Publishing (Draft->Approved->Published->Expired->Deleted)
@parmentf
parmentf / GitCommitEmoji.md
Last active May 5, 2025 18:02
Git Commit message Emoji
@0xjac
0xjac / private_fork.md
Last active May 7, 2025 10:59
Create a private fork of a public repository

The repository for the assignment is public and Github does not allow the creation of private forks for public repositories.

The correct way of creating a private frok by duplicating the repo is documented here.

For this assignment the commands are:

  1. Create a bare clone of the repository. (This is temporary and will be removed so just do it wherever.)

git clone --bare [email protected]:usi-systems/easytrace.git

@marcorichetta
marcorichetta / postgresql-manjaro.md
Last active March 17, 2025 00:07
Install PostgreSQL on Manjaro and set it up for Django
@Tobi-De
Tobi-De / admin.py
Last active January 3, 2021 08:02
Custom user model
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin
from django.utils.translation import ugettext_lazy as _
from .models import User
@admin.register(User)
class UserAdmin(DjangoUserAdmin):
from datetime import datetime
"""
Called during request:
process_request(request)
process_view(request, view_func, view_args, view_kwargs)
Called during response:
process_exception(request, exception) (only if the view raised an exception)
process_template_response(request, response) (only for template responses)
@Tobi-De
Tobi-De / models.py
Created December 5, 2020 12:52
Multiple Users model using Proxy models, code originated from https://github.com/pydanny/multiple-user-types-django
from django.contrib.auth.models import AbstractUser
from django.db import models
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
class User(AbstractUser):
class Types(models.TextChoices):
SPY = "SPY", "Spy"
DRIVER = "DRIVER", "Driver"
@shashank-p
shashank-p / tachiyomi-source-details.json
Created December 22, 2020 14:08
Tachiyomi Source (Extensions) Details
{
"extensions": [
{
"id": "10",
"lang": "de",
"source": "Wie Manga!"
},
{
"id": "100019686565354829",
"lang": "de",
@tonybaloney
tonybaloney / app.py
Last active March 25, 2024 23:52
FastAPI with OpenTelemetry
from azure.monitor.opentelemetry.exporter import AzureMonitorTraceExporter
from fastapi import FastAPI, Request
from fastapi.responses import JSONResponse
from opentelemetry.context import get_current as get_current_context
from opentelemetry.instrumentation.fastapi import FastAPIInstrumentor
from opentelemetry.sdk.trace import TracerProvider, _Span
from opentelemetry.sdk.trace.export import (BatchSpanProcessor,
ConsoleSpanExporter,
SimpleSpanProcessor)
from starlette.exceptions import HTTPException as StarletteHTTPException