Skip to content

Instantly share code, notes, and snippets.

View TomNeyland's full-sized avatar

Thomas Neyland TomNeyland

  • Spotify
View GitHub Profile
@TomNeyland
TomNeyland / mongolite.py
Created February 9, 2025 04:21
MongoLite-Py
#!/usr/bin/env python3
"""
MongoLite-Py: A MongoDB-like library for in-memory Python dicts and lists,
supporting both query expressions and an aggregation pipeline.
"""
import re
import json
import math
import datetime
@TomNeyland
TomNeyland / mongolite.js
Last active February 9, 2025 20:40
MongoLite
/*
MongoLite: A MongoDB‑like library for in‑memory POJOs,
supporting both query expressions (filtering) and an aggregation pipeline.
Updated to TypeScript and enhanced with:
– New operators: $slice and $filter
– Modern JS features: optional chaining (?.), nullish coalescing (??), Array.prototype.at()
– Simple pipeline optimization (merging consecutive $match stages)
– Cursor support via async iterators
– Some improvements in array operation efficiency (e.g. in $addToSet)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <semaphore.h>
#define SHM_NAME "/my_shared_memory"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <semaphore.h>
#define SHM_NAME "/my_shared_memory"
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <pthread.h>
typedef struct {
{rkey:{key: r[key] for key in header} for rkey, r in z.items()}