Skip to content

Instantly share code, notes, and snippets.

View Warwolt's full-sized avatar

Rasmus Källqvist Warwolt

  • Mojang Studios
  • Stockholm
View GitHub Profile
@AidanSun05
AidanSun05 / DockBuilderExample.cpp
Created February 5, 2022 00:29
A commented example for Dear ImGui's DockBuilder API.
// The DockBuilder API is still marked as experimental, include Dear ImGui's internal header to pull the functions in:
#include "imgui_internal.h"
// [...]
// Beginning of main loop
// 1. DockBuilder functions only need to run once to take effect.
// This state variable will let us check for the first frame of the app.
static bool firstLoop = true;
@fworks
fworks / install-zsh-windows-git-bash.md
Last active August 12, 2025 14:25
Zsh / Oh-my-zsh on Windows Git Bash
@mortie
mortie / chrono-cheat-sheet.md
Last active August 4, 2025 18:26
std::chrono cheat sheet for the every-day programmer

Chrono cheat sheet

For the every-day programmer who needs to get shit done instead of fighting type errors.

If your application deals with times in any meaningful way, you should probably want to actually store time_points and durations and what-not; chrono has a pretty rich vocabulary for talking about time-related concepts using the type system. However, sometimes you just need to do something simple, like timing how long something takes, which is where chrono becomes overly complex, hence this cheat sheet.

All examples will assume #include <chrono>.

I just want to time something, then print the result

@PrestonKnopp
PrestonKnopp / optional.gd
Last active September 20, 2023 21:15
Attempt at Optionals in GDScript
# optional.gd
#
# Caveat
# ------
# This only works with types inheriting from Object. Built-in types don't work
# with the call api. Built-ins can still be fetched but they cannot be operated
# on.
#
# This can be fixed by subclassing optional and adding type specific methods
# that wrap the builtin type.
@obsoke
obsoke / FYT_Rust_Notes.md
Created January 4, 2017 04:06
Fix Your Timestep Notes - Rust Style

Simple: Fixed Delta Time

let mut t: 0.0;
let dt = 1.0 / 60.0;

loop {
    update(t, dt);
    render();
@jlgerber
jlgerber / CMakeLists.txt
Last active May 21, 2024 20:28
cmake - handling executable and library with same name
# Lets say we want to add a library and an executable, both with the same name.
# In this example, it is resman
add_library(resman ${src_cpps} ${src_hpps} )
target_link_libraries(resman ${Boost_LIBRARIES} ${LIBYAML} ${LIBFMT})
#
# Add resman executable
#
# We call the executable resman-bin
add_executable(resman-bin main.cpp )
@andymatuschak
andymatuschak / States-v3.md
Last active August 16, 2025 08:46
A composable pattern for pure state machines with effects (draft v3)

A composable pattern for pure state machines with effects

State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?

There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.

Here I present a composable pattern for pure state machiness with effects,

function prompt
{
# Determine if Powershell is running as Administrator
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal( [Security.Principal.WindowsIdentity]::GetCurrent() )
$isAdmin = $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
$leftCharCount = 0
$middleCharCount = 0
$rightCharCount = 0
@Cheeseness
Cheeseness / gist:8a49668d0a43278b72b2
Last active May 16, 2024 03:28
C++ SDL Fullscreen Toggle
/*
* A function for toggling windowed mode in a C++ SDL app. Fullscreen windows will appear on whichever screen the window was on.
*
* Could be used in conjunction with SDL_GetDisplayName(int displayIndex)
* and SDL_GetNumVideoDisplays(void) to programmatically force fullscreen onto a particular display
*/
void toggleWindowed()
{
//Grab the mouse so that we don't end up with unexpected movement when the dimensions/position of the window changes.