Skip to content

Instantly share code, notes, and snippets.

@paretech
paretech / exampleApplyCalOffsets.m
Last active September 15, 2022 22:33
This MATLAB+Psychtoolbox example script contains naively approach of applying spatial calibration offsets using Psychtoolbox imaging pipeline. It is posted along with support post on the PTB website. Note that this is not production code, it is simply an example to demonstrate a specific concept.
% Demonstrate attempt at applying x, y offsets via PTB processing hooks.
%
% Instructions
% ------------
% After running, press any key to advance offset position. Position will
% not change until key-up event. The script will run indefinitely until the
% escape key is pressed.
%
% Known Issues
% ------------
@paretech
paretech / collate_nibbles.py
Last active March 7, 2025 05:08
Collate Bytes by Nibble
from collections.abc import Generator
def collate_nibbles(upper: bytes, lower: bytes) -> Generator[int]:
def to_nibbles(data: bytes) -> bytes:
"""Convert bytes to nibbles"""
return (
nibble for byte in data for nibble in ((byte & 0xF0), (byte & 0x0F) << 4)
)
@paretech
paretech / grid.py
Last active March 10, 2025 03:58
Grid Explorer
"""Convenience module for working with grids"""
import dataclasses
import unittest
@dataclasses.dataclass
class GridPoint:
x: int
y: int