Skip to content

Instantly share code, notes, and snippets.

{
"name": "TextFile",
"version": "0.1",
"namespace": "http://onto-ns.com/meta",
"meta": "http://onto-ns.com/meta/0.3/EntitySchema",
"description": "Representation an experimental image.",
"dimensions": [],
"properties": [
{
"name": "data",
identity: http://onto-ns.com/entity/v1/demo#a77e5e81-2107-45f9-9dde-1f559d961d0a
description: Demonstration
dimensions:
N: Number of items
properties:
lat:
type: float
shape: ["N"]
description: Latitude
@quaat
quaat / fisher_random.py
Last active February 10, 2024 14:03
Fisher Random starting positions
"""Generate and validate starting positions for Fischer Random Chess,
also known as Chess960. Fischer Random Chess is a variant of
traditional chess invented by the former World Chess Champion Bobby
Fischer. It was introduced to add variety to the game and reduce the
reliance on opening memorization by randomly shuffling the positions
of the back-row pieces (rooks, knights, bishops, queen, and king)
while adhering to certain rules to ensure the game remains balanced
and playable.
Fischer Random Chess follows these specific rules for setting up the
@quaat
quaat / storage-backend-example.py
Last active March 6, 2024 08:43
Example of how to abstract the storage backend for a caching service in Python, using the principles of protocols from type hinting for runtime type checking.
from dataclasses import dataclass, field
from typing import Any, Dict, Protocol, runtime_checkable
from redis import Redis
@runtime_checkable
class ICacheBackend(Protocol):
"""
Defines an interface for cache backends. Any class that implements this protocol
must provide `set`, `get`, and `aclose` methods. This allows for flexibility in
the cache implementation, as different storage mechanisms can be used as long as