Skip to content

Instantly share code, notes, and snippets.

@d0rc
d0rc / quantum-2d-square-potential.py
Created January 22, 2025 19:36
quantum-2d-square-potential.py
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.animation import FuncAnimation
if __name__ == '__main__':
# Constants and parameters
hbar = 1.0 # Reduced Planck's constant
m = 1.0 # Particle mass
V0 = 1.0 # Barrier height

To capture a video stream from a Logitech C270 HD Webcam using libusb, you'll need to interface with the webcam's USB Video Class (UVC) interface, as the C270 is a UVC-compliant device. Below is a step-by-step guide to achieve this. Note that this process requires familiarity with C/C++ programming, USB protocols, and handling video data (e.g., MJPEG or YUYV formats). The approach assumes you're working on a Linux system, as libusb is commonly used there, but it can be adapted for other platforms.Prerequisites

  1. Install libusb: Ensure libusb-1.0 is installed (sudo apt install libusb-1.0-0-dev on Debian/Ubuntu or equivalent).
  2. Development Environment: Set up a C/C++ environment with a compiler (e.g., gcc) and necessary headers.
  3. Permissions: Ensure you have permissions to access the webcam (e.g., add your user to the video group or run as root, though root is not recommended).
  4. Dependencies: Optionally, install v4l2loopback to create a virtual video device for testing or piping the stream to other appl
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <math.h>
#define ORIGINAL_TABLE_SIZE 256
#define PROPOSED_TABLE_SIZE 512
int32_t original_table[ORIGINAL_TABLE_SIZE];
int32_t proposed_table[PROPOSED_TABLE_SIZE];
@d0rc
d0rc / eggroll-hacks.md
Created December 16, 2025 11:22
EGGROLL hacks

USE_ADAPTIVE_THRESHOLD

#ifndef USE_ADAPTIVE_THRESHOLD
#  define USE_ADAPTIVE_THRESHOLD 1
#endif
#ifndef ADAPTIVE_THRESHOLD_ALPHA
#  define ADAPTIVE_THRESHOLD_ALPHA 0.1f
#endif
### **The Core Concept**
The main innovation of mHC is solving the instability of "Hyper-Connections" (HC).
Standard HC expands the residual stream width (from $C$ to $n \times C$) but allows the signal to explode or vanish because the connection matrices are unconstrained.
**mHC fixes this by enforcing constraints:**
1. **Residual Mapping ($\mathcal{H}^{res}$):** Projected onto the **Birkhoff polytope** (doubly stochastic matrices) using the Sinkhorn-Knopp algorithm.
2. **Input/Output Mappings ($\mathcal{H}^{pre}, \mathcal{H}^{post}$):** Constrained to be non-negative (using Sigmoid) to prevent signal cancellation.