Skip to content

Instantly share code, notes, and snippets.

import torch.nn as nn
import torch.nn.functional as F
import math
# N log N approximation for a multiplication by a random orthogonal matrix
# Mostly untested, depends on having fast_hadamard_transform installed via git
class FastFood(nn.Module):
def __init__(self, size):
super().__init__()
# Check that size is a power of two

Learning AI

If you've never done any programming courses before, I'd recommend Harvard CS50.
You do need a good amount of math at some point, but there are too many possible math resources to easily include here.

Basics

3Blue1Brown's neural networks videos are fantastic introductions to the ideas here. And I hate videos.
Fast.ai has been the go-to starter resource for years. Highly recommended.

General

Courses

MIT's open course is a good survey course that is more theory-oriented.
Huggingface's tutorials are well regarded for a number of specific applied topics.

"""
Hugging Face Dataset Verification Tool
This script verifies the integrity of locally downloaded Hugging Face datasets by comparing
SHA256 checksums from the remote repository with local file hashes.
USAGE:
python verify_hf_download.py <repo_id> [local_path]
ARGUMENTS:
import torch
@torch.compile
def fwht_optimized(x, dim=-1):
"""
Highly optimized FWHT specifically designed for torch.compile.
Uses more compiler-friendly operations.
"""
if dim != -1:
@segyges
segyges / cuda_reinstall.txt
Created July 30, 2025 20:08 — forked from jbohnslav/cuda_reinstall.txt
Reinstall Nvidia drivers and CUDA on Ubuntu
# Uninstall all nvidia packages, old drivers, etc.
# list all the packages with nvidia in the name
dpkg -l | grep -i nvidia
sudo apt-get remove --purge nvidia*
sudo apt-get remove --purge cuda*
sudo apt-get remove --purge libnccl*

The Scott Alexander Email: An Explainer

So, Scott Alexander sent an email to someone in 2014. In 2021 the person who got that email thought that Scott was not being honest about his relationship to the neoreactionary movement, so they published it.

Although this has been widely available, even people who have read it have often missed what the email is saying. There are some cases of genuine ambiguity, where there can be more than one meaning. There are also cases where there is only one plausible meaning, but that meaning is expressed indirectly, subtly, or by linking to something else. Because what the email is saying can be difficult to understand, it seems like it would be of general interest to publish an explainer that went over these ambiguities and the links.

It has sometimes been said that this email should not be read because it was released without permission. This seems like a bad position.

First, because information is information. We know, due to the circumstances, that this was somewhat i

#!/bin/bash
# ==============================================================================
# NVIDIA Driver Installation Script
#
# This script automates the installation of NVIDIA drivers on various Linux
# distributions based on the official NVIDIA documentation:
# https://docs.nvidia.com/datacenter/tesla/driver-installation-guide/index.html
#
# Supported Distributions:
// Takes a youtube transcript and makes it one big string
// Get all transcript segments
const segments = document.querySelectorAll('ytd-transcript-segment-renderer');
// Extract text from each segment
const text = Array.from(segments)
.map(segment => segment.querySelector('.segment-text')?.textContent.trim())
.filter(text => text) // Remove any empty entries
.join(' ');
import pandas as pd
import sys
from pathlib import Path
from datetime import datetime
def log_warning(message, log_file="conversion_warnings.txt"):
"""Log a warning message to the warnings file with timestamp."""
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
with open(log_file, 'a', encoding='utf-8') as f: