Skip to content

Instantly share code, notes, and snippets.

@tliron
tliron / asset_reference.rs
Created May 15, 2024 19:56
Bevy AssetReference
use bevy::asset::{io::*, *};
use serde::*;
use tracing::*;
/// A serializable reference to an asset based on its path. It can only work for
/// assets that have paths.
///
/// A common use case is to refer to an asset in settings for an [AssetLoader],
/// which must be serializable.
///
@tliron
tliron / fixed_thread_pool_executor.py
Last active September 26, 2022 21:32
Python fixed thread pool exuector
from threading import Thread, Lock
from Queue import Queue
import itertools, traceback, multiprocessing
class FixedThreadPoolExecutor(object):
"""
Executes tasks in a fixed thread pool.
Makes sure to gather all returned results and thrown exceptions in one place, in order of task
submission.
@tliron
tliron / bind-port-privilege.sh
Created April 5, 2016 18:29
Give Linux executables the privilege to bind to ports below 1024
#!/bin/bash
if (( $# != 2 )); then
echo 'Control whether an executable has the privilege to bind to ports < 1024, even if the user is not root'
echo
echo "Usage: $(basename "$0") [enable|disable|status] [path-to-exectuable]"
exit 1
fi
FILE=$(readlink -f "$2")
@tliron
tliron / rest.py
Last active August 9, 2024 13:43
Simple and functional REST server for Python (2.7) using no dependencies beyond the Python standard library.
#!/usr/bin/env python
'''
Simple and functional REST server for Python (2.7) using no dependencies beyond the Python standard library.
Features:
* Map URI patterns using regular expressions
* Map any/all the HTTP VERBS (GET, PUT, DELETE, POST)
* All responses and payloads are converted to/from JSON for you