Skip to content

Instantly share code, notes, and snippets.

@B-Reif
B-Reif / grid_neighbors_mut.rs
Created May 4, 2021 19:56
Grid Mutation Iterator
struct GridNeighborsMut<'a> {
grid: &'a mut Grid,
point_x: usize,
point_y: usize,
count: usize,
}
impl<'a> Iterator for GridNeighborsMut<'a> {
type Item = &'a mut Elevation;
fn next(&mut self) -> Option<Self::Item> {
unsafe {
@B-Reif
B-Reif / camera.rs
Created May 4, 2021 00:50
Chunk auto_spawn bug
use bevy::prelude::*;
pub fn setup_system(mut commands: Commands) {
println!("Spawning Camera bundle...");
commands
.spawn()
.insert_bundle(OrthographicCameraBundle::new_2d());
}
@B-Reif
B-Reif / ControlledExpander.fs
Created January 25, 2021 01:13
controlled expander sketch
[<Struct>]
type ControlledState =
| Writing
| Resetting
| Listening
type ControlledExpander() =
inherit Expander()
interface IStyleable with
@B-Reif
B-Reif / Domain.fs
Created January 8, 2021 00:35
Program breaks when switching tabs while an item is selected
namespace FuncUITypeRepro
open Avalonia.Controls
open Avalonia.FuncUI.Components
open Avalonia.FuncUI.DSL
open Avalonia.Layout
module Domain =
type RecordA = { Title: string; Pages: int }
type RecordB = { Cost: float; Paid: bool }
@B-Reif
B-Reif / redux_orm.js
Last active December 20, 2017 19:25
my stab at redux-orm flow-typing
declare module "redux-orm" {
declare export class Model<I> {
// Static properties
static all: () => QuerySet<this>;
static filter: (filterArg: {} | (this => boolean)) => QuerySet<this>;
static first: () => this | typeof undefined;
static create: (props?: {}) => this;
static get: (lookupObj: {}) => this;
static hasId: (id: I) => boolean;
static withId: (id: I) => this;