This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Toml Everywhere | |
A wrapper that allows any command line program to have a `--config` flag. | |
No explicit support required! | |
Call as: | |
$ toml_everywhere.py program [argument ...] --config config.cfg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simplified PathType | |
- Simplify for common case | |
- Only one type, no more (never used really) | |
- No dash support, just simplier | |
- No symilnk (never used) | |
A helper type for input validation in argparse for paths. | |
This provides a convienent way to check the path type and existance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
PathType | |
A helper type for input validation in argparse for paths. | |
This provides a convienent way to check the paths type, existance, and | |
potentially use "-" to reference stdin or stdout. | |
This class is provided as an alternative to argparse.FileType(), which | |
does not open the path, only validates it and supports directories. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Because it turns out writing files is hard | |
# Process can crash halfway through, and a collision can overwrite the file | |
# mid operation. | |
# https://stackoverflow.com/questions/7645338/how-to-do-atomic-file-replacement | |
# http://www.weirdnet.nl/apple/rename.html | |
import os | |
import hjson | |
import filelock | |
def safe_json_read(filename, timeout = None): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Simply little utility function to make it possible to pickle generators. | |
While generator instances can not actually be pickled, this saves the generator | |
function and only creates a generator instance when the first value is accessed. | |
The goal is to make it possible to pass generators, with arguments, through multiprocessing | |
which uses pickling internally to move objects between Python processes. | |
import multiprocessing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://en.wikipedia.org/wiki/Reuleaux_triangle | |
import math | |
import cairo | |
def pos_on_circle(cx, cy, radius, angle): | |
# Convert polar to cartesian, Author: Matthew Schweiss | |
x = math.cos(angle) * radius + cx | |
y = math.sin(angle) * radius + cy | |
return x, y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
JAVA="java" | |
JAR="paper-1.18.1-101.jar" | |
RAM="2000M" | |
FLAGS="-XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Daikars.new.flags=true -Dusing.aikars.flags=https://mcflags.emc.gs" | |
echo "Starting server..." | |
${JAVA} -Xmx${RAM} -Xms${RAM} ${FLAGS} -jar ${JAR} --nogui |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import array | |
def test_signed(typecode): | |
try: | |
a = array.array(typecode) | |
# Create byte representation of exactly one item | |
byte_item = bytes() | |
for i in range(a.itemsize): |
NewerOlder