Skip to content

Instantly share code, notes, and snippets.

View hastebrot's full-sized avatar

Benjamin Gudehus hastebrot

  • Freiheit.com
  • Hamburg, Germany
  • 04:00 (UTC +01:00)
View GitHub Profile
export const HomePage = () => {
return (
<SiteLayout>
<div className="flex">
<SitePanel></SitePanel>
<SiteContainer></SiteContainer>
</div>
</SiteLayout>
)
}
@hastebrot
hastebrot / ECS notes.md
Created September 17, 2020 06:04 — forked from dakom/ECS notes.md
ECS with sparse array notes (EnTT style)

Intro

The below is a breakdown / bird's eye view of how a sparse-array backed ECS like EnTT or Shipyard works.

Please see the thanks and references at the bottom - without their help I would not have been able to share this breakdown with you... everything here is really just notes and rephrasing of what they've written already :)

Also, these notes do not cover archetype systems (like unity) nor adaptations of archetypes (like in Flecs). Though there's a couple comparative footnotes at the end.

Here we go!

@hastebrot
hastebrot / main.dart
Created September 8, 2020 21:05 — forked from ds84182/main.dart
Flutter GPU memory growth repro
import 'dart:async';
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'dart:ui' as ui;
void main() => runApp(MyApp());
int xorshift32(int x) {
x ^= x << 13;
@hastebrot
hastebrot / fezrotate.js
Created January 29, 2020 02:32 — forked from veeenu/fezrotate.js
Fez-like world rotation
/*
* Procedurally generated Minecraft dirt texture.
*/
(function() {
var ctx, imgd;
ctx = document.getElementById('texture').getContext('2d');
imgd = ctx.createImageData(64, 64);
@hastebrot
hastebrot / ctpuzzle.c
Created November 24, 2019 09:38
Solver for the c't puzzle by Uli Schuhmacher.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define C if
#define T void
#define P NULL
#define U while
#define Z break
#define S return
#define L typedef
@hastebrot
hastebrot / Blocks.txt
Last active November 6, 2019 09:11
Unicode Character Database (12.1.0)
# Blocks-12.1.0.txt
# Date: 2019-03-08, 23:59:00 GMT [KW]
# © 2019 Unicode®, Inc.
# For terms of use, see http://www.unicode.org/terms_of_use.html
#
# Unicode Character Database
# For documentation, see http://www.unicode.org/reports/tr44/
#
# Format:
# Start Code..End Code; Block Name
import React from "react"
import createStore from "storeon"
import useStoreon from "storeon/react"
import StoreContext from "storeon/react/context"
import produce from "immer"
import { Pane, Button } from "fannypack"
export default () => {
return (
<StoreContext.Provider value={store}>
import React, { Fragment, useState, useEffect } from "react"
// this is similar to react's render().
export default () => {
const [state, setState] = useState({ count: 1 })
// this is similar to react's componentDidMount().
useEffect(() => {
setState({ count: 2 })
timeout(500, () => {
; The official HD AI
; An Artificial Intelligence Script written by Archon and Promiskuitiv
; Get in contact with Promiskuitiv by sending a mail to [email protected]
; List of taunts it reacts to:
; Standard taunts.
; 33 - Stop slinging resources. If slinging is requested early and is immediately canceled it may mess up the strategy.
; 38 - Sling Resources. Human player only, stops any unit production except for civilian units.

1. Separation of immutable and mutable logic

Quite a lot of different people have been on the same trail of thought. Gary Bernhardt's formulation of a "functional core, imperative shell" seems to be the most voiced.

"Boundaries" - Gary Bernhardt

"Imperative shell" that wraps and uses your "functional core".. The result of this is that the shell has fewer paths, but more dependencies. The core contains no dependencies, but encapsulates the different logic paths. So we’re encapsulating dependencies on one side, and business logic on the other side. Or put another way, the way to figure out the separation is by doing as much as you can without mutation, and then encapsulating the mutation separately. Functional core — Many fast unit tests. Imperative shell — Few integration tests

https://www.youtube.com/watch?v=yTkzNHF6rMs