Skip to content

Instantly share code, notes, and snippets.

View MartinThoma's full-sized avatar

Martin Thoma MartinThoma

View GitHub Profile
{"last_update":"2024-03-01 09:13:24","query":{"bytes_billed":858128384000,"bytes_processed":858128187412,"cached":false,"estimated_cost":"3.91"},"rows":[{"download_count":1136326177,"project":"boto3"},{"download_count":522672231,"project":"botocore"},{"download_count":464629985,"project":"urllib3"},{"download_count":385781127,"project":"requests"},{"download_count":354125620,"project":"certifi"},{"download_count":351980457,"project":"wheel"},{"download_count":351883200,"project":"pip"},{"download_count":344505419,"project":"typing-extensions"},{"download_count":328506796,"project":"charset-normalizer"},{"download_count":327273028,"project":"setuptools"},{"download_count":325648939,"project":"idna"},{"download_count":296205881,"project":"s3transfer"},{"download_count":285309065,"project":"aiobotocore"},{"download_count":266830043,"project":"packaging"},{"download_count":247186654,"project":"pyyaml"},{"download_count":240249108,"project":"python-dateutil"},{"download_count":230994667,"project":"cryptography"},{
MartinThoma /
Created July 22, 2012 13:30 — forked from teepark/
a pure-python B tree implementation
import bisect
import itertools
import operator
class _BNode(object):
__slots__ = ["tree", "contents", "children"]
def __init__(self, tree, contents=None, children=None):
self.tree = tree
self.contents = contents or []
MartinThoma /
Created October 19, 2023 20:21
Show how ChatGPT can mimik people

Explain general relativity in the style of Donald Trump


Let me tell you, folks, General Relativity, it's a big, big theory, okay? So, you've got this guy, Albert Einstein, right? He was a smart guy, but I'm a smart guy too, very smart, very stable genius. So Einstein, he comes up with this idea, General Relativity. And it's all about gravity, you know, the thing that keeps us on the ground.

from pypdf import PdfReader, PdfWriter
import pypdf
import sys
print(f"Python {sys.version} using pypdf=={pypdf.__version__}")
reader = PdfReader("Antrag.pdf") #
# Get the field names
# fields = reader.get_fields()
from typing import Literal, List
from pydantic import BaseModel, Field
class User(BaseModel):
name: str
roles: List[Literal["Registered", "Moderator", "Admin"]] = Field(
MartinThoma / [WP] "Cheating a goddess" with Chat GPT Plus (GPT-4)
Last active April 2, 2023 06:25
[WP] You stood there, looking at your friend, faceplaming "Let me get this straight, you're dating a Goddess, an actual 'divine powers, older than civilization' Goddess and you ....CHEATED ON HER!?!??" Your friend has a desperate look in their eyes "Can you help me or not?"
As I stood there in disbelief, I couldn't help but feel a mix of amusement and
concern. My friend, Josh, had managed to get himself into the most absurdly
dangerous and comical situation imaginable. He had somehow managed to win the
heart of Lilaia, the enchanting Goddess of Balance and Harmony. Her powers were
legendary, with the ability to restore equilibrium to any situation, whether it
was calming the fiercest storms or soothing the angriest of hearts. Legend had
it that she had once single-handedly quelled a war between two ancient
civilizations, restoring peace and ushering in a golden age of prosperity. And
now, Josh had cheated on her with a mortal woman.
MartinThoma /
Created August 27, 2013 13:25
Automatically find all homomorphisms between (Z/nZ, *) and (Z/mZ, *). This can easily be adjusted to find homomorphisms between (Z/nZ, +) and (Z/mZ, +)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def isGroupHomomorphism(phi, group1, group2, verbose=False):
for a, b in product(group1['set'], group2['set']):
inner = group1['operator'](a, b)
outer = group2['operator'](phi(a), phi(b))
if verbose:
print("f(%i) = %i, f(%i) = %i f(%i)=%i=%i" % (a, phi(a), b, phi(b), inner, phi(inner), outer))
if phi(inner) != outer:
summary: Place an order for a pet
description: successful operation
$ref: '#/components/schemas/Order'
def get_color(i: int) -> Tuple[int, int, int, int]:
r = i % 256
g = 0 # i * 2 % 256
b = i % (256*2)
return (r, g, b, 255)
from dataclasses import dataclass
from typing import List, Tuple
# Just store
# as in the same directory
from anti_aliased_line import draw_line_antialiased
from PIL import Image, ImageDraw