Skip to content

Instantly share code, notes, and snippets.

View jordanorelli's full-sized avatar
🎴

Jordan Orelli jordanorelli

🎴
View GitHub Profile
@jordanorelli
jordanorelli / contention.py
Created July 31, 2026 14:36
asyncio scheduler contention
import asyncio
import time
async def badguy():
# await asyncio.sleep(0.001) # 1ms
time.sleep(0.499) # 499ms
async def goodguy():
@jordanorelli
jordanorelli / main.rs
Created July 29, 2026 21:08
sudoku generator and solver
#![allow(uncommon_codepoints, confusable_idents, mixed_script_confusables)]
//! 🧩🎲🔢✨
use clap::{Parser, Subcommand};
use rand::rngs::ThreadRng;
use rand::seq::SliceRandom;
use std::io::Read;
use thiserror::Error;
/// 💥🧩😵
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",