Skip to content

Instantly share code, notes, and snippets.

View Niriel's full-sized avatar

Niriel Niriel

View GitHub Profile
@Niriel
Niriel / rvo_provider_monitoring.py
Created March 21, 2024 15:10
Rvo Provider Monitoring
from http.server import BaseHTTPRequestHandler, HTTPServer
from datetime import datetime
import urllib.request
import urllib.error
from bs4 import BeautifulSoup
TIMEOUT = 2.0 # seconds
HOST_NAME = "localhost"
SERVER_PORT = 8080
@Niriel
Niriel / bounded_floats.cpp
Last active July 27, 2023 14:52
C++ bounded floats
#include <iostream>
#include <cmath>
#include <cassert>
#define DEBUG_BOUNDS 1 // 1 enabled, 0 disabled.
class BoundedFloat {
private:
float _value;
tool
extends Spatial
export var debug_run := false setget set_debug_run
onready var sun_light: DirectionalLight = $SunLight
onready var world_env: Environment = $WorldEnvironment.environment
func _ready():
env_to_light()
@Niriel
Niriel / shelved.py
Last active February 11, 2020 12:19
import hashlib
import pickle
import shelve
from decorator import decorator
SHELF: shelve.DbfilenameShelf
def _make_key(version, func, args, kwargs):
@Niriel
Niriel / resumable.py
Last active January 28, 2020 14:50
Pause/resume/load/save a long data analysis process
import datetime
import pickle
import time
import tkinter as tk
from dataclasses import dataclass
from enum import Enum
from functools import partial
from multiprocessing import Process
from multiprocessing.connection import Connection, Pipe
from pathlib import Path
@Niriel
Niriel / restrict_method_access.py
Created January 21, 2020 12:53
Python method that can't even be accessed if some condition is False
# Dunno how useful it could be. Whatever.
import types
class Monoid:
def __init__(self, xs):
self.xs = xs
@classmethod
@Niriel
Niriel / xmonad.hs
Last active September 10, 2016 23:20
My xmonad configuration. Java hack inside.
import XMonad
import XMonad.Config.Gnome
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageHelpers -- (isFullscreen, doFullFloat)
import XMonad.Hooks.SetWMName --hack to fix broken sun java
import XMonad.Layout.NoBorders
import XMonad.Util.CustomKeys
import Control.OldException
import Monad -- (when)
import Data.Monoid (All (All)) -- (All)
@Niriel
Niriel / daggerfall.conf
Created August 14, 2013 12:50
My dosbox config file for Daggerfall.
# This is the configuration file for DOSBox 0.74. (Please use the latest version of DOSBox)
# Lines starting with a # are comment lines and are ignored by DOSBox.
# They are used to (briefly) document the effect of each option.
[sdl]
# fullscreen: Start dosbox directly in fullscreen. (Press ALT-Enter to go back)
# fulldouble: Use double buffering in fullscreen. It can reduce screen flickering, but it can also result in a slow DOSBox.
# fullresolution: What resolution to use for fullscreen: original or fixed size (e.g. 1024x768).
# Using your monitor's native resolution with aspect=true might give the best results.
# If you end up with small window on a large screen, try an output different from surface.
@Niriel
Niriel / gist:5311471
Created April 4, 2013 15:37
A Python implementation of Arrows (such as seen in Haskell).
#! /usr/bin/python
"""Implementation of the arrow abstraction for functions.
Abstracting functions with Arrows has advantages. Arrows make it very easy to
compose functions (by simply 'multiplying' them with the `*` operator). The
order in which the arrows are written match the order of the computations,
making long pipelines easy to work with. Arrows also provide mechanisms for
creating and merging branches, which helps when a value needs to be consumed by
several functions, or when a function needs values from several sources. Arrows
can also support conditional application, selecting which of two functions f and
@Niriel
Niriel / gist:5194870
Last active December 15, 2015 03:29
This is how I lock SDL and OpenGl to the main thread in go.
//============== threadlock.go
package threadlock
import "runtime"
// A threadlock contains a queue of functions to execute on a given OS thread.
type ThreadLock chan func()
// Blocking call that consumes the queue, executing all the functions until the channel is closed.
func (self ThreadLock) Lock() {