Skip to content

Instantly share code, notes, and snippets.

View Wavesonics's full-sized avatar

Adam Brown Wavesonics

View GitHub Profile
@Wavesonics
Wavesonics / WallClockTimer.gd
Last active February 7, 2023 22:21
A real-time timer for synchronizing events in Godot across multiple clients to within 1 second of each other, which for my use case was good enough. It's API is meant to be a drop-in replacement for the default Timer node. Additionally it solved the problem of Timers in Godot being effected by poor performance. On a slower computer that is being…
# A drop in replacement for the Timer class
# This timer is completely framerate independent
# It can also be given a unix time stamp instead of a duration
# for when it should fire. This is useful for synchornizing events
# across multiple clients such as in Multiplayer
extends Node
class_name WallClockTimer, 'res://utilities/wallclock_timer/icon.png'
signal timeout
@Wavesonics
Wavesonics / DiffusionHeatMap.cpp
Created March 13, 2020 07:03
Thermal diffusion algirothm
void DiffusingHeatMap::_physics_process(float delta)
{
clearBackBuffer();
for(int yy = 0; yy < mapSize; ++yy)
{
for(int xx = 0; xx < mapSize; ++xx)
{
diffuse(xx, yy);
}
@Wavesonics
Wavesonics / DropDown.kt
Last active January 14, 2023 00:43
A Dropdown box composable
@Composable
fun <T> DropDown(
modifier: Modifier = Modifier,
padding: Dp = 16.dp,
items: List<T>,
defaultIndex: Int = 0,
onValueChanged: (T) -> Unit
) {
var selectedIndex by remember { mutableStateOf(defaultIndex) }
var itemsExpanded by remember { mutableStateOf(false) }
@Wavesonics
Wavesonics / remove-onedrive.ps1
Created June 25, 2024 02:08
A Shell script to remove OneDrive, move files to their proper directories, and fix paths in your registry
# Description:
# This script will remove and disable OneDrive integration.
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\New-FolderForced.psm1
Import-Module -DisableNameChecking $PSScriptRoot\..\lib\take-own.psm1
Write-Output "Kill OneDrive process"
taskkill.exe /F /IM "OneDrive.exe"
taskkill.exe /F /IM "explorer.exe"
@Wavesonics
Wavesonics / DictionaryTransform.ipynb
Created November 16, 2024 23:32
Normalize the frequency dictionary and show the top 100 values
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Wavesonics
Wavesonics / debounceUntilQuiescent.kt
Created November 17, 2024 03:52
Debounce a Flow's emissions until it is quite for some period
fun <T> Flow<T>.debounceUntilQuiescent(duration: Duration): Flow<T> = channelFlow {
var job: Job? = null
collect { value ->
job?.cancel()
job = launch {
delay(duration)
send(value)
job = null
}
}