Skip to content

Instantly share code, notes, and snippets.

@antont
antont / ec.xml
Created September 24, 2011 23:47
drafting an xml spec for txml
<scene>
<entity id="1">
<!--name>
<name>Bird</name>
<description>A flying bird</description>
</name-->
<name name="Bird" description="A flying bird" />
<!-- mesh>
<meshref>bird.mesh</meshref>
<materialref index=0>feathers.material</materialref>
@antont
antont / getpositions.py
Created October 7, 2013 06:36
read 3d ob positions from txml in python and output them as json for easier use in e.g. web clients
from xml.etree.ElementTree import ElementTree
import xml.etree.ElementTree as ET
import sys
if len(sys.argv) != 2:
print "Giev filename!"
sys.exit(1)
@antont
antont / Kymmenen kertaa pienempi.ipynb
Last active August 29, 2015 14:26
Kymmenen kertaa pienempi
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import json
import sys
F = sys.argv[1]
print(F)
#F = "just60.json"
#F = "c-asus_nvidia.json"
#F = TimelineRawData-20160412T120624.json"
@antont
antont / Toggle3D.cs
Created November 11, 2017 21:48
Unity: Toggle3D and ToggleGroup3D, for selecting 3D objects similarily to how Unity.UI Toggles and ToggleGroup works. Ported from those counterparts.
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Toggle3D : MonoBehaviour {
// group that this toggle can belong to
[SerializeField]
private ToggleGroup3D m_Group;
@antont
antont / csv2cue.py
Last active June 18, 2023 13:38
Serato History CSV to Mixcloud compatible CUE converter, with time offset
import csv
import datetime
session_start_time = datetime.datetime(2018, 8, 31, 22, 57, 27)
print("FILE \"swingit_vol1.mp3\" MP3")
with open('edit-31.8.2018.csv') as csvfile:
reader = csv.reader(csvfile)
@antont
antont / Time Series Multi-Line.md
Created September 10, 2018 10:58 — forked from jonmitten/Time Series Multi-Line.md
Temperature Graph with threshold lines

A graph that interprets IoT temperature device through time, tracking internal to a refrigerator and external to a refrigerator.

Written in D3, and visible here

Gist available here

"""
fastapi-cache decorator modified for SQLModel use.
Also, caches and serves the final JSON, instead of Python objects.
Thus looses pydantic validation of the response objects up in fastapi,
but this cache func does `response_model.from_orm` itself, so runs the same validation.
Elsewhere, there's an example that uses unmodified fastapi-cache with SQLModel, that works too
https://github.com/jonra1993/fastapi-alembic-sqlmodel-async/blob/main/fastapi-alembic-sqlmodel-async/app/api/v1/endpoints/cache.py
"""
@antont
antont / asynctask_thread.py
Last active October 6, 2023 10:22
Python thread to run async tasks in the background, in a single eventloop & thread
import threading
import asyncio
from queue import Queue
import time
from typing import Awaitable
import flask
from firebase_functions.private import serving
concurrent_handler_id = 0
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {font-family: Arial;}
/* Style the tab */
.tab {