Skip to content

Instantly share code, notes, and snippets.

View arnemileswinter's full-sized avatar

Arne Winter arnemileswinter

View GitHub Profile
@arnemileswinter
arnemileswinter / PlaneModelFactory.java
Last active August 8, 2019 10:34
LibGdx ModelBuilder box with faces seperated
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.VertexAttributes;
import com.badlogic.gdx.graphics.g3d.Material;
import com.badlogic.gdx.graphics.g3d.Model;
import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute;
import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder;
/**
* Used to render boxes with their faces seperated.
*/
@arnemileswinter
arnemileswinter / VueRouterNavigation.js
Last active June 9, 2020 04:00
Vue Router Plugin to support forwards&backwards navigation
/*
Vue navigation plugin that remembers history not as a plain-old array, but properly lets you navigate through it.
This is useful for example in order to implement back-buttons.
The existing implementations I've found did not use Vue's Observable feature though, which is why I've created this,
further i did not find any implementation supporting vue-router's `replace` API.
In order for `replace` to work, you must replace calls to `$router.replace('/myRoute')` with `$navigation.replace(`/myRoute`)`.
There is also the alternative to vue-routers `push`, `$navigation.push()` but that's just for convenience.
Author: Arne Miles Winter
@arnemileswinter
arnemileswinter / recurseInterval.hs
Created December 25, 2021 18:34
Haskell function to repeat an IO action repeatedly, analogous to javascript's setInterval, with the addition of receiving a time delta. Personally used for a game server's main tick-loop.
import Data.Time.Clock.POSIX (getPOSIXTime) -- from `time` package.
import Control.Concurrent (threadDelay)
{- | Repeats IO action repeatedly on single thread, taking action running-time into account when waiting for next repetition.
__Examples__:
@
secondsToMicros = (*) (10 ^ 6)
millisToMicros = (*) (10 ^ 3)
@arnemileswinter
arnemileswinter / hs-redlock.hs
Last active January 23, 2022 19:00
Distributed locks with Redlock ported to Haskell. See https://redis.io/topics/distlock
-- |
-- Module : Database.Redis.Redlock
-- Copyright : (c) 2022 Arne Miles Winter
--
-- License : MIT
--
-- Maintainer : https://github.com/arnemileswinter
-- Stability : experimental
-- Portability : portable
--
@arnemileswinter
arnemileswinter / ITC.hs
Created July 1, 2022 16:39
Haskell Implementation of Interval Tree Clock
{- | Author: Arne Winter
| Date: 01/07/2022
| Description: Haskell implementation of interval tree clocks, as per the paper
Almeida, Paulo & Baquero, Carlos & Fonte, Victor. (2008). Interval Tree Clocks: A Logical Clock for Dynamic Systems. 5401. 259-274. 10.1007/978-3-540-92221-6_18.
-}
module ITC (
Stamp (..),
ITCId (..),
ITCEvent (..),
fmtStamp,
module MondayTutorial where
{- class MyList<T> {
private T value;
private MyList<T> next;
MyList(){}
MyList(T value, MyList<T> next){
Objects.requireNonNull(next);
this.value = value;
@arnemileswinter
arnemileswinter / frequency.rs
Created January 16, 2023 23:04
Rust snippet using avr-hal: Manual PWM to pull a digital output pin on an arduino to specified Hertz frequency. Useful to operate buzzers.
use arduino_hal::{clock::Clock,port::{mode::Output, Pin, PinOps}};
/// Pull an arduino's output pin to specified Hertz for microseconds duration.
/// This is essentially manual PWM, without avr-hal's clock prescaling.
/// Useful to make buzzers oscillate at 440 hertz.
/// This is not measured to be precise but works well enough.
///
/// example:
/// let dp = arduino_hal::Peripherals::take().unwrap();
/// let pins = arduino_hal::pins!(dp);