Skip to content

Instantly share code, notes, and snippets.

View jordanorelli's full-sized avatar
🎴

Jordan Orelli jordanorelli

🎴
View GitHub Profile
def cool():
n = 0
while True:
delta = yield n
if delta is not None:
n += delta
else:
n += 1
@jordanorelli
jordanorelli / timeouts.py
Last active August 22, 2025 16:29
asyncio timeouts are cursed
import asyncio
import time
import random
from collections.abc import Callable
def roll(dice: int = 1, sides: int = 6) -> int:
total = 0
for _ in range(dice):
total += random.randint(1, sides)
@jordanorelli
jordanorelli / my_async.py
Created August 9, 2025 21:57
async python without asyncio lol dave beazley good job
import time
import heapq
from collections import deque
def switch():
return Awaitable()
class Awaitable:
@jordanorelli
jordanorelli / es_container.py
Created October 21, 2024 16:00
starts an openseach container with python
import time
import docker
from docker.models.containers import Container
keep_container = False
docker_client = docker.from_env()
def wait_healthy(container_name):
use std::rc::Rc;
pub enum List<T> {
Node { value: T, next: Rc<List<T>> },
Empty,
}
impl <T> List<T> {
pub fn empty() -> Self {
List::Empty
// iterators2.rs
// In this exercise, you'll learn some of the unique advantages that iterators
// can offer. Follow the steps to complete the exercise.
// Execute `rustlings hint iterators2` or use the `hint` watch subcommand for a hint.
// Step 1.
// Complete the `capitalize_first` function.
// "hello" -> "Hello"
pub fn capitalize_first(input: &str) -> String {
let mut c = input.chars();
// errors6.rs
// Using catch-all error types like `Box<dyn error::Error>` isn't recommended
// for library code, where callers might want to make decisions based on the
// error content, instead of printing it out or propagating it further. Here,
// we define a custom error type to make it possible for callers to decide
// what to do next when our function returns an error.
// Execute `rustlings hint errors6` or use the `hint` watch subcommand for a hint.
@jordanorelli
jordanorelli / settings.json
Created August 29, 2022 19:42
git bash in windows terminal
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions": [],
"defaultProfile": "{00000000-0000-0000-ba54-000000000002}",
"profiles":
{
"defaults":
{
"antialiasingMode": "cleartype",
@jordanorelli
jordanorelli / export.py
Created April 22, 2022 02:09
static mesh exporter for blender to unity
from math import pi
import bpy
import os
import copy
# export to blend file location
dirname = os.path.dirname
basedir = dirname(dirname(dirname(bpy.data.filepath)))
export_dir = os.path.join(basedir, "Assets", "Models")
package merge
import (
"testing"
)
func TestMergeTables(t *testing.T) {
alice := Table[string, *additive]{
"vanilla": add(3),
"chocolate": add(5),