Skip to content

Instantly share code, notes, and snippets.

View ottobricks's full-sized avatar

Otto von Sperling ottobricks

View GitHub Profile
@ottobricks
ottobricks / pytorch_binary_classification.py
Last active June 15, 2026 16:01
pytorch_binary_classification.py
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "pandas",
# "torch",
# "torchvision",
# "scikit-learn"
# ]
# ///
@ottobricks
ottobricks / generate-mock-names.py
Last active August 19, 2026 12:00
Name-matching challenge
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "faker",
# ]
# ///
import random
from typing impot Tuple
@ottobricks
ottobricks / mock_data.py
Last active September 3, 2026 12:44
Mock users and transfers Pandas DataFrames
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "pandas",
# "faker"
# ]
# ///
# from duckdb.experimental.spark.sql import SparkSession
import pandas as pd
@ottobricks
ottobricks / patch_hint.py
Last active January 11, 2025 23:48
Patch `pyspark.sql.DataFrame.hint` method in PySpark 3.3
from typing import Any, List, Union
from pyspark.sql import DataFrame
from pyspark.sql.column import Column, _to_java_column
def hint(self, name: str, *parameters: Union[str, int, List[Union[int, str]]]) -> DataFrame:
"""
Patches method from :class:`DataFrame`.
Reference: https://github.com/apache/spark/pull/37616
"""
@ottobricks
ottobricks / download_large_files_from_gdrive.py
Last active November 30, 2020 16:51
Download large files from Google Drive using Python
import io
import os
import pickle
import sys, argparse
from googleapiclient.discovery import build
from google.auth.transport.requests import Request
from googleapiclient.http import MediaIoBaseDownload
from google_auth_oauthlib.flow import InstalledAppFlow
# If modifying these scopes, delete the file token.pickle.