Skip to content

Instantly share code, notes, and snippets.

View rchowell's full-sized avatar
🐙
Gardening

R. C. Howell rchowell

🐙
Gardening
View GitHub Profile
@rchowell
rchowell / video_source.py
Last active July 30, 2025 22:25
Daft VideoSource Implementation
@dataclass
class VideoSource(DataSource):
filepath: Path
image_mode: ImageMode
image_height: int
image_width: int
@property
def name(self) -> str:
return "VideoSource"
@rchowell
rchowell / dataset.py
Created July 15, 2025 18:57
Attempt at python dataset with types
from __future__ import annotations
from abc import ABC, abstractmethod
from collections.abc import Iterable, Iterator
from dataclasses import dataclass
from typing import TYPE_CHECKING, Callable, Generic, TypeVar
__all__ = [
"Dataset",
@rchowell
rchowell / my_cast.rs
Created June 6, 2025 21:11
my_cast.rs
struct MyCast;
#[derive(FunctionArgs)]
struct MyCastArgs {
input: ExprRef,
target: DataType,
}
impl ScalarFunctionFactory for MyCast {
@rchowell
rchowell / test_jq.py
Created June 2, 2025 23:21
Daft example for transforming raw JSON then deserializing into a scalar value.
import daft
from daft import DataType as dt
from daft import col
# here's our raw sample data which is just some json dump from a sensor
df = daft.from_pydict(
{
"sample": [
'{ "x": 1 }', # missing y, we'll insert 0 in its place
'{ "x": 1, "y": 1 }', # ok
@rchowell
rchowell / from_json.py
Last active June 12, 2025 19:17
Daft JSON to STRUCT
import json
import daft
from daft import DataType, Expression, Series, col, udf
def from_json(col: Expression, schema: DataType) -> Expression:
"""Produces a UDF based upon the input schema."""
@rchowell
rchowell / put_file.py
Created May 9, 2025 22:43
Ephemeral modal put_file script
import modal
import os
app = modal.App()
vol = modal.Volume.from_name("...")
@app.local_entrypoint()
def put_file(filepath: str):
src_path = os.path.abspath(filepath)
dst_path = f"/tmp/{os.path.basename(filepath)}"
@rchowell
rchowell / egg.rs
Created March 31, 2025 15:49
egg.rs
use std::collections::BTreeSet;
use egg::{rewrite as rw, *};
fn main() {
let mut egraph: EGraph<SymbolLang, ()> = Default::default();
let a = egraph.add(SymbolLang::leaf("a"));
let b = egraph.add(SymbolLang::leaf("b"));
let _ = egraph.add(SymbolLang::new("foo", vec![a, b]));
egraph.rebuild();
@rchowell
rchowell / crabtime.rs
Created March 29, 2025 03:56
crabtime_lab
const MY_NUM: usize = crabtime::eval! {
(std::f32::consts::PI.sqrt() * 10.0).round() as usize
};
// you can use #[macro_export]
#[crabtime::function]
fn gen_positions_struct() -> &str {
"
#[derive(Debug)]
@rchowell
rchowell / display.py
Created March 27, 2025 20:50
Daft DataFrame.show() using tabulate
"""
This gist shows how you can patch tabulate to print daft dataframes with options.
"""
import tabulate
from tabulate import DataRow, Line, TableFormat
# add a default which is like our rust comfytable
tabulate._table_formats["default"] = TableFormat(
@rchowell
rchowell / gist:4d0ac8889a0d7951bf2f7218deff28c8
Last active February 7, 2025 19:03
Logical plan lazy builders
package org.partiql.plan.builder
import org.partiql.plan.Collation
import org.partiql.plan.Exclusion
import org.partiql.plan.JoinType
import org.partiql.plan.rel.Rel
import org.partiql.plan.rel.RelAggregate
/**
* DataFrame style fluent-builder for PartiQL logical plans.