Skip to content

Instantly share code, notes, and snippets.

View sma's full-sized avatar

Stefan Matthias Aust sma

  • I.C.N.H GmbH
  • Kiel
View GitHub Profile
@sma
sma / review.md
Last active July 1, 2024 13:50
ChatGPT hat mir ein Review zum neuen Conan-Rollenspiel geschrieben

[Ich habe ChatGPT 4o das PDF vorgeworfen und gesagt, bitte mache mir ein ausführliches Review, zähle gute und nicht so gute Punkte auf und ziehe ein Fazit. Dies ist das leicht eingekürzte Ergebnis --sma]

Review of "Conan: The Hyborian Age" RPG Quickstart

Aussehen und Aufbau

Der "Conan: The Hyborian Age" RPG Quickstart besticht durch beeindruckende Illustrationen und ein klares Layout. Die Kunstwerke fangen die düstere, actionreiche Atmosphäre der Conan-Geschichten perfekt ein. Das Dokument ist logisch strukturiert und einfach zu navigieren, was den Einstieg erleichtert.

Charakterdefinition

Charaktere werden durch vier Hauptattribute definiert: Might, Edge, Grit und Wits. Diese reichen von 1 bis 8 und sind mit spezifischen Würfeln (D6, D8, D10) verbunden. Weitere Werte wie Physical Defense, Sorcery Defense, Life Points und Stamina Points sowie Skills und Ausrüstung bieten individuelle Anpassungsmöglichkeiten.

@sma
sma / article.md
Last active June 26, 2024 22:53
Challenging Claude 3.5 to create a simple game

I challenged -> Claude 3.5 to follow -> these way to detailed instructions to create a simple 4X "play by mail" strategy game in Dart.

It spit out ~500 lines of Dart code which I had to stitch together because it wasn't able to create the code in one go. I had to fix its usage of dynamic types with JSON decoding because I always enable strict-casts in my analysis_options.yaml, but otherwise there were no syntax errors. Compared to ChatGPT, Claude's style is a bit more "archaic", though.

Because I could have created the Dart code myself, I find it difficult to rate the AI's achievement. Do you find the result impressive? Please read my specification and try to come up with an implementation on your own.

Let's analyse -> Claude's code.

It created a Planet, a Player and a GameState class for JSON serialization and a Game class for implementing the game rules.

@sma
sma / moving_border.dart
Last active June 8, 2024 09:14
An animated moving border
import 'package:flutter/material.dart';
class MovingBorder extends StatefulWidget {
const MovingBorder({
super.key,
this.duration = const Duration(seconds: 2),
this.borderColor,
this.highlightColor,
this.borderRadius,
this.child,
@sma
sma / Makefile
Last active April 25, 2024 10:57
one billion (or at least a couple of millions) rows challenge
url=https://raw.githubusercontent.com/gunnarmorling/1brc/main/data/weather_stations.csv
prepare:
curl -s ${url} | grep -v '^#' >data2/weather.csv
dart run bin/prepare.dart 1_000_000 >data2/1m
dart run bin/prepare.dart 10_000_000 >data2/10m
dart run bin/prepare.dart 100_000_000 >data2/100m
dart run bin/prepare.dart 1_000_000_000 >data2/1g
clean:
@sma
sma / wasm_interpreter.dart
Last active April 11, 2024 12:40
A tiny, incomplete, proof of concept wasm interpreter that can add two numbers
/// A simple incomplete WebAssembly interpreter.
library;
import 'dart:io';
void main() {
// final bytes = File('sum.wasm').readAsBytesSync();
final module = WasmModule(bytes);
print(module.exports);
print(module.invoke('add', [3, 4]));

Add Flutter to an iOS Appplication

  1. Create a normal iOS App (using SwiftUI) called SmaApp.
  2. Cd into SmaApp.
  3. Run pod init and pod install in the SmaApp folder to setup Cocoapods (install it with brew install cocoapods).
  4. Add platform :ios, '17.0' to Podfile.
  5. Add Pods folder to .gitignore: echo Pods/ >.gitignore.
  6. Reopen the project using open SmaApp.xcworkspace.
  7. Build & run to make sure everything works.
  8. Run flutter --template module sma_flutter to setup Flutter.
  9. Go into sma_flutter and run flutter run (choose iOS if asked for a device).
@sma
sma / twodim.md
Created March 14, 2024 14:17
How to build a 2d scrollable hex map

Wenn man einen 2D ScrollView bauen will…

Ich will eine große Hexkarte bauen. Wenn ich naiv 200x200 Hex-Felder in einem Stack anordne (weil die sich ja überlappen) und den in einen InteractiveViewer packe, dann braucht Flutter 30 Sekunden (!) die 120.000 Widgets zu bauen.

  1. Ich muss eine Unterklasse von TwoDimensionalScrollView erstellen, die minimal ein delegate bekommt, der weiß, wie man Kinder baut. Dazu später mehr. Erst mal ist das alles nur boilerplate-Code:

    class HexMapView extends TwoDimensionalScrollView {
      const HexMapView({super.key, required super.delegate})
        : super(diagonalDragBehavior: DiagonalDragBehavior.free);
@sma
sma / bin_unpak.dart
Created March 12, 2024 22:23
a library and utility to unpack BG3 pak files
import 'dart:io';
import 'dart:math';
import 'package:unpak/unpak.dart';
void main(List<String> arguments) {
if (arguments.length < 2 || !<String>{'-l', '-x'}.contains(arguments[0])) {
stderr.writeln('usage: unpak -l <file.pak>');
stderr.writeln(' unpak -x <file.pak> <index> [<output>]');
exit(1);
@sma
sma / my_lint.dart
Created March 7, 2024 16:27
A quick & dirty tutorial how to create a custom linter for Dart
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/error/listener.dart';
import 'package:custom_lint_builder/custom_lint_builder.dart';
class MyLintPlugin extends PluginBase {
@override
List<LintRule> getLintRules(CustomLintConfigs configs) {
return [
MyLintRule(),
@sma
sma / iui.dart
Last active February 25, 2024 09:51
an immediate mode UI for Flutter
import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
// ----------------------------------------------------------------------------
class Box<T> {
Box(this.value);