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 / basic.dart
Created September 18, 2024 17:06
A Basic interpreter thrown together with ChatGPT
import 'dart:async';
import 'package:flutter/material.dart';
void main() => runApp(const BasicInterpreterApp());
class BasicInterpreterApp extends StatelessWidget {
const BasicInterpreterApp({super.key});
@override
Widget build(BuildContext context) {
@sma
sma / triangle_progress.dart
Created September 15, 2024 09:36
A triangle shaped progress indicator
import 'dart:math';
import 'package:flutter/material.dart';
class TriangleProgress extends StatelessWidget {
final double value;
const TriangleProgress({super.key, required this.value});
@override
Widget build(BuildContext context) {
import 'package:flutter/material.dart';
class RangeModel {
RangeModel(this.position, this.width);
final Offset position;
final double width;
}
class RangeView extends StatelessWidget {
import 'package:flutter/material.dart';
void main() {
runApp(App());
}
class App extends StatelessWidget {
const App({super.key});
@override
@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).