Skip to content

Instantly share code, notes, and snippets.

@Broxzier
Broxzier / program.cs
Last active December 16, 2024 13:20
Example of how a spawner could skew the chances for objects to spawin in favour of the player, making it more likely to give the objects a player doesn't have while still respecting a base chance.
public class Program
{
public static void Main()
{
// Setup data
var butterfly = new Spawnable("Butterfly");
var bumblebee = new Spawnable("Bumblebee");
var cockroach = new Spawnable("Cockroach");
var spawnPoint = new SpawnPoint();
@Broxzier
Broxzier / .vb
Created November 21, 2024 11:28
A macro for time cells in Excel documents that converts inputs to time values, so that you can, for example, enter "9,5" and it would become "9:30"
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Cell As Range
' Prevent infinite loops by disabling events temporarily
On Error Resume Next
Application.EnableEvents = False
' Iterate through each cell in the range that was changed
For Each Cell In Target
' Strictly check if the cell's format is exactly "h:mm"
@Broxzier
Broxzier / quick_sort.cpp
Created October 10, 2024 20:40
This is an implementation of the quick sort algorithm, written from memory as an excersice.
#include <utility> // For std::swap
template <typename T>
void quick_sort(T array[], size_t size)
{
constexpr auto npos = (size_t{ 0 } - 1);
// Empty or doesn't need sorting
if (size <= 1)
return;
$defaultItems = @(
"Deze standaard items staan bovenaan in het script",
"Hier kun je nieuwe dingen toevoegen die er vanaf het opstarten al in staan.",
"Open dit bestandje in notepad om het aan te passen.",
"Zet aanhalingstekens ("") voor en achter de zin, en eindig met een comma (,).",
"Als je in het script een "" wil gebruiken, dan moet je deze schrijven als """".",
"Achter het laatste item in deze lijst moet geen comma staan, anders krijg je errors"
)
Add-Type -AssemblyName PresentationFramework
@Broxzier
Broxzier / Window layout file
Created April 22, 2024 09:24
Window layout language
// Some default colours
var black = { r = 0.0f, g = 0.0f, b = 0.0f, };
var white = { r = 1.0f, g = 1.0f, b = 1.0f, };
var grey = { r = 0.5f, g = 0.5f, b = 0.5f, };
var lightgrey = { r = 0.8f, g = 0.8f, b = 0.8f, };
var darkgrey = { r = 0.3f, g = 0.3f, b = 0.3f, };
var red = { r = 1.0f, g = 0.0f, b = 0.0f, };
var green = { r = 0.0f, g = 0.5f, b = 0.0f, };
var blue = { r = 0.0f, g = 0.0f, b = 1.0f, };
var lightred : red = { g = 0.2f, b = 0.2f, };
@Broxzier
Broxzier / GitHubLogin.vbs
Created October 31, 2023 08:15
Firefox private window for secondary github account
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run """C:\Program Files\Mozilla Firefox\firefox.exe"" -private-window https://github.com/login"
WScript.Sleep 4000
WshShell.SendKeys "<username or email address>{TAB}<password>{ENTER}"
@Broxzier
Broxzier / uv-coordinates.js
Created August 3, 2023 14:45
A javascript function to quickly generate a grid of UV coordinates for an .obj file
function generateVT(w, h) {
var vt = "";
for (var y = 1; y <= h; y++)
for (var x = 1; x <= w; x++)
vt += `vt ${((x-1)/(w-1)).toFixed(6)} ${((h-y)/(h-1)).toFixed(6)}\n`;
return vt;
}
@Broxzier
Broxzier / admin.bat
Created July 3, 2023 08:30
Request admin permisions from batch
@echo off
:: Ensure we're admin by checking if the last arguent is "asadmin", and if not, restart as administrator with this argument set.
for %%a in (%*) do set last=%%a
if NOT "%last%" == "asadmin" (
powershell start -WindowStyle Minimized -verb runas '%0' '%* asadmin'
exit
)
:: Ensure the working directory is the same folder as where this script is located
@Broxzier
Broxzier / main.cpp
Last active May 26, 2023 22:15
Compact int reader and writer
#include <cstdint>
#include <iostream>
#include <limits>
#include <type_traits>
int GetBitValue(const std::uint8_t* data, int offset)
{
constexpr auto BitsPerByte = std::numeric_limits<std::decay_t<decltype(*data)>>::digits;
static_assert(BitsPerByte != 0, "Unknown bit size for type");
@Broxzier
Broxzier / Condition.h
Last active April 25, 2023 21:46
Draft of how a scenario objective system could be made
#pragma once
#include <variant>
#include "Deadline.h"
#include "GuestCount.h"
#include "ParkValue.h"
namespace Objectives
{