Skip to content

Instantly share code, notes, and snippets.

View timsneath's full-sized avatar

Tim Sneath timsneath

View GitHub Profile
$ aqueduct document client
-- Aqueduct CLI Version: 3.0.0
-- Aqueduct project version: 3.0.0
*** Uncaught error
[Bad state: Invalid documenter 'HeroesController'. Reached end of controller chain and found no operations. Path has summary 'null'., #0 Controller.documentOperations (package:aqueduct/src/http/controller.dart:307:9)
#1 Controller.documentOperations (package:aqueduct/src/http/controller.dart:313:28)
#2 _RouteController.documentPaths.<anonymous closure> (package:aqueduct/src/http/router.dart:219:27)
#3 _ListBase&Object&ListMixin.fold (dart:collection/list.dart:218:22)
#4 _RouteController.documentPaths (package:aqueduct/src/http/router.dart:195:27)
#5 Router.documentPaths.<anonymous closure> (package:aqueduct/src/http/router.dart:145:24)
@timsneath
timsneath / keybase.md
Created March 19, 2019 22:45
Keybase Proof

Keybase proof

I hereby claim:

  • I am timsneath on github.
  • I am timsneath (https://keybase.io/timsneath) on keybase.
  • I have a public key ASBuO4qNQ37lc4xluDGHePGwLrbrh2z2Zj4trHu7OUugXgo

To claim this, I am signing this object:

import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Text Editing Demo',
home: SafeArea(
@timsneath
timsneath / main.dart
Created December 2, 2019 02:00
Advent of Code: Day 1
import 'dart:io';
int fuelMassForModule(int moduleMass, [int massSoFar = 0]) {
var mass = (moduleMass / 3).floor() - 2;
if (mass <= 0) {
return 0;
} else {
return mass + fuelMassForModule(mass, massSoFar);
}
@timsneath
timsneath / knownfolder.dart
Created March 31, 2020 22:34
Buggy attempt to call SHGetKnownFolder from Dart
// knownfolder.dart
// Shows usage of Shell APIs to retrieve the user's home directory
import 'dart:ffi';
import 'package:ffi/ffi.dart';
////////////////////////////////////////////////////////////////////////////////
// DEFINES /////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(debugShowCheckedModeBanner: false, home: HomeScreen());
}
}
import 'dart:ffi';
class LOGFONT extends Struct {
// Should be (5 * 4) + (8 * 1) + (8 * 8) bytes = 92 bytes
// sizeOf<LOGFONT>() is 96 bytes
@Int32()
int lfHeight;
@Int32()
int lfWidth;
@Int32()
String numToString(BigInt number) {
final buf = StringBuffer();
for (var v = 0; v < 8; v++) {
final charCode = (number & BigInt.parse('0xFF' + ('00' * v))) >> v * 8;
buf.write(String.fromCharCode(charCode.toInt()));
}
return buf.toString();
}
@timsneath
timsneath / msgbox.dart
Last active April 10, 2021 15:22
MessageBox with Dart FFI -- a simple example
// msgbox.dart
// Demonstrates a simple example of calling a Win32 API directly from Dart code.
// This sample relies on the ffi package. Download these two files to an empty
// directory and run `pub get` to download the ffi package prior to running this
// example.
import 'dart:ffi';
import 'package:ffi/ffi.dart';
@timsneath
timsneath / msgbox.dart
Last active June 16, 2020 21:21
Code fragment for embedding. See https://gist.github.com/timsneath/181092c75864001ca37b1b1495b9b396 for a full example that you can run.
typedef MessageBoxNative = Int32 Function(
IntPtr hWnd, Pointer<Utf16> lpText, Pointer<Utf16> lpCaption, Int32 uType);
typedef MessageBoxDart = int Function(
int hWnd, Pointer<Utf16> lpText, Pointer<Utf16> lpCaption, int uType);
final user32 = DynamicLibrary.open('user32.dll');
final win32MessageBox =
user32.lookupFunction<MessageBoxNative, MessageBoxDart>('MessageBoxW');
void showMessageBox(String message, String caption) => win32MessageBox(