Skip to content

Instantly share code, notes, and snippets.

@jtanx
jtanx / enctest.c
Created March 21, 2021 10:04
fontforge encoding comparison
#include <stdio.h>
#include <utype.h>
#include <chardata.h>
#include <encoding.h>
static int umodenc(int enc, int modtype)
{
if (modtype == -1)
return (-1);
@jtanx
jtanx / CMakeLists.txt
Created July 5, 2022 11:16
Working example of writing a Parquet file in C++
cmake_minimum_required(VERSION 3.10)
project(parq)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
find_package(Arrow REQUIRED)
add_executable(parq park.cc)
@jtanx
jtanx / polars_multi_collect.py
Created September 28, 2024 11:38
Single pass collection of multiple polars lazyframes
import polars as pl
df = pl.LazyFrame({"A": range(1, 100), "B": range(100, 1, -1)})
df = df.filter(pl.col("A") > 20, pl.col("B") < 50)
df1 = df.with_columns(pl.col("A") * 2)
df2 = df.with_columns(pl.col("B") / 2)
# https://github.com/pola-rs/polars/issues/13065
# This will result in re-evaluating the initial filter twice
@jtanx
jtanx / chunks.py
Created November 15, 2024 23:24
datetime chunking
import datetime as dt
from functools import partial
from typing import Any
import pandas as pd
from dateutil import relativedelta
def next_chunk(st: pd.Timestamp, et: pd.Timestamp, freqs: list[Any]):
if st == et: