Skip to content

Instantly share code, notes, and snippets.

@maludwig
maludwig / fastest_first_key.py
Created January 10, 2023 20:39
What is the fastest way to get the first key in a dictionary?
from time import perf_counter_ns
NANOS_PER_SECOND = 1_000_000_000
ITER_COUNT = 100_000
biased_dict = {"one_key_to_rule_them_all": 42}
def first_1():
@maludwig
maludwig / lift.py
Created March 20, 2022 19:45
Timberborn World Lifter
#!/usr/bin/env python3
"""
Requires python 3 or higher
Usage:
This would lift a custom map, saved as "my_custom_map" by 8 blocks up vertically.
I doubt this will work with save files, but it should produce a new .timber file you can create a new game on
python --timber-path C:\Users\mitchell.ludwig\Documents\Timberborn\Maps\my_custom_map.timber --lift-by 8
"""
@maludwig
maludwig / arcade_osx_bug.py
Created February 25, 2019 00:12
Describes a bug with retina displays
import colorsys
from itertools import cycle
from math import floor
import arcade
from arcade.color import WHITE, RED, GREEN, BLUE
from pyglet import gl
WINDOW_WIDTH = 1000
WINDOW_HEIGHT = 600
@maludwig
maludwig / Application.java
Created November 12, 2018 06:45
Jackson deduping resolver
package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
@maludwig
maludwig / generating_high_precision_arrows.py
Created August 16, 2018 01:09
Testing out high precision Arrow generating methods
#!/usr/bin/env python3.7
# Requires Python 3.7 to run all tests
# Requires arrow: "pip install arrow"
import datetime
import time
import arrow
import json